@Test public void testDeleteDeployment_WhenK8sReturnsDeploymentWithMismatchingId_DoesNothing() 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.deploymentApi.deleteDeployment(UUID.randomUUID().toString(), namespace, name); verify(this.deploymentMock, never()).delete(); }
public void deleteDeployment(String uid, String namespace, String name) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("Uid should not be null"); } if (name == null) { throw new IllegalArgumentException("Name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("Namespace should not be null"); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { LOG.info(String.format("The deployment with id %s, name %s and namespace %s was not found. Nothing to do.", uid, name, namespace)); return; } try { getKubernetesClient().resource(deployment.getDeploymentResource()).delete(); } catch (KubernetesClientException e) { throw new VmidcException("Failed to delete the deployment"); } }
KubernetesDeploymentApi extends KubernetesApi { public void deleteDeployment(String uid, String namespace, String name) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("Uid should not be null"); } if (name == null) { throw new IllegalArgumentException("Name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("Namespace should not be null"); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { LOG.info(String.format("The deployment with id %s, name %s and namespace %s was not found. Nothing to do.", uid, name, namespace)); return; } try { getKubernetesClient().resource(deployment.getDeploymentResource()).delete(); } catch (KubernetesClientException e) { throw new VmidcException("Failed to delete the deployment"); } } }
KubernetesDeploymentApi extends KubernetesApi { public void deleteDeployment(String uid, String namespace, String name) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("Uid should not be null"); } if (name == null) { throw new IllegalArgumentException("Name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("Namespace should not be null"); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { LOG.info(String.format("The deployment with id %s, name %s and namespace %s was not found. Nothing to do.", uid, name, namespace)); return; } try { getKubernetesClient().resource(deployment.getDeploymentResource()).delete(); } catch (KubernetesClientException e) { throw new VmidcException("Failed to delete the deployment"); } } KubernetesDeploymentApi(KubernetesClient client); }
KubernetesDeploymentApi extends KubernetesApi { public void deleteDeployment(String uid, String namespace, String name) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("Uid should not be null"); } if (name == null) { throw new IllegalArgumentException("Name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("Namespace should not be null"); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { LOG.info(String.format("The deployment with id %s, name %s and namespace %s was not found. Nothing to do.", uid, name, namespace)); return; } try { getKubernetesClient().resource(deployment.getDeploymentResource()).delete(); } catch (KubernetesClientException e) { throw new VmidcException("Failed to delete 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 deleteDeployment(String uid, String namespace, String name) throws VmidcException { if (uid == null) { throw new IllegalArgumentException("Uid should not be null"); } if (name == null) { throw new IllegalArgumentException("Name should not be null"); } if (namespace == null) { throw new IllegalArgumentException("Namespace should not be null"); } KubernetesDeployment deployment = getDeploymentById(uid, namespace, name); if (deployment == null) { LOG.info(String.format("The deployment with id %s, name %s and namespace %s was not found. Nothing to do.", uid, name, namespace)); return; } try { getKubernetesClient().resource(deployment.getDeploymentResource()).delete(); } catch (KubernetesClientException e) { throw new VmidcException("Failed to delete 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; }