]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
fog: Cancel stale deploy tasks 1131/head
authorZack Cerza <zack@redhat.com>
Mon, 4 Dec 2017 19:11:19 +0000 (12:11 -0700)
committerZack Cerza <zack@redhat.com>
Mon, 4 Dec 2017 19:11:19 +0000 (12:11 -0700)
In case, for whatever reason, any active deploy tasks already exist for
a given host, cancel them before we schedule a new one.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/provision/fog.py
teuthology/provision/test/test_fog.py

index aa267ea7f2f58ecb59d39ce448c21a842cb9c2eb..a9a3cca05e79b082d60c304d49f6e3f7be881813 100644 (file)
@@ -182,7 +182,10 @@ class FOG(object):
         self.log.info(
             "Scheduling deploy of %s %s",
             self.os_type, self.os_version)
-        # First, we need to find the right tasktype ID
+        # First, let's find and cancel any existing deploy tasks for the host.
+        for task in self.get_deploy_tasks():
+            self.cancel_deploy_task(task['id'])
+        # Next, we need to find the right tasktype ID
         resp = self.do_request(
             '/tasktype',
             data=json.dumps(dict(name='deploy')),
@@ -213,7 +216,11 @@ class FOG(object):
         :returns: A list of deploy tasks which are active on our host
         """
         resp = self.do_request('/task/active')
-        tasks = resp.json()['tasks']
+        try:
+            tasks = resp.json()['tasks']
+        except Exception:
+            self.log.exception("Failed to get deploy tasks!")
+            return list()
         host_tasks = [obj for obj in tasks
                       if obj['host']['name'] == self.shortname]
         return host_tasks
index f370cd6e4801a301bc52c8067039a8526cb10a8f..d849bee21f45afd94f49fd0b0dcdad2c23a7d968 100644 (file)
@@ -213,7 +213,7 @@ class TestFOG(object):
             obj = self.klass('name.fqdn', 'type', '1.0')
             result = obj.schedule_deploy_task(host_id)
             assert local_mocks['get_deploy_tasks'].called_once_with()
-        assert len(self.mocks['m_requests_Session_send'].call_args_list) == 2
+        assert len(self.mocks['m_requests_Session_send'].call_args_list) == 3
         assert result == task_id
 
     def test_get_deploy_tasks(self):