Browse Source

Merge "Moving task cache update into task creation transaction"

Jenkins 2 years ago
parent
commit
2ec2a93d53
1 changed files with 12 additions and 21 deletions
  1. 12
    21
      nailgun/nailgun/task/task.py

+ 12
- 21
nailgun/nailgun/task/task.py View File

@@ -946,24 +946,18 @@ class StopDeploymentTask(object):
946 946
                 }
947 947
             }
948 948
         )
949
-        db().commit()
950 949
         return rpc_message
951 950
 
952 951
     @classmethod
953 952
     def execute(cls, task, deploy_task=None, provision_task=None):
954
-        db().commit()
953
+        messages = []
955 954
         if provision_task:
956
-            rpc.cast(
957
-                'naily',
958
-                cls.message(task, provision_task),
959
-                service=True
960
-            )
955
+            messages.append(cls.message(task, provision_task))
961 956
         if deploy_task:
962
-            rpc.cast(
963
-                'naily',
964
-                cls.message(task, deploy_task),
965
-                service=True
966
-            )
957
+            messages.append(cls.message(task, deploy_task))
958
+        db().commit()
959
+        for msg in messages:
960
+            rpc.cast('naily', msg, service=True)
967 961
 
968 962
 
969 963
 class ResetEnvironmentTask(object):
@@ -1962,8 +1956,9 @@ class CheckRepoAvailability(BaseNetworkVerification):
1962 1956
         return rpc_message
1963 1957
 
1964 1958
     def execute(self):
1959
+        message = self.get_message()
1965 1960
         db().commit()
1966
-        rpc.cast('naily', self.get_message())
1961
+        rpc.cast('naily', message)
1967 1962
 
1968 1963
     def _get_nodes_to_check(self):
1969 1964
         nodes = [{'uid': consts.MASTER_NODE_UID}]
@@ -2091,11 +2086,9 @@ class CreateStatsUserTask(object):
2091 2086
 
2092 2087
     @classmethod
2093 2088
     def execute(cls, task, primary_controller):
2089
+        message = cls.message(task, primary_controller)
2094 2090
         db().commit()
2095
-        rpc.cast(
2096
-            'naily',
2097
-            cls.message(task, primary_controller)
2098
-        )
2091
+        rpc.cast('naily', message)
2099 2092
 
2100 2093
 
2101 2094
 class RemoveStatsUserTask(object):
@@ -2124,11 +2117,9 @@ class RemoveStatsUserTask(object):
2124 2117
 
2125 2118
     @classmethod
2126 2119
     def execute(cls, task, primary_controller):
2120
+        message = cls.message(task, primary_controller)
2127 2121
         db().commit()
2128
-        rpc.cast(
2129
-            'naily',
2130
-            cls.message(task, primary_controller)
2131
-        )
2122
+        rpc.cast('naily', message)
2132 2123
 
2133 2124
 
2134 2125
 class UpdateOpenstackConfigTask(BaseDeploymentTask):

Loading…
Cancel
Save