use of io.stackgres.cluster.common.StackGresClusterContext in project stackgres by ongres.
the class ClusterControllerReconciliator method reconcile.
@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "False positives")
@Override
protected ReconciliationResult<?> reconcile(KubernetesClient client, StackGresClusterContext context) throws Exception {
ReconciliationResult<Boolean> extensionReconciliationResult = extensionReconciliator.reconcile(client, context);
if (extensionReconciliationResult.result().orElse(false)) {
final String podName = propertyContext.getString(ClusterControllerProperty.CLUSTER_CONTROLLER_POD_NAME);
final StackGresCluster cluster = context.getCluster();
final StackGresClusterStatus status = cluster.getStatus();
String clusterName = cluster.getMetadata().getName();
String namespace = cluster.getMetadata().getNamespace();
clusterFinder.findByNameAndNamespace(clusterName, namespace).ifPresent(savedCluster -> {
var newPodStatus = findPodStatus(status.getPodStatuses(), podName).orElseThrow();
Optional.ofNullable(savedCluster.getStatus()).ifPresentOrElse(savedStatus -> Optional.ofNullable(savedStatus.getPodStatuses()).ifPresentOrElse(savedPodStatuses -> findPodStatus(savedPodStatuses, podName).ifPresentOrElse(savedPodStatus -> applyPodStatusChanges(newPodStatus, savedPodStatus), () -> savedPodStatuses.add(newPodStatus)), () -> savedStatus.setPodStatuses(status.getPodStatuses())), () -> savedCluster.setStatus(status));
clusterScheduler.updateStatus(savedCluster);
});
}
return extensionReconciliationResult;
}
Aggregations