Skip to content

Commit

Permalink
Add step in Composer Task for creating a FrequencyUpdateInfoMetadata.…
Browse files Browse the repository at this point in the history
…json

Signed-off-by: RishabhSaini <[email protected]>
  • Loading branch information
RishabhSaini committed Apr 12, 2023
1 parent ceeaad9 commit 30b1956
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 5 deletions.
67 changes: 67 additions & 0 deletions bodhi-server/bodhi/server/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,73 @@ def modifyrepo(comp_type, compose_path, filetype, extension, source, zchunk):
repodata = os.path.join(repo_path, arch, 'os', 'repodata')
insert_in_repo(comp_type, repodata, filetype, extension, source, zchunk)

class FrequencyUpdateInfoMetadata(object):
"""
This class represents the frequencyupdateinfo.json metadata
"""

def __init__(release, update, update_status):
"""
Initialize the FrequencyUpdateInfoMetadata object.
Args:
release (bodhi.server.models.Release): The Release that is being composed.
update (bodhi.server.models.Update):
update_status (bodhi.server.models.UpdateStatus):
"""
updates = update.query.filter(
update.status.in_(
[update_status.stable])
).filter(
update.release_id == release.id
).order_by(
update.date_submitted
)
modified_updates = []
for update in updates:
simplified_update = {
"release" : {
"name" : update.release.name,
"version" : update.release.version,
},
"alias" : update.alias,
"date_stable" : update.date_stable,
"builds" : [{"nvr_name" : build.nvr_name()} for build in update.builds],
}
modified_updates.push(simplified_update)
self.comp_type = cr.XZ

# Some repos such as FEDORA-EPEL, are primarily targeted at
# distributions that use the yum client, which does not support zchunk metadata
self.legacy_repos = ['FEDORA-EPEL']
self.zchunk = True

if release.id_prefix in self.legacy_repos:
# FIXME: I'm not sure which versions of RHEL support xz metadata
# compression, so use the lowest common denominator for now.
self.comp_type = cr.BZ2

log.warning(
'Zchunk data is disabled for repo {release.id_prefix} until it moves to a client'
' with Zchunk support'
)
self.zchunk = False

self.finfo = modified_updates

def insert_frequencyupdateinfo(self, compose_path):
"""
Add the frequencyupdateinfo.xml file to the repository.
Args:
compose_path (str): The path to the compose where the metadata will be inserted.
"""
fd, tmp_file_path = tempfile.mkstemp()
tmp_file_path.write(json.dumps(self.finfo))
repo_path = os.path.join(compose_path, 'compose', 'Everything')
repodata = os.path.join(repo_path, 'source', 'tree', 'repodata')
insert_in_repo(self.comp_type, repodata, 'frequencyupdateinfo', 'json', tmp_file_path, self.zchunk)
os.unlink(tmp_file_path)

class UpdateInfoMetadata(object):
"""
Expand Down
28 changes: 23 additions & 5 deletions bodhi-server/bodhi/server/tasks/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
from bodhi.server import buildsys, mail, notifications
from bodhi.server.config import config, validate_path
from bodhi.server.exceptions import BodhiException
from bodhi.server.metadata import UpdateInfoMetadata
from bodhi.server.metadata import (
UpdateInfoMetadata,
FrequencyInfoMetadata
)
from bodhi.server.models import (
Compose,
ComposeState,
Expand Down Expand Up @@ -126,12 +129,12 @@ class ComposerHandler(object):
Things to do while we're waiting on compose:
- Add testing updates to updates-testing digest
- Generate/update updateinfo.xml
- Generate/update updateinfo.xml and frequencyUpdateInfo.json
- Have a coffee. Have 7 coffees.
Once compose is done:
- inject the updateinfo it into the repodata
- inject the updateinfo and frequencyUpdateInfo it into the repodata
- Sanity check the repo
- Flip the symlinks to the new repo
- Cache the new repodata
Expand Down Expand Up @@ -373,7 +376,7 @@ def work(self):

# For 'pending' or 'frozen' branched releases, we only want to perform repo-related
# tasks for testing updates. For stable updates, we should just add the
# dist_tag and do everything else other than composing/updateinfo, since
# dist_tag and do everything else other than composing/updateinfo/frequencyUpdateInfo, since
# the nightly build-branched cron job composes for us.
self.skip_compose = False
if self.compose.request is UpdateRequest.stable \
Expand Down Expand Up @@ -941,7 +944,7 @@ def load_state(self):
log.info('Resuming push without any completed repos')

def _compose_updates(self):
"""Start pungi, generate updateinfo, wait for pungi, and wait for the mirrors."""
"""Start pungi, generate updateinfo and frequencyUpdateInfo, wait for pungi, and wait for the mirrors."""
if not os.path.exists(self.compose_dir):
log.info('Creating %s' % self.compose_dir)
os.makedirs(self.compose_dir)
Expand All @@ -956,10 +959,12 @@ def _compose_updates(self):

if not self.skip_compose and not composedone:
uinfo = self._generate_updateinfo()
finfo = self._generate_frequencyUpdateInfo()

self._wait_for_pungi(pungi_process)

uinfo.insert_updateinfo(self.path)
finfo.insert_frequencyUpdateInfo(self.path)

self._sanity_check_repo()
self._wait_for_repo_signature()
Expand Down Expand Up @@ -1013,6 +1018,19 @@ def _create_pungi_config(self):

self._copy_additional_pungi_files(self._pungi_conf_dir, env)

def _generate_frequencyUpdateInfo(self):
"""
Create the frequencyUpdateInfo.xml file for this repository.
Returns:
bodhi.server.metadata.frequencyUpdateInfoMetadata: The frequencyUpdateInfo model that was created for this
repository.
"""
log.info('Generating frequency updateinfo for %s' % self.compose.release.name)
fuinfo = FrequencyUpdateInfoMetadata(self.compose.release, Update, UpdateStatus)
log.info('FrequencyUpdateinfo generation for %s complete' % self.compose.release.name)
return fuinfo

def _generate_updateinfo(self):
"""
Create the updateinfo.xml file for this repository.
Expand Down
23 changes: 23 additions & 0 deletions docs/user/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ Release notes

.. towncrier release notes start
v7.1.2
======

Released on 2023-04-12.
This is a minor feature release.


Features
^^^^^^^^

* A new metadata file `frequencyupdateinfo.json` will be released as a
part of the composer process which has a more comprehensive list of
updates than updateinfo.xml and is not architecture
specific (:pr:`5172`).

Contributors
^^^^^^^^^^^^

The following developers contributed to this release of Bodhi:

* Rishabh Saini


v7.1.1
======

Expand Down

0 comments on commit 30b1956

Please sign in to comment.