-
Notifications
You must be signed in to change notification settings - Fork 48
Filter Konflux golang-builder search by hermetic flag #3048
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| from artcommonlib.github_auth import get_github_client_for_org | ||
| from artcommonlib.konflux.konflux_build_record import ArtifactType, Engine, KonfluxBuildOutcome, KonfluxBuildRecord | ||
| from artcommonlib.konflux.konflux_db import KonfluxDb | ||
| from artcommonlib.metadata import resolve_network_mode | ||
| from artcommonlib.release_util import isolate_el_version_in_release | ||
| from artcommonlib.rpm_utils import parse_nvr | ||
| from artcommonlib.util import new_roundtrip_yaml_handler | ||
|
|
@@ -573,6 +574,11 @@ async def get_existing_builders_konflux( | |
| """ | ||
| _LOGGER.info(f"Checking if {GOLANG_BUILDER_IMAGE_NAME} builds exist in Konflux for given golang builds") | ||
|
|
||
| el_hermetic_map: dict[int, bool] = {} | ||
| for el_v in el_nvr_map: | ||
| network_mode = self._get_effective_network_mode(el_v, go_version) | ||
| el_hermetic_map[el_v] = network_mode == "hermetic" | ||
|
|
||
| builder_records: dict[int, KonfluxBuildRecord] = {} | ||
| extra_patterns = {'nvr': f"{GOLANG_BUILDER_CVE_COMPONENT}-v{go_version}"} | ||
| build_records = await asyncio.gather( | ||
|
|
@@ -585,6 +591,7 @@ async def get_existing_builders_konflux( | |
| "artifact_type": str(ArtifactType.IMAGE), | ||
| "outcome": str(KonfluxBuildOutcome.SUCCESS), | ||
| "engine": str(Engine.KONFLUX), | ||
| "hermetic": el_hermetic_map[el_v], | ||
| }, | ||
| extra_patterns=extra_patterns, | ||
| limit=1, | ||
|
|
@@ -972,6 +979,38 @@ def _get_doozer_group_and_image(self, el_v, go_version): | |
| group += f'@{self.data_gitref}' | ||
| return group, image_key | ||
|
|
||
| def _get_effective_network_mode(self, el_v: int, go_version: str) -> str: | ||
| if self.network_mode: | ||
| return self.network_mode | ||
|
|
||
| if self.use_new_golang_branch: | ||
| branch = self.GOLANG_DATA_BRANCH | ||
| image_key = self.get_golang_image_key(el_v, go_version) | ||
| else: | ||
| branch = self.get_golang_branch(el_v, go_version) | ||
| image_key = GOLANG_BUILDER_IMAGE_NAME | ||
|
|
||
| ref = self.data_gitref if self.data_gitref else branch | ||
| repo = self._get_upstream_ocp_build_data_repo() | ||
|
|
||
| try: | ||
| image_config = self._load_yaml_from_repo(repo, f"images/{image_key}.yml", ref) | ||
| except Exception as e: | ||
| _LOGGER.warning(f"Failed to load image config for {image_key}: {e}") | ||
| image_config = {} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| image_config_network_mode = (image_config.get("konflux") or {}).get("network_mode") | ||
|
|
||
| try: | ||
| group_config = self._load_yaml_from_repo(repo, "group.yml", ref) | ||
| except Exception as e: | ||
| _LOGGER.warning(f"Failed to load group config from {ref}: {e}") | ||
| group_config = {} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| group_config_network_mode = (group_config.get("konflux") or {}).get("network_mode") | ||
|
|
||
| network_mode = resolve_network_mode(None, image_config_network_mode, group_config_network_mode) | ||
| _LOGGER.info(f"Effective network mode for el{el_v} golang-builder: {network_mode}") | ||
|
Comment on lines
+996
to
+1011
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failing to read build-data currently fails open to non-hermetic matching. At Line 1004 and Line 997, exceptions are converted to 🔧 Suggested fix- try:
- image_config = self._load_yaml_from_repo(repo, f"images/{image_key}.yml", ref)
- except Exception as e:
- _LOGGER.warning(f"Failed to load image config for {image_key}: {e}")
- image_config = {}
+ try:
+ image_config = self._load_yaml_from_repo(repo, f"images/{image_key}.yml", ref)
+ except Exception as e:
+ _LOGGER.exception("Failed to load image config for %s at ref %s", image_key, ref)
+ raise RuntimeError(f"Unable to resolve network mode from images/{image_key}.yml at {ref}") from e
@@
- try:
- group_config = self._load_yaml_from_repo(repo, "group.yml", ref)
- except Exception as e:
- _LOGGER.warning(f"Failed to load group config from {ref}: {e}")
- group_config = {}
+ try:
+ group_config = self._load_yaml_from_repo(repo, "group.yml", ref)
+ except Exception as e:
+ _LOGGER.exception("Failed to load group config at ref %s", ref)
+ raise RuntimeError(f"Unable to resolve network mode from group.yml at {ref}") from e🧰 Tools🪛 Ruff (0.15.15)[warning] 998-998: Do not catch blind exception: (BLE001) [warning] 1005-1005: Do not catch blind exception: (BLE001) 🤖 Prompt for AI Agents |
||
| return network_mode | ||
|
|
||
| def verify_golang_builder_repo(self, el_v, go_version): | ||
| if self.use_new_golang_branch: | ||
| branch = self.GOLANG_DATA_BRANCH | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.