| |
@@ -951,7 +951,7 @@
|
| |
|
| |
@property
|
| |
def chroot_states(self):
|
| |
- return map(lambda chroot: chroot.status, self.build_chroots)
|
| |
+ return list(map(lambda chroot: chroot.status, self.build_chroots))
|
| |
|
| |
def get_chroots_by_status(self, statuses=None):
|
| |
"""
|
| |
@@ -981,16 +981,34 @@
|
| |
if self.canceled:
|
| |
return StatusEnum("canceled")
|
| |
|
| |
- use_src_statuses = ["starting", "pending", "running", "failed"]
|
| |
+ use_src_statuses = ["starting", "pending", "running", "importing", "failed"]
|
| |
if self.source_status in [StatusEnum(s) for s in use_src_statuses]:
|
| |
return self.source_status
|
| |
|
| |
- for state in ["running", "starting", "pending", "failed", "succeeded", "skipped", "forked", "waiting"]:
|
| |
+ if not self.chroot_states:
|
| |
+ # There were some builds in DB which had source_status equal
|
| |
+ # to 'succeeded', while they had no biuld_chroots created.
|
| |
+ # The original source of this inconsistency isn't known
|
| |
+ # because we only ever flip source_status to "succeded" directly
|
| |
+ # from the "importing" state.
|
| |
+ # Anyways, return something meaningful here so we can debug
|
| |
+ # properly if such situation happens.
|
| |
+ app.logger.error("Build %s has source_status succeeded, but "
|
| |
+ "no build_chroots", self.id)
|
| |
+ return StatusEnum("waiting")
|
| |
+
|
| |
+ for state in ["running", "starting", "pending", "failed", "succeeded", "skipped", "forked"]:
|
| |
if StatusEnum(state) in self.chroot_states:
|
| |
- if state == "waiting":
|
| |
- return self.source_status
|
| |
- else:
|
| |
- return StatusEnum(state)
|
| |
+ return StatusEnum(state)
|
| |
+
|
| |
+ if StatusEnum("waiting") in self.chroot_states:
|
| |
+ # We should atomically flip
|
| |
+ # a) build.source_status: "importing" -> "succeeded" and
|
| |
+ # b) biuld_chroot.status: "waiting" -> "pending"
|
| |
+ # so at this point nothing really should be in "waiting" state.
|
| |
+ app.logger.error("Build chroots pending, even though build %s"
|
| |
+ " has succeeded source_status", self.id)
|
| |
+ return StatusEnum("pending")
|
| |
|
| |
return None
|
| |
|
| |
... as it strikes again in issue #668.