public static boolean isDeploymentReady(Deployment d) { Utils.checkNotNull(d, "Deployment can't be null."); DeploymentSpec spec = d.getSpec(); DeploymentStatus status = d.getStatus(); if (status == null || status.getReplicas() == null || status.getAvailableReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReplicas() && spec.getReplicas().intValue() <= status.getAvailableReplicas(); }
public void run() { try { Deployment deployment = get(); //If the deployment is gone, we shouldn't wait. if (deployment == null) { if (count == 0) { queue.put(true); return; } else { queue.put(new IllegalStateException("Can't wait for Deployment: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available.")); return; } } replicasRef.set(deployment.getStatus().getReplicas()); int currentReplicas = deployment.getStatus().getReplicas() != null ? deployment.getStatus().getReplicas() : 0; long generation = deployment.getMetadata().getGeneration() != null ? deployment.getMetadata().getGeneration() : 0; long observedGeneration = deployment.getStatus() != null && deployment.getStatus().getObservedGeneration() != null ? deployment.getStatus().getObservedGeneration() : -1; if (observedGeneration >= generation && Objects.equals(deployment.getSpec().getReplicas(), currentReplicas)) { queue.put(true); } else { LOG.debug("Only {}/{} pods scheduled for Deployment: {} in namespace: {} seconds so waiting...", deployment.getStatus().getReplicas(), deployment.getSpec().getReplicas(), deployment.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Deployment to be scaled.", t); } } };
public DeploymentSpecBuilder(DeploymentSpec instance,Boolean validationEnabled){ this.fluent = this; this.withMinReadySeconds(instance.getMinReadySeconds()); this.withPaused(instance.getPaused()); this.withReplicas(instance.getReplicas()); this.withRevisionHistoryLimit(instance.getRevisionHistoryLimit()); this.withRollbackTo(instance.getRollbackTo()); this.withSelector(instance.getSelector()); this.withStrategy(instance.getStrategy()); this.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; }
public DeploymentSpecFluentImpl(DeploymentSpec instance){ this.withMinReadySeconds(instance.getMinReadySeconds()); this.withPaused(instance.getPaused()); this.withReplicas(instance.getReplicas()); this.withRevisionHistoryLimit(instance.getRevisionHistoryLimit()); this.withRollbackTo(instance.getRollbackTo()); this.withSelector(instance.getSelector()); this.withStrategy(instance.getStrategy()); this.withTemplate(instance.getTemplate()); }
public DeploymentSpecBuilder(DeploymentSpecFluent<?> fluent,DeploymentSpec instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withMinReadySeconds(instance.getMinReadySeconds()); fluent.withPaused(instance.getPaused()); fluent.withReplicas(instance.getReplicas()); fluent.withRevisionHistoryLimit(instance.getRevisionHistoryLimit()); fluent.withRollbackTo(instance.getRollbackTo()); fluent.withSelector(instance.getSelector()); fluent.withStrategy(instance.getStrategy()); fluent.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; } public DeploymentSpecBuilder(DeploymentSpec instance){