use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsStatus in project stackgres by ongres.
the class DistributedLogsStatusManager method isPendingRestart.
/**
* Check pending restart status condition.
*/
public boolean isPendingRestart(StackGresDistributedLogs distributedLogs) {
List<StackGresClusterPodStatus> clusterPodStatuses = Optional.ofNullable(distributedLogs.getStatus()).map(StackGresDistributedLogsStatus::getPodStatuses).orElse(ImmutableList.of());
Optional<StatefulSet> clusterStatefulSet = getClusterStatefulSet(distributedLogs);
List<Pod> clusterPods = clusterStatefulSet.map(sts -> getStsPods(sts, distributedLogs)).orElse(ImmutableList.of());
RestartReasons reasons = ClusterPendingRestartUtil.getRestartReasons(clusterPodStatuses, clusterStatefulSet, clusterPods);
for (RestartReason reason : reasons.getReasons()) {
switch(reason) {
case OPERATOR_VERSION:
LOGGER.debug("Distributed Logs {} requires restart due to operator version change", getDistributedLogsId(distributedLogs));
break;
case PATRONI:
LOGGER.debug("Distributed Logs {} requires restart due to patroni's indication", getDistributedLogsId(distributedLogs));
break;
case POD_STATUS:
LOGGER.debug("Distributed Logs {} requires restart due to pod status indication", getDistributedLogsId(distributedLogs));
break;
case STATEFULSET:
LOGGER.debug("Distributed Logs {} requires restart due to pod template changes", getDistributedLogsId(distributedLogs));
break;
default:
break;
}
}
return reasons.requiresRestart();
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsStatus in project stackgres by ongres.
the class DistributedLogsControllerReconciliator method reconcile.
@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "False positives")
@Override
protected ReconciliationResult<Void> reconcile(KubernetesClient client, StackGresDistributedLogsContext context) throws Exception {
boolean statusUpdated = false;
ReconciliationResult<Boolean> extensionReconciliationResult = extensionReconciliator.reconcile(client, context);
if (extensionReconciliationResult.result().orElse(false) && context.getCluster().getStatus() != null && context.getCluster().getStatus().getPodStatuses() != null) {
if (context.getDistributedLogs().getStatus() == null) {
context.getDistributedLogs().setStatus(new StackGresDistributedLogsStatus());
}
context.getDistributedLogs().getStatus().setPodStatuses(context.getCluster().getStatus().getPodStatuses());
}
ReconciliationResult<Boolean> clusterReconciliationResult = clusterReconciliator.reconcile(client, context);
statusUpdated = statusUpdated || clusterReconciliationResult.result().orElse(false);
if (extensionReconciliationResult.result().orElse(false) || clusterReconciliationResult.result().orElse(false)) {
distributedLogsScheduler.updateStatus(context.getDistributedLogs(), StackGresDistributedLogs::getStatus, StackGresDistributedLogs::setStatus);
}
return extensionReconciliationResult.join(clusterReconciliationResult);
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsStatus in project stackgres by ongres.
the class DistributedLogsTransformer method getResourceStatus.
private DistributedLogsStatus getResourceStatus(StackGresDistributedLogsStatus source, List<String> clusters) {
DistributedLogsStatus transformation = new DistributedLogsStatus();
transformation.setClusters(clusters);
if (source == null) {
return transformation;
}
final List<StackGresDistributedLogsCondition> sourceConditions = source.getConditions();
if (sourceConditions != null) {
transformation.setConditions(sourceConditions.stream().map(this::getResourceCondition).collect(ImmutableList.toImmutableList()));
}
return transformation;
}
Aggregations