public void run() { Deployment deployment = oper.getMandatory(); if (observedGeneration <= deployment.getStatus().getObservedGeneration()) { countDownLatch.countDown(); } } };
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); } } };
@Override public boolean reap() { Deployment deployment = oper.cascading(false).edit().editSpec().withReplicas(0).endSpec().done(); //TODO: These checks shouldn't be used as they are not realistic. We just use them to support mock/crud tests. Need to find a cleaner way to do so. if (deployment.getStatus() != null) { waitForObservedGeneration(deployment.getStatus().getObservedGeneration()); } if (deployment.getSpec().getSelector() != null) { reapMatchingReplicaSets(deployment.getSpec().getSelector()); } return false; }