Skip to content

Commit

Permalink
new safer upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 30, 2017
1 parent a4babbc commit e2888ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rancher/service.py
Expand Up @@ -79,11 +79,13 @@ def upgrade_service(
interval = 2000,
full_upgrade = True,
try_finish = True,
safe = True,
launch_config = None
):
url = self.base_url + "services/%s?action=upgrade" % id
if try_finish: self._service_try_finish(id)
if launch_config == None: launch_config = self._service_launch_config(id)
if safe and not self._serivce_active(id): return
contents = self.post(
url,
data_j = dict(
Expand Down Expand Up @@ -125,6 +127,10 @@ def restart_service(self, id, batch_size = 1, interval = 2000):
data = contents["data"]
return data

def _serivce_active(self):
service = self.get_service(id)
return service["state"] == "active"

def _service_try_finish(self, id, timeout = 10.0):
try: self.finish_upgrade_service(id)
except: pass
Expand Down

0 comments on commit e2888ef

Please sign in to comment.