Hello Yuvipanda,

I'd like you to do a code review.  Please visit

    https://gerrit.wikimedia.org/r/336049

to review the following change.


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(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/operations/software/tools-webservice 
refs/changes/49/336049/1

diff --git a/debian/changelog b/debian/changelog
index 8c99636..b31375a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+toollabs-webservice (0.33~dev) unstable; urgency=medium
+
+  * Wait for the Kubernetes pod to shut down after "stop"
+
+ -- Tim Landscheidt <t...@tim-landscheidt.de>  Sun, 05 Feb 2017 03:15:10 +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..808f43c 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: newchange
Gerrit-Change-Id: I51a38c5a6c096f269669e8fdfd3ac19af24ec20b
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/tools-webservice
Gerrit-Branch: master
Gerrit-Owner: Tim Landscheidt <t...@tim-landscheidt.de>
Gerrit-Reviewer: Yuvipanda <yuvipa...@wikimedia.org>

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

Reply via email to