summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Williamson <awilliam@redhat.com>2015-08-19 16:33:15 -0700
committerAdam Williamson <awilliam@redhat.com>2015-08-19 16:33:15 -0700
commit60967e2ab532c613341624363a7abb61b6bbf8a8 (patch)
tree954c23a1f2a1f8376d4f2174cfd4f090924376f6
parentea5bf36cbe5e4a94c314cf63461ef28ff7b8f80b (diff)
add koji_done and pungi_done properties to Releases
These can be used to check if a compose is done. Obviously this is dumb and we should be using fedmsg, but right now there is no fedmsg sent after the Koji builds for a nightly compose are done: there's a signal when they're kicked off, but not when they're done. So you get this hack instead. Merry Christmas. Non-Nightly Releases implement the properties so users don't have to check, but they just assume the tasks are done so long as the release 'exists'. This isn't *quiiiiiiiiiite* entirely true, but good enough for government work.
-rw-r--r--fedfind/release.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/fedfind/release.py b/fedfind/release.py
index 3db8c8e..9bd56c3 100644
--- a/fedfind/release.py
+++ b/fedfind/release.py
@@ -254,6 +254,16 @@ class Release(object):
"""
pass
+ @abc.abstractproperty
+ def koji_done(self):
+ """Whether all Koji tasks for the compose are complete."""
+ pass
+
+ @abc.abstractproperty
+ def pungi_done(self):
+ """Whether all Pungi tasks for the compose are complete."""
+ pass
+
def difference(self, other):
"""Similarly to the behaviour of the set.difference() method,
this tells you which images exist for this release but not
@@ -418,6 +428,35 @@ class Nightly(Release):
logger.debug("expected images: {0}".format(imgs))
return tuple(imgs)
+ @property
+ def koji_done(self):
+ """Rather slow way to check if Koji builds are done. Will
+ return True if we have at least one task of each method and
+ all tasks are in one of the known 'finished' states (CLOSED,
+ CANCELED or ASSIGNED.)
+ """
+ for method in ('createLiveCD', 'createAppliance', 'createImage'):
+ opts = {'states': [], 'method': method}
+ tasks = self.get_koji_tasks(opts, nocache=True)
+ if not tasks:
+ logger.debug("koji_done: no tasks for {0}".format(method))
+ return False
+ # KOJI: as we're trying to avoid using the koji module,
+ # these values are hard-coded. Ideally we would use
+ # koji.TASK_STATES here.
+ if any(task['state'] not in (2, 3, 5) for task in tasks):
+ logger.debug("koji_done: running task found")
+ return False
+ return True
+
+ @property
+ def pungi_done(self):
+ """Check to see if Pungi has finished (by looking for the
+ 'finish' file in the compose log directory).
+ """
+ doneurl = "{0}/../logs/finish".format(self.https_url_generic)
+ return fedfind.helpers.url_exists(doneurl)
+
def _get_boot_url(self, arch):
"""Get the expected URL for the boot.iso of a given arch."""
tmpl = '{0}/{1}/os/images/boot.iso'
@@ -638,8 +677,23 @@ class MirrorRelease(Release):
def exists(self):
"""Release 'exists' if its top-level mirror path is there."""
url = '{0}/{1}'.format(fedfind.const.RSYNC, self._rsyncpath)
+ logger.debug("exists: checking URL {0}".format(url))
return fedfind.helpers.url_exists(url)
+ @cached_property
+ def koji_done(self):
+ """For non-nightlies, we just assume Koji and Pungi are done
+ if the compose exists.
+ """
+ return self.exists
+
+ @cached_property
+ def pungi_done(self):
+ """For non-nightlies, we just assume Koji and Pungi are done
+ if the compose exists.
+ """
+ return self.exists
+
@property
def https_url_generic(self):
"""HTTPS URL for the 'generic' tree for this release (whose