[MediaWiki-commits] [Gerrit] operations...tools-webservice[master]: Wait for the Kubernetes pod to shut down after "stop"

2017-02-07 Thread jenkins-bot (Code Review)
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   Tue, 07 Feb 2017 13:29:07 +
+
 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 
Gerrit-Reviewer: JustBerry 
Gerrit-Reviewer: Tim Landscheidt 
Gerrit-Reviewer: Yuvipanda 
Gerrit-Reviewer: Zhuyifei1999 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] operations...tools-webservice[master]: Wait for the Kubernetes pod to shut down after "stop"

2017-02-04 Thread Tim Landscheidt (Code Review)
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   Sun, 05 Feb 2017 03:15:10 +
+
 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 
Gerrit-Reviewer: Yuvipanda 

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