Skip to content

Commit

Permalink
Fix errors in ready replicas retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
olevitt committed Sep 27, 2024
1 parent 2610ee3 commit ec277c8
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ private static List<HealthCheckResult> checkHealth(
.withName(name)
.get();
details.setDesired(deployment.getSpec().getReplicas());
details.setReady(deployment.getStatus().getReadyReplicas());
if (deployment.getStatus().getReplicas() > 0) {
details.setReady(deployment.getStatus().getReadyReplicas());
}
break;
case "StatefulSet":
StatefulSet statefulset =
Expand All @@ -65,7 +67,9 @@ private static List<HealthCheckResult> checkHealth(
.withName(name)
.get();
details.setDesired(statefulset.getSpec().getReplicas());
details.setReady(statefulset.getStatus().getReadyReplicas());
if (statefulset.getStatus().getReplicas() > 0) {
details.setReady(statefulset.getStatus().getReadyReplicas());
}
break;
case "DaemonSet":
DaemonSet daemonSet =
Expand All @@ -76,7 +80,9 @@ private static List<HealthCheckResult> checkHealth(
.withName(name)
.get();
details.setDesired(daemonSet.getStatus().getDesiredNumberScheduled());
details.setReady(daemonSet.getStatus().getNumberReady());
if (daemonSet.getStatus().getNumberAvailable() > 0) {
details.setReady(daemonSet.getStatus().getNumberReady());
}
break;
default:
continue;
Expand Down

0 comments on commit ec277c8

Please sign in to comment.