Skip to content

Commit

Permalink
fix: default replica values in deployment status to zero
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar committed Jan 2, 2025
1 parent 10c76e4 commit 6d4dd5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.streamshub.console.dependents.conditions;

import java.util.Optional;
import java.util.Objects;

import org.jboss.logging.Logger;

Expand Down Expand Up @@ -41,9 +41,9 @@ private boolean isReady(Deployment deployment) {
}

var desiredReplicas = deployment.getSpec().getReplicas();
var replicas = status.getReplicas();
var updatedReplicas = Optional.ofNullable(status.getUpdatedReplicas()).orElse(-1).intValue();
var availableReplicas = status.getAvailableReplicas();
var replicas = Objects.requireNonNullElse(status.getReplicas(), 0);
var updatedReplicas = Objects.requireNonNullElse(status.getUpdatedReplicas(), 0);
var availableReplicas = Objects.requireNonNullElse(status.getAvailableReplicas(), 0);

if (desiredReplicas != null && updatedReplicas < desiredReplicas) {
LOGGER.debugf("Waiting for deployment %s rollout to finish: %d out of %d new replicas have been updated...", deploymentName, updatedReplicas, desiredReplicas);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ Deployment setReady(Deployment deployment) {
return deployment.edit()
.editOrNewStatus()
.withReplicas(desiredReplicas)
.withUpdatedReplicas(desiredReplicas)
.withAvailableReplicas(desiredReplicas)
.withReadyReplicas(desiredReplicas)
.endStatus()
.build();
Expand Down

0 comments on commit 6d4dd5e

Please sign in to comment.