@Override long getObservedGeneration(StatefulSet current) { return (current != null && current.getStatus() != null && current.getStatus().getObservedGeneration() != null) ? current.getStatus().getObservedGeneration() : -1; }
@Override long getObservedGeneration(ReplicaSet current) { return (current != null && current.getStatus() != null && current.getStatus().getObservedGeneration() != null)? current.getStatus().getObservedGeneration() : -1; } }
@Override protected StatefulSet setReplicas(StatefulSet obj, int replicas) { return new StatefulSetBuilder(obj).editSpec().withReplicas(replicas).endSpec().build(); }
@Override protected ReplicaSet createClone(ReplicaSet obj, String newName, String newDeploymentHash) { return new ReplicaSetBuilder(obj) .editMetadata() .withResourceVersion(null) .withName(newName) .endMetadata() .editSpec() .withReplicas(0) .editSelector().addToMatchLabels(DEPLOYMENT_KEY, newDeploymentHash).endSelector() .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, newDeploymentHash).endMetadata().endTemplate() .endSpec() .build(); }
@Override protected StatefulSet createClone(StatefulSet obj, String newName, String newDeploymentHash) { return new StatefulSetBuilder(obj) .editMetadata() .withResourceVersion(null) .withName(newName) .endMetadata() .editSpec() .withReplicas(0) .editSelector().addToMatchLabels(DEPLOYMENT_KEY, newDeploymentHash).endSelector() .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, newDeploymentHash).endMetadata().endTemplate() .endSpec() .build(); }
@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; }
@Override protected void updateDeploymentKey(DoneableStatefulSet obj, String hash) { obj.editSpec() .editSelector().addToMatchLabels(DEPLOYMENT_KEY, hash).endSelector() .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, hash).endMetadata().endTemplate() .endSpec(); }
@Override protected void updateDeploymentKey(DoneableReplicaSet obj, String hash) { obj.editSpec() .editSelector().addToMatchLabels(DEPLOYMENT_KEY, hash).endSelector() .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, hash).endMetadata().endTemplate() .endSpec(); }
@Override protected ReplicaSet setReplicas(ReplicaSet obj, int replicas) { return new ReplicaSetBuilder(obj).editSpec().withReplicas(replicas).endSpec().build(); }
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(); }
@Override protected void removeDeploymentKey(DoneableReplicaSet obj) { obj.editSpec() .editSelector().removeFromMatchLabels(DEPLOYMENT_KEY).endSelector() .editTemplate().editMetadata().removeFromLabels(DEPLOYMENT_KEY).endMetadata().endTemplate() .endSpec(); }
@Override protected void removeDeploymentKey(DoneableStatefulSet obj) { obj.editSpec() .editSelector().removeFromMatchLabels(DEPLOYMENT_KEY).endSelector() .editTemplate().editMetadata().removeFromLabels(DEPLOYMENT_KEY).endMetadata().endTemplate() .endSpec(); }
public static boolean isStatefulSetReady(StatefulSet ss) { Utils.checkNotNull(ss, "StatefulSet can't be null."); StatefulSetSpec spec = ss.getSpec(); StatefulSetStatus status =ss.getStatus(); if (status == null || status.getReplicas() == 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(); }
@Override int getDesiredReplicas(StatefulSet item) { return item.getSpec().getReplicas(); }
public static boolean isReplicaSetReady(ReplicaSet r) { Utils.checkNotNull(r, "ReplicationController can't be null."); ReplicaSetSpec spec = r.getSpec(); ReplicaSetStatus status = r.getStatus(); if (status == null || status.getReadyReplicas() == 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.getReadyReplicas(); }
@Override int getDesiredReplicas(ReplicaSet item) { return item.getSpec().getReplicas(); }
@Override int getCurrentReplicas(StatefulSet current) { return current.getStatus().getReplicas(); }
@Override int getCurrentReplicas(ReplicaSet current) { return current.getStatus().getReplicas(); }
@Override protected int getReplicas(StatefulSet obj) { return obj.getSpec().getReplicas(); }
@Override protected int getReplicas(ReplicaSet obj) { return obj.getSpec().getReplicas(); }