Browse Source

Merge "Fix stuck job caused by exception during repo update"

tags/3.6.0
Zuul 5 months ago
parent
commit
6ea6885e21
1 changed files with 26 additions and 13 deletions
  1. 26
    13
      zuul/executor/server.py

+ 26
- 13
zuul/executor/server.py View File

@@ -495,6 +495,7 @@ class UpdateTask(object):
495 495
         self.branches = None
496 496
         self.refs = None
497 497
         self.event = threading.Event()
498
+        self.success = False
498 499
 
499 500
     def __eq__(self, other):
500 501
         if (other and other.connection_name == self.connection_name and
@@ -807,6 +808,11 @@ class AnsibleJob(object):
807 808
 
808 809
         for task in tasks:
809 810
             task.wait()
811
+
812
+            if not task.success:
813
+                raise ExecutorError(
814
+                    'Failed to update project %s' % task.canonical_name)
815
+
810 816
             self.project_info[task.canonical_name] = {
811 817
                 'refs': task.refs,
812 818
                 'branches': task.branches,
@@ -2414,19 +2420,26 @@ class ExecutorServer(object):
2414 2420
         if task is None:
2415 2421
             # We are asked to stop
2416 2422
             raise StopException()
2417
-        with self.merger_lock:
2418
-            self.log.info("Updating repo %s/%s" % (
2419
-                task.connection_name, task.project_name))
2420
-            self.merger.updateRepo(task.connection_name, task.project_name)
2421
-            repo = self.merger.getRepo(task.connection_name, task.project_name)
2422
-            source = self.connections.getSource(task.connection_name)
2423
-            project = source.getProject(task.project_name)
2424
-            task.canonical_name = project.canonical_name
2425
-            task.branches = repo.getBranches()
2426
-            task.refs = [r.name for r in repo.getRefs()]
2427
-            self.log.debug("Finished updating repo %s/%s" %
2428
-                           (task.connection_name, task.project_name))
2429
-        task.setComplete()
2423
+        try:
2424
+            with self.merger_lock:
2425
+                self.log.info("Updating repo %s/%s",
2426
+                              task.connection_name, task.project_name)
2427
+                self.merger.updateRepo(task.connection_name, task.project_name)
2428
+                repo = self.merger.getRepo(
2429
+                    task.connection_name, task.project_name)
2430
+                source = self.connections.getSource(task.connection_name)
2431
+                project = source.getProject(task.project_name)
2432
+                task.canonical_name = project.canonical_name
2433
+                task.branches = repo.getBranches()
2434
+                task.refs = [r.name for r in repo.getRefs()]
2435
+                self.log.debug("Finished updating repo %s/%s",
2436
+                               task.connection_name, task.project_name)
2437
+                task.success = True
2438
+        except Exception:
2439
+            self.log.exception('Got exception while updating repo %s/%s',
2440
+                               task.connection_name, task.project_name)
2441
+        finally:
2442
+            task.setComplete()
2430 2443
 
2431 2444
     def update(self, connection_name, project_name):
2432 2445
         # Update a repository in the main merger

Loading…
Cancel
Save