@Test public void testUpdateDeploymentReplicaCount_WhenK8sReturnsDeploymentWithMismatchingId_ReturnsNull() throws Exception { String name = UUID.randomUUID().toString(); String namespace = UUID.randomUUID().toString(); mockDeploymentByName(namespace, name, newDeployment(UUID.randomUUID().toString(), name, namespace, 1, "image-sample-name")); this.exception.expect(VmidcException.class); this.deploymentApi.updateDeploymentReplicaCount(UUID.randomUUID().toString(), namespace, name, 1); }
public void updateDeploymentReplicaCount(String uid, String namespace, String name, int replicaCount) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("The uid should not be null"); } if (name == null) { throw new IllegalArgumentException("The name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("The namespace should not be null"); } if (replicaCount < 1) { throw new IllegalArgumentException("The replica count should not be smaller than 1."); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { throw new VmidcException(String.format("The deployment with id %s, name %s and namespace %s was not found during update.", uid, name, namespace)); } try { getKubernetesClient().extensions().deployments().inNamespace(namespace).withName(name).scale(replicaCount); } catch (KubernetesClientException e) { throw new VmidcException("Failed to update the deployment"); } }
KubernetesDeploymentApi extends KubernetesApi { public void updateDeploymentReplicaCount(String uid, String namespace, String name, int replicaCount) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("The uid should not be null"); } if (name == null) { throw new IllegalArgumentException("The name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("The namespace should not be null"); } if (replicaCount < 1) { throw new IllegalArgumentException("The replica count should not be smaller than 1."); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { throw new VmidcException(String.format("The deployment with id %s, name %s and namespace %s was not found during update.", uid, name, namespace)); } try { getKubernetesClient().extensions().deployments().inNamespace(namespace).withName(name).scale(replicaCount); } catch (KubernetesClientException e) { throw new VmidcException("Failed to update the deployment"); } } }
KubernetesDeploymentApi extends KubernetesApi { public void updateDeploymentReplicaCount(String uid, String namespace, String name, int replicaCount) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("The uid should not be null"); } if (name == null) { throw new IllegalArgumentException("The name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("The namespace should not be null"); } if (replicaCount < 1) { throw new IllegalArgumentException("The replica count should not be smaller than 1."); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { throw new VmidcException(String.format("The deployment with id %s, name %s and namespace %s was not found during update.", uid, name, namespace)); } try { getKubernetesClient().extensions().deployments().inNamespace(namespace).withName(name).scale(replicaCount); } catch (KubernetesClientException e) { throw new VmidcException("Failed to update the deployment"); } } KubernetesDeploymentApi(KubernetesClient client); }
KubernetesDeploymentApi extends KubernetesApi { public void updateDeploymentReplicaCount(String uid, String namespace, String name, int replicaCount) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("The uid should not be null"); } if (name == null) { throw new IllegalArgumentException("The name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("The namespace should not be null"); } if (replicaCount < 1) { throw new IllegalArgumentException("The replica count should not be smaller than 1."); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { throw new VmidcException(String.format("The deployment with id %s, name %s and namespace %s was not found during update.", uid, name, namespace)); } try { getKubernetesClient().extensions().deployments().inNamespace(namespace).withName(name).scale(replicaCount); } catch (KubernetesClientException e) { throw new VmidcException("Failed to update the deployment"); } } KubernetesDeploymentApi(KubernetesClient client); KubernetesDeployment getDeploymentById(String uid, String namespace, String name); void deleteDeployment(String uid, String namespace, String name); void updateDeploymentReplicaCount(String uid, String namespace, String name, int replicaCount); String createDeployment(KubernetesDeployment deployment); }
KubernetesDeploymentApi extends KubernetesApi { public void updateDeploymentReplicaCount(String uid, String namespace, String name, int replicaCount) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("The uid should not be null"); } if (name == null) { throw new IllegalArgumentException("The name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("The namespace should not be null"); } if (replicaCount < 1) { throw new IllegalArgumentException("The replica count should not be smaller than 1."); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { throw new VmidcException(String.format("The deployment with id %s, name %s and namespace %s was not found during update.", uid, name, namespace)); } try { getKubernetesClient().extensions().deployments().inNamespace(namespace).withName(name).scale(replicaCount); } catch (KubernetesClientException e) { throw new VmidcException("Failed to update the deployment"); } } KubernetesDeploymentApi(KubernetesClient client); KubernetesDeployment getDeploymentById(String uid, String namespace, String name); void deleteDeployment(String uid, String namespace, String name); void updateDeploymentReplicaCount(String uid, String namespace, String name, int replicaCount); String createDeployment(KubernetesDeployment deployment); final static String OSC_DEPLOYMENT_LABEL_NAME; }