From e9a04c4db0330956b3da7340fa36f156e59c1b55 Mon Sep 17 00:00:00 2001 From: Stan Lagun Date: Wed, 15 Apr 2015 03:02:09 +0300 Subject: [PATCH] Fixes replication controller deletion KubernetesCluster method to delete RC was using incorrect property and there was a typo in execution plan making it fail on validation Also renames destroy* methods to delete* methods to match Kubernetes terms Change-Id: I2ff71679deeb5ad3692fcc1a5fcfed8fa0e8d94f Closes-Bug: #1443857 --- .../package/Classes/KubernetesCluster.yaml | 16 +++++++-------- .../DeleteReplicationController.template | 20 +++++++++++++++++++ ...ervice.template => DeleteService.template} | 8 ++++---- .../DestroyReplicationController.template | 20 ------------------- ...ller.sh => deleteReplicationController.sh} | 0 .../{destroyService.sh => deleteService.sh} | 0 .../package/Classes/KubernetesPod.yaml | 4 ++-- 7 files changed, 34 insertions(+), 34 deletions(-) create mode 100644 Kubernetes/KubernetesCluster/package/Resources/DeleteReplicationController.template rename Kubernetes/KubernetesCluster/package/Resources/{DestroyService.template => DeleteService.template} (61%) delete mode 100644 Kubernetes/KubernetesCluster/package/Resources/DestroyReplicationController.template rename Kubernetes/KubernetesCluster/package/Resources/scripts/{destroyReplicationController.sh => deleteReplicationController.sh} (100%) rename Kubernetes/KubernetesCluster/package/Resources/scripts/{destroyService.sh => deleteService.sh} (100%) diff --git a/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml b/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml index b7a2c10..43011e9 100644 --- a/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml +++ b/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml @@ -148,15 +148,15 @@ Methods: - $.masterNode.instance.agent.call($template, $resources) - destroyReplicationController: + deleteReplicationController: Arguments: - id: Contract: $.string().notNull() Body: - $.deploy() - $resources: new(sys:Resources) - - $template: $resources.yaml('DestroyReplicationController.template').bind(dict(rcId => $id)) - - $.kubernetesCluster.masterNode.instance.agent.call($template, $resources) + - $template: $resources.yaml('DeleteReplicationController.template').bind(dict(rcId => $id)) + - $.masterNode.instance.agent.call($template, $resources) createServices: @@ -257,7 +257,7 @@ Methods: Do: - If: not $service in $servicesUsed Then: - - $._destroyService($service) + - $._deleteService($service) - $._environment.stack.push() @@ -349,26 +349,26 @@ Methods: - $.setAttr(lastGatewayCount, $.gatewayCount) - _destroyService: + _deleteService: Arguments: serviceName: Contract: $.string().notNull() Body: - $resources: new(sys:Resources) - - $template: $resources.yaml('DestroyService.template').bind(dict( + - $template: $resources.yaml('DeleteService.template').bind(dict( serviceId => $service )) - $.masterNode.instance.agent.call($template, $resources) - destroyService: + deleteService: Arguments: - applicationName: Contract: $.string().notNull() - podId: Contract: $.string().notNull() Body: - - $._destroyService($applicationName, $podId) + - $._deleteService($applicationName, $podId) _findUnusedPort: diff --git a/Kubernetes/KubernetesCluster/package/Resources/DeleteReplicationController.template b/Kubernetes/KubernetesCluster/package/Resources/DeleteReplicationController.template new file mode 100644 index 0000000..d2eb652 --- /dev/null +++ b/Kubernetes/KubernetesCluster/package/Resources/DeleteReplicationController.template @@ -0,0 +1,20 @@ +FormatVersion: 2.0.0 +Version: 1.0.0 +Name: Delete Replication Controller + +Parameters: + rcId: $rcId + +Body: | + return deleteReplicationController(args.rcId).stdout + +Scripts: + deleteReplicationController: + Type: Application + Version: 1.0.0 + EntryPoint: deleteReplicationController.sh + Files: [] + Options: + captureStdout: true + captureStderr: true + diff --git a/Kubernetes/KubernetesCluster/package/Resources/DestroyService.template b/Kubernetes/KubernetesCluster/package/Resources/DeleteService.template similarity index 61% rename from Kubernetes/KubernetesCluster/package/Resources/DestroyService.template rename to Kubernetes/KubernetesCluster/package/Resources/DeleteService.template index 4a8d639..05afb4f 100644 --- a/Kubernetes/KubernetesCluster/package/Resources/DestroyService.template +++ b/Kubernetes/KubernetesCluster/package/Resources/DeleteService.template @@ -1,18 +1,18 @@ FormatVersion: 2.0.0 Version: 1.0.0 -Name: Destroy Service +Name: Delete Service Parameters: serviceId: $serviceId Body: | - return destroyService('{0}'.format(args.serviceId)).stdout + return deleteService('{0}'.format(args.serviceId)).stdout Scripts: - destroyService: + deleteService: Type: Application Version: 1.0.0 - EntryPoint: destroyService.sh + EntryPoint: deleteService.sh Files: [] Options: captureStdout: true diff --git a/Kubernetes/KubernetesCluster/package/Resources/DestroyReplicationController.template b/Kubernetes/KubernetesCluster/package/Resources/DestroyReplicationController.template deleted file mode 100644 index 6668533..0000000 --- a/Kubernetes/KubernetesCluster/package/Resources/DestroyReplicationController.template +++ /dev/null @@ -1,20 +0,0 @@ -FormattVersion: 2.0.0 -Version: 1.0.0 -Name: Destroy Replication Controller - -Parameters: - rcId: $rcId - -Body: | - return destroyReplicationController(args.rcId).stdout - -Scripts: - destroyReplicationController: - Type: Application - Version: 1.0.0 - EntryPoint: destroyReplicationController.sh - Files: [] - Options: - captureStdout: true - captureStderr: true - diff --git a/Kubernetes/KubernetesCluster/package/Resources/scripts/destroyReplicationController.sh b/Kubernetes/KubernetesCluster/package/Resources/scripts/deleteReplicationController.sh similarity index 100% rename from Kubernetes/KubernetesCluster/package/Resources/scripts/destroyReplicationController.sh rename to Kubernetes/KubernetesCluster/package/Resources/scripts/deleteReplicationController.sh diff --git a/Kubernetes/KubernetesCluster/package/Resources/scripts/destroyService.sh b/Kubernetes/KubernetesCluster/package/Resources/scripts/deleteService.sh similarity index 100% rename from Kubernetes/KubernetesCluster/package/Resources/scripts/destroyService.sh rename to Kubernetes/KubernetesCluster/package/Resources/scripts/deleteService.sh diff --git a/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml b/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml index a334b71..6a6d6e6 100644 --- a/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml +++ b/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml @@ -158,7 +158,7 @@ Methods: Contract: $.string().notNull() Body: - $._deleteContainer($name) - - $.kubernetesCluster.destroyService( + - $.kubernetesCluster.deleteService( applicationName => $name, podId => $._getPodName()) - $.deploy() @@ -195,7 +195,7 @@ Methods: definition => $rcDefinition, isNew => $prevReplicas = 0) - If: $.replicas = 0 and $prevReplicas > 0 Then: - - $.kubernetesCluster.destroyReplicationController($._getReplicationControllerId()) + - $.kubernetesCluster.deleteReplicationController($._getReplicationControllerId()) - $.setAttr(lastReplicas, $.replicas) - $._environment.reporter.report($, 'Pod {0} is ready'.format($.name))