jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/336049 )

Change subject: Wait for the Kubernetes pod to shut down after "stop"
......................................................................


Wait for the Kubernetes pod to shut down after "stop"

Currently, with the Kubernetes backend "webservice stop" only waits
until the corresponding service and deployment have been deleted, but
not the pod itself.  If a webservice is started immediately
afterwards, for example by "webservice restart", this means that for a
short while two pods can exist, one for the terminating and one for
the starting webservice.  This causes the script to fail because it
cannot cope with two parallel webservice pods, and there are probably
other code paths that do not expect this.  In addition, this behaviour
can be surprising to users and administrators because the SGE backend
waits for the webservice job to be gone.

This change amends the logic of "webservice stop" for Kubernetes
backends so that it wait until the webservice pod has been deleted.

Bug: T156626
Change-Id: I51a38c5a6c096f269669e8fdfd3ac19af24ec20b
---
M debian/changelog
M toollabs/webservice/backends/kubernetesbackend.py
2 files changed, 14 insertions(+), 5 deletions(-)

Approvals:
  Tim Landscheidt: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/debian/changelog b/debian/changelog
index 8c99636..4df7a91 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+toollabs-webservice (0.33) trusty; urgency=medium
+
+  * Wait for the Kubernetes pod to shut down after "stop"
+
+ -- Tim Landscheidt <t...@tim-landscheidt.de>  Tue, 07 Feb 2017 13:29:07 +0000
+
 toollabs-webservice (0.32) trusty; urgency=medium
 
   * change absolute kubectl path to '/usr/bin/kubectl'
diff --git a/toollabs/webservice/backends/kubernetesbackend.py 
b/toollabs/webservice/backends/kubernetesbackend.py
index 39a6bbd..24cf1ac 100644
--- a/toollabs/webservice/backends/kubernetesbackend.py
+++ b/toollabs/webservice/backends/kubernetesbackend.py
@@ -380,15 +380,18 @@
         self._delete_obj(pykube.Pod, self.webservice_label_selector)
 
     def get_state(self):
+        pod = self._find_obj(pykube.Pod, self.webservice_label_selector)
+        if pod is not None:
+            if pod.obj['status']['phase'] == 'Running':
+                return Backend.STATE_RUNNING
+            elif pod.obj['status']['phase'] == 'Pending':
+                return Backend.STATE_PENDING
         svc = self._find_obj(pykube.Service, self.webservice_label_selector)
         deployment = self._find_obj(pykube.Deployment, 
self.webservice_label_selector)
         if svc is not None and deployment is not None:
-            pod = self._find_obj(pykube.Pod, self.webservice_label_selector)
-            if pod is not None:
-                if pod.obj['status']['phase'] == 'Running':
-                    return Backend.STATE_RUNNING
             return Backend.STATE_PENDING
-        return Backend.STATE_STOPPED
+        else:
+            return Backend.STATE_STOPPED
 
     def shell(self):
         podSpec = self._get_shell_pod()

-- 
To view, visit https://gerrit.wikimedia.org/r/336049
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I51a38c5a6c096f269669e8fdfd3ac19af24ec20b
Gerrit-PatchSet: 4
Gerrit-Project: operations/software/tools-webservice
Gerrit-Branch: master
Gerrit-Owner: Tim Landscheidt <t...@tim-landscheidt.de>
Gerrit-Reviewer: JustBerry <justinberr...@gmail.com>
Gerrit-Reviewer: Tim Landscheidt <t...@tim-landscheidt.de>
Gerrit-Reviewer: Yuvipanda <yuvipa...@wikimedia.org>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to