Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get all arches rhcos pullspec from rhcos version #1133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions artcommon/artcommonlib/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# constants shared across multiple sub-projects

RHCOS_RELEASES_BASE_URL = "https://releases-rhcos-art.apps.ocp-virt.prod.psi.redhat.com/storage/releases"
RHCOS_RELEASES_STREAM_URL = "https://releases-rhcos-art.apps.ocp-virt.prod.psi.redhat.com/storage/prod/streams"
BREW_HUB = "https://brewhub.engineering.redhat.com/brewhub"
BREW_DOWNLOAD_URL = "https://download.devel.redhat.com/brewroot"
RELEASE_SCHEDULES = "https://pp.engineering.redhat.com/api/v7/releases"
Expand Down
28 changes: 20 additions & 8 deletions doozer/doozerlib/cli/release_gen_assembly.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio

import requests
import click
import json
import re
Expand All @@ -12,6 +12,7 @@
from artcommonlib.assembly import AssemblyTypes
from artcommonlib.model import Model
from artcommonlib.release_util import isolate_el_version_in_release
from artcommonlib.constants import RHCOS_RELEASES_STREAM_URL
from doozerlib import util
from doozerlib.cli import cli, pass_runtime, click_coroutine
from doozerlib import brew
Expand Down Expand Up @@ -183,10 +184,6 @@ def _validate_params(self):
if not self.nightlies and not self.standards:
self._exit_with_error('At least one release (--nightly or --standard) must be specified')

if len(self.runtime.arches) != len(self.nightlies) + len(self.standards) and not self.custom:
self._exit_with_error(f'Expected at least {len(self.runtime.arches)} nightlies; '
f'one for each group arch: {self.runtime.arches}')

if self.auto_previous and self.previous_list:
self._exit_with_error('Cannot use `--previous` and `--auto-previous` at the same time.')

Expand Down Expand Up @@ -244,6 +241,10 @@ async def _process_release(self, brew_cpu_arch, pullspec, rhcos_tag_names):
payload_tag_name = component_tag.name # e.g. "aws-ebs-csi-driver"
payload_tag_pullspec = component_tag['from'].name # quay pullspec

if not release_info["displayVersions"]["machine-os"]["Version"]:
self._exit_with_error(f'Could not find machine-os version in release: {pullspec}')
# get rhcos version eg. 417.94.202410250757-0
self.rhcos_version = release_info["displayVersions"]["machine-os"]["Version"]
if payload_tag_name in rhcos_tag_names:
self.rhcos_by_tag.setdefault(payload_tag_name, {})[brew_cpu_arch] = payload_tag_pullspec
continue
Expand Down Expand Up @@ -395,7 +396,9 @@ def _collect_outliers(self):
def _get_rhcos_container(self):
# We should have found an RHCOS container for each architecture in the group for a standard assembly
self.primary_rhcos_tag = rhcos.get_primary_container_name(self.runtime)

major_minor = self.runtime.get_minor_version()
rhcos_el_major = self.runtime.group_config.vars.RHCOS_EL_MAJOR
rhcos_el_minor = self.runtime.group_config.vars.RHCOS_EL_MINOR
for arch in self.runtime.arches:
if arch in self.rhcos_by_tag[self.primary_rhcos_tag]:
continue
Expand All @@ -406,8 +409,17 @@ def _get_rhcos_container(self):
self.logger.info('Did not find RHCOS "%s" image for active group architecture: %s; '
'ignoring for custom assembly type.', self.primary_rhcos_tag, arch)
else:
self._exit_with_error(
f'Did not find RHCOS "{self.primary_rhcos_tag}" image for active group architecture: {arch}')
# get rhcos pullspecs for this arch from rhcos version
if rhcos_el_major > 8:
rhcos_build_url = f"{RHCOS_RELEASES_STREAM_URL}/{major_minor}-{rhcos_el_major}.{rhcos_el_minor}/builds/{self.rhcos_version}/{arch}/meta.json"
else:
rhcos_build_url = f"{RHCOS_RELEASES_STREAM_URL}/{major_minor}/builds/{self.rhcos_version}/{arch}/meta.json"
rhcos_meta_json = requests.get(rhcos_build_url).json()
for tag in rhcos.get_container_configs(self.runtime):
if tag.build_metadata_key not in rhcos_meta_json:
self._exit_with_error(f'Did not find RHCOS "{tag.name}" image for active group architecture: {arch}')
rhcos_image = rhcos_meta_json[tag.build_metadata_key]
self.rhcos_by_tag[tag.name][arch] = f"{rhcos_image['image']}@{rhcos_image['digest']}"

def _select_rpms(self):
"""
Expand Down
15 changes: 0 additions & 15 deletions doozer/tests/cli/test_gen_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,6 @@ def test_no_nightlies_nor_standards(self):
gacli.should_receive('_exit_with_error').once()
gacli._validate_params()

@patch('doozerlib.cli.release_gen_assembly.GenAssemblyCli._exit_with_error', MagicMock(return_value=None))
def test_arches_nightlies_mismatchs(self):
"""
The command expects one nightly/standard for each group arch,
and should raise an error otherwise
"""

# 2 group arches, 1 nightly
gacli = flexmock(GenAssemblyCli(
runtime=MagicMock(assembly='stream', arches=['amd64', 's390x']),
nightlies=['4.13.0-0.nightly-2022-12-01-153811']
))
gacli.should_receive('_exit_with_error').once()
gacli._validate_params()

@patch('doozerlib.cli.release_gen_assembly.GenAssemblyCli._exit_with_error', MagicMock(return_value=None))
def test_previous_and_auto_previous(self):
"""
Expand Down