use of io.stackgres.common.ClusterPendingRestartUtil.RestartReason 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.ClusterPendingRestartUtil.RestartReason in project stackgres by ongres.
the class ClusterStatusManager method isPendingRestart.
/**
* Check pending restart status condition.
*/
public boolean isPendingRestart(StackGresCluster cluster) {
List<StackGresClusterPodStatus> clusterPodStatuses = Optional.ofNullable(cluster.getStatus()).map(StackGresClusterStatus::getPodStatuses).orElse(ImmutableList.of());
Optional<StatefulSet> clusterStatefulSet = getClusterStatefulSet(cluster);
List<Pod> clusterPods = clusterStatefulSet.map(sts -> getStsPods(sts, cluster)).orElse(ImmutableList.of());
RestartReasons reasons = ClusterPendingRestartUtil.getRestartReasons(clusterPodStatuses, clusterStatefulSet, clusterPods);
for (RestartReason reason : reasons.getReasons()) {
switch(reason) {
case OPERATOR_VERSION:
LOGGER.debug("Cluster {} requires restart due to operator version change", getClusterId(cluster));
break;
case PATRONI:
LOGGER.debug("Cluster {} requires restart due to patroni's indication", getClusterId(cluster));
break;
case POD_STATUS:
LOGGER.debug("Cluster {} requires restart due to pod status indication", getClusterId(cluster));
break;
case STATEFULSET:
LOGGER.debug("Cluster {} requires restart due to pod template changes", getClusterId(cluster));
break;
default:
break;
}
}
return reasons.requiresRestart();
}
Aggregations