Skip to content

Commit

Permalink
Fix errors ready replicas (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
olevitt authored Oct 8, 2024
1 parent d590e25 commit f61c0b3
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ private static List<HealthCheckResult> checkHealth(
.inNamespace(namespace)
.withName(name)
.get();
if (deployment == null) continue;
details.setDesired(deployment.getSpec().getReplicas());
details.setReady(deployment.getStatus().getReadyReplicas());
// If replicas is 0 then readyReplicas is not defined (and can't be
// different from 0 anyway)
if (deployment.getStatus().getReplicas() > 0
&& deployment.getStatus().getReadyReplicas() != null) {
details.setReady(deployment.getStatus().getReadyReplicas());
}
break;
case "StatefulSet":
StatefulSet statefulset =
Expand All @@ -64,8 +70,14 @@ private static List<HealthCheckResult> checkHealth(
.inNamespace(namespace)
.withName(name)
.get();
if (statefulset == null) continue;
details.setDesired(statefulset.getSpec().getReplicas());
details.setReady(statefulset.getStatus().getReadyReplicas());
// If replicas is 0 then readyReplicas is not defined (and can't be
// different from 0 anyway)
if (statefulset.getStatus().getReplicas() > 0
&& statefulset.getStatus().getReadyReplicas() != null) {
details.setReady(statefulset.getStatus().getReadyReplicas());
}
break;
case "DaemonSet":
DaemonSet daemonSet =
Expand All @@ -75,8 +87,14 @@ private static List<HealthCheckResult> checkHealth(
.inNamespace(namespace)
.withName(name)
.get();
if (daemonSet == null) continue;
details.setDesired(daemonSet.getStatus().getDesiredNumberScheduled());
details.setReady(daemonSet.getStatus().getNumberReady());
// If replicas is 0 then readyReplicas is not defined (and can't be
// different from 0 anyway)
if (daemonSet.getStatus().getNumberAvailable() > 0
&& daemonSet.getStatus().getNumberReady() != null) {
details.setReady(daemonSet.getStatus().getNumberReady());
}
break;
default:
continue;
Expand Down

0 comments on commit f61c0b3

Please sign in to comment.