public static boolean isDeploymentConfigReady(DeploymentConfig d) { Utils.checkNotNull(d, "Deployment can't be null."); DeploymentConfigSpec spec = d.getSpec(); DeploymentConfigStatus 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 { DeploymentConfig deploymentConfig = get(); //If the rs is gone, we shouldn't wait. if (deploymentConfig == null) { if (count == 0) { queue.put(true); return; } else { queue.put(new IllegalStateException("Can't wait for DeploymentConfig: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available.")); return; } } replicasRef.set(deploymentConfig.getStatus().getReplicas()); int currentReplicas = deploymentConfig.getStatus().getReplicas() != null ? deploymentConfig.getStatus().getReplicas() : 0; if (deploymentConfig.getStatus().getObservedGeneration() >= deploymentConfig.getMetadata().getGeneration() && Objects.equals(deploymentConfig.getSpec().getReplicas(), currentReplicas)) { queue.put(true); } else { LOG.debug("Only {}/{} pods scheduled for DeploymentConfig: {} in namespace: {} seconds so waiting...", deploymentConfig.getStatus().getReplicas(), deploymentConfig.getSpec().getReplicas(), deploymentConfig.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Deployment to be scaled.", t); } } };
public static boolean isDeploymentConfigReady(DeploymentConfig d) { Utils.checkNotNull(d, "Deployment can't be null."); DeploymentConfigSpec spec = d.getSpec(); DeploymentConfigStatus 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 { DeploymentConfig deploymentConfig = get(); //If the rs is gone, we shouldn't wait. if (deploymentConfig == null) { if (count == 0) { queue.put(true); return; } else { queue.put(new IllegalStateException("Can't wait for DeploymentConfig: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available.")); return; } } replicasRef.set(deploymentConfig.getStatus().getReplicas()); int currentReplicas = deploymentConfig.getStatus().getReplicas() != null ? deploymentConfig.getStatus().getReplicas() : 0; if (deploymentConfig.getStatus().getObservedGeneration() >= deploymentConfig.getMetadata().getGeneration() && Objects.equals(deploymentConfig.getSpec().getReplicas(), currentReplicas)) { queue.put(true); } else { LOG.debug("Only {}/{} pods scheduled for DeploymentConfig: {} in namespace: {} seconds so waiting...", deploymentConfig.getStatus().getReplicas(), deploymentConfig.getSpec().getReplicas(), deploymentConfig.getMetadata().getName(), namespace); } } catch (Throwable t) { LOG.error("Error while waiting for Deployment to be scaled.", t); } } };
@Override public boolean isScaled(String name, int desiredReplicas, Map<String, String> labels) { List<DeploymentConfig> deploymentConfigs = getDeploymentsByLabel(labels); if (deploymentConfigs.isEmpty()) { return false; } DeploymentConfig dc = deploymentConfigs.get(0); int allReplicas = 0; int availableReplicas = 0; if (dc != null && dc.getStatus() != null) { DeploymentConfigStatus status = dc.getStatus(); allReplicas = nullSafe(status.getReplicas()); availableReplicas = nullSafe(status.getAvailableReplicas()); } return desiredReplicas == allReplicas && desiredReplicas == availableReplicas; }
@Override public boolean isScaled(String name, int desiredReplicas) { String sName = Names.sanitize(name); DeploymentConfig dc = openShiftClient.deploymentConfigs().withName(sName).get(); int allReplicas = 0; int availableReplicas = 0; if (dc != null && dc.getStatus() != null) { DeploymentConfigStatus status = dc.getStatus(); allReplicas = nullSafe(status.getReplicas()); availableReplicas = nullSafe(status.getAvailableReplicas()); } return desiredReplicas == allReplicas && desiredReplicas == availableReplicas; }
public DeploymentConfigStatusBuilder(DeploymentConfigStatus instance,Boolean validationEnabled){ this.fluent = this; this.withAvailableReplicas(instance.getAvailableReplicas()); this.withDetails(instance.getDetails()); this.withLatestVersion(instance.getLatestVersion()); this.withObservedGeneration(instance.getObservedGeneration()); this.withReplicas(instance.getReplicas()); this.withUnavailableReplicas(instance.getUnavailableReplicas()); this.withUpdatedReplicas(instance.getUpdatedReplicas()); this.validationEnabled = validationEnabled; }
public DeploymentConfigStatusFluentImpl(DeploymentConfigStatus instance){ this.withAvailableReplicas(instance.getAvailableReplicas()); this.withDetails(instance.getDetails()); this.withLatestVersion(instance.getLatestVersion()); this.withObservedGeneration(instance.getObservedGeneration()); this.withReplicas(instance.getReplicas()); this.withUnavailableReplicas(instance.getUnavailableReplicas()); this.withUpdatedReplicas(instance.getUpdatedReplicas()); }
public DeploymentConfigStatusBuilder(DeploymentConfigStatusFluent<?> fluent,DeploymentConfigStatus instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withAvailableReplicas(instance.getAvailableReplicas()); fluent.withDetails(instance.getDetails()); fluent.withLatestVersion(instance.getLatestVersion()); fluent.withObservedGeneration(instance.getObservedGeneration()); fluent.withReplicas(instance.getReplicas()); fluent.withUnavailableReplicas(instance.getUnavailableReplicas()); fluent.withUpdatedReplicas(instance.getUpdatedReplicas()); this.validationEnabled = validationEnabled; } public DeploymentConfigStatusBuilder(DeploymentConfigStatus instance){