From 0549313491d63a09759fa0be65644e93cf2b7dac Mon Sep 17 00:00:00 2001 From: Stan Lagun Date: Sat, 10 Oct 2015 01:41:09 +0300 Subject: [PATCH] [Docker] Do not try to delete container on destroyed host When Environment get deleted both Docker/k8s host and Docker applications get deleted. So it is possible that host will try to delete container from an Instance that was already destroyed. Attempt to send commands to such instance will hang until timeout because there is no more agent exist on the other side. Change-Id: Ia6e8064ae50c24ce595ed08e446ed45b96b4a330 Closes-Bug: #1504623 Depends-On: I298f3f079a153ef87ed7213b7f1432c9e5e4b4b6 --- .../package/Classes/DockerApplication.yaml | 1 - .../package/Classes/DockerStandaloneHost.yaml | 2 +- .../package/Classes/KubernetesCluster.yaml | 5 ++++- .../package/Classes/KubernetesMasterNode.yaml | 4 ++++ .../package/Classes/KubernetesPod.yaml | 14 ++++++++------ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/DockerInterfacesLibrary/package/Classes/DockerApplication.yaml b/DockerInterfacesLibrary/package/Classes/DockerApplication.yaml index 82e6fc2..7516e24 100644 --- a/DockerInterfacesLibrary/package/Classes/DockerApplication.yaml +++ b/DockerInterfacesLibrary/package/Classes/DockerApplication.yaml @@ -61,7 +61,6 @@ Methods: destroy: Body: - - $.host.deploy() - If: $.getAttr(container, null) != null Then: - $container: $.getContainer() diff --git a/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml b/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml index 46454de..58ed9d6 100644 --- a/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml +++ b/DockerStandaloneHost/package/Classes/DockerStandaloneHost.yaml @@ -273,7 +273,7 @@ Methods: - name: Contract: $.string().notNull() Body: - - If: $name in $.containers + - If: $name in $.containers and $.instance.isDeployed() Then: - $._environment.reporter.report($this, 'Deleting container {0}'.format($name)) - $._removeApplicationEndpoints($name) diff --git a/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml b/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml index 779d1be..6213e2f 100644 --- a/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml +++ b/Kubernetes/KubernetesCluster/package/Classes/KubernetesCluster.yaml @@ -63,12 +63,15 @@ Properties: Default: [] Usage: Out - Methods: initialize: Body: - $._environment: $.find(std:Environment).require() + isAvailable: + Body: + - Return: $.masterNode.isAvailable() + deploy: Body: diff --git a/Kubernetes/KubernetesCluster/package/Classes/KubernetesMasterNode.yaml b/Kubernetes/KubernetesCluster/package/Classes/KubernetesMasterNode.yaml index 1d711bb..4692af3 100644 --- a/Kubernetes/KubernetesCluster/package/Classes/KubernetesMasterNode.yaml +++ b/Kubernetes/KubernetesCluster/package/Classes/KubernetesMasterNode.yaml @@ -70,3 +70,7 @@ Methods: - $ip: coalesce($.instance.floatingIpAddress, $.getIp()) - $._environment.reporter.report($this, $msg.format($ip)) + isAvailable: + Body: + Return: $.instance.isDeployed() + diff --git a/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml b/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml index 8850c97..7959226 100644 --- a/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml +++ b/Kubernetes/KubernetesPod/package/Classes/KubernetesPod.yaml @@ -215,12 +215,14 @@ Methods: - name: Contract: $.string().notNull() Body: - - $._loadCurrentPodDefinition() - - $._deleteContainer($name) - - $.kubernetesCluster.deleteServices( - applicationName => $name, - podId => $._getPodName()) - - $.deploy() + - If: $.kubernetesCluster.isAvailable() + Then: + - $._loadCurrentPodDefinition() + - $._deleteContainer($name) + - $.kubernetesCluster.deleteServices( + applicationName => $name, + podId => $._getPodName()) + - $.deploy() _generateVolumeName: