Skip to content

Commit f08be8f

Browse files
committed
Only allow lesser arch builds for certain OPM versions
This commit introduces a new configuration variable named `IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS` which, when set, defines a list of OPM versions that are allowed to proceed building index images for lesser arches than the defaults, using the supported values from the configured binary image. It also updates the existing unit-tests Refers to CLOUDDST-28638 Signed-off-by: Jonathan Gangi <jgangi@redhat.com> Assisted-by: Cursor/Gemini
1 parent dd3b327 commit f08be8f

14 files changed

Lines changed: 89 additions & 24 deletions

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ The custom configuration options for the REST API are listed below:
199199
to another dictionary mapping ocp_version label to a binary image pull specification.
200200
This is useful in setting up customized binary image for different index image images thus
201201
reducing complexity for the end user. This defaults to `{}`.
202+
* `IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS` - an optional `list(<str>)` to specify the OPM
203+
versions which are allowed to build index images with lesser arches than the configured
204+
on `iib_supported_archs`. When a certain version is set it will allow building only to the
205+
available arches supported by the binary image.
202206
* `IIB_INDEX_TO_GITLAB_PUSH_MAP` - the mapping, `dict(<str>:<str>)`, to specify which index
203207
images (keys) which should have its catalog pushed into a GitLab repository (value). This defaults to {}.
204208
* `IIB_GRAPH_MODE_INDEX_ALLOW_LIST` - the list of index image pull specs on which using the

iib/web/api_v1.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def _get_rm_args(
106106
flask.current_app.config['IIB_BINARY_IMAGE_CONFIG'],
107107
payload.get('build_tags', []),
108108
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
109+
flask.current_app.config['IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS'],
109110
]
110111

111112

@@ -140,6 +141,7 @@ def _get_add_args(
140141
payload.get('graph_update_mode'),
141142
payload.get('check_related_images', False),
142143
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
144+
flask.current_app.config['IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS'],
143145
]
144146

145147

@@ -758,6 +760,7 @@ def patch_request(request_id: int) -> Tuple[flask.Response, int]:
758760
'source_from_index_resolved',
759761
'target_index_resolved',
760762
'index_to_gitlab_push_map',
763+
'binary_image_less_arches_allowed_versions',
761764
)
762765
start_time = time.time()
763766
for key in image_keys:
@@ -900,6 +903,7 @@ def regenerate_bundle() -> Tuple[flask.Response, int]:
900903
payload.get('bundle_replacements', dict()),
901904
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
902905
flask.current_app.config['IIB_REGENERATE_BUNDLE_REPO_KEY'],
906+
flask.current_app.config['IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS'],
903907
]
904908
safe_args = _get_safe_args(args, payload)
905909

@@ -970,6 +974,7 @@ def regenerate_bundle_batch() -> Tuple[flask.Response, int]:
970974
build_request.get('bundle_replacements', dict()),
971975
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
972976
flask.current_app.config['IIB_REGENERATE_BUNDLE_REPO_KEY'],
977+
flask.current_app.config['IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS'],
973978
]
974979
safe_args = _get_safe_args(args, build_request)
975980
error_callback = failed_request_callback.s(request.id)
@@ -1176,6 +1181,7 @@ def create_empty_index() -> Tuple[flask.Response, int]:
11761181
payload.get('labels'),
11771182
flask.current_app.config['IIB_BINARY_IMAGE_CONFIG'],
11781183
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
1184+
flask.current_app.config['IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS'],
11791185
]
11801186
safe_args = _get_safe_args(args, payload)
11811187
error_callback = failed_request_callback.s(request.id)
@@ -1337,6 +1343,7 @@ def fbc_operations() -> Tuple[flask.Response, int]:
13371343
flask.current_app.config['IIB_BINARY_IMAGE_CONFIG'],
13381344
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
13391345
request._used_fbc_fragment, # Pass the legacy flag to the worker
1346+
flask.current_app.config['IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS'],
13401347
]
13411348
safe_args = _get_safe_args(args, payload)
13421349
error_callback = failed_request_callback.s(request.id)

iib/web/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Config(object):
2020
IIB_ADDITIONAL_LOGGERS: List[str] = []
2121
IIB_AWS_S3_BUCKET_NAME: Optional[str] = None
2222
IIB_BINARY_IMAGE_CONFIG: Dict[str, Dict[str, str]] = {}
23+
IIB_BINARY_IMAGE_LESS_ARCHES_ALLOWED_VERSIONS: List[str] = []
2324
IIB_INDEX_TO_GITLAB_PUSH_MAP: Dict[str, str] = {}
2425
IIB_REGENERATE_BUNDLE_REPO_KEY: str = 'regenerate-bundle'
2526
IIB_GRAPH_MODE_INDEX_ALLOW_LIST: List[str] = []

iib/workers/tasks/build_add_deprecations.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import logging
55
import tempfile
6-
from typing import Dict, Optional, Set
6+
from typing import Dict, List, Optional, Set
77

88
from iib.common.common_utils import get_binary_versions
99
from iib.common.tracing import instrument_tracing
@@ -55,6 +55,7 @@ def handle_add_deprecations_request(
5555
build_tags: Optional[Set[str]] = None,
5656
binary_image_config: Optional[Dict[str, Dict[str, str]]] = None,
5757
overwrite_from_index_token: Optional[str] = None,
58+
binary_image_less_arches_allowed_versions: Optional[List[str]] = None,
5859
) -> None:
5960
"""
6061
Add a deprecation schema to index image.
@@ -74,6 +75,8 @@ def handle_add_deprecations_request(
7475
:param list build_tags: List of tags which will be applied to intermediate index images.
7576
:param dict binary_image_config: the dict of config required to identify the appropriate
7677
``binary_image`` to use.
78+
:param list binary_image_less_arches_allowed_versions: list of versions of the binary image
79+
that are allowed to build for less arches. Defaults to ``None``.
7780
"""
7881
_cleanup()
7982
set_request_state(request_id, 'in_progress', 'Resolving the index images')
@@ -87,6 +90,7 @@ def handle_add_deprecations_request(
8790
operator_package=operator_package,
8891
deprecation_schema=deprecation_schema,
8992
binary_image_config=binary_image_config,
93+
binary_image_less_arches_allowed_versions=binary_image_less_arches_allowed_versions,
9094
),
9195
)
9296

iib/workers/tasks/build_containerized_add.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def handle_containerized_add_request(
7777
graph_update_mode: Optional[str] = None,
7878
check_related_images: bool = False,
7979
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
80+
binary_image_less_arches_allowed_versions: Optional[List[str]] = None,
8081
username: Optional[str] = None,
8182
) -> None:
8283
"""
@@ -108,6 +109,8 @@ def handle_containerized_add_request(
108109
in the index.
109110
:param dict index_to_gitlab_push_map: the dict mapping index images (keys) to GitLab repos
110111
(values) in order to push their catalogs into GitLab.
112+
:param list binary_image_less_arches_allowed_versions: list of versions of the binary image
113+
that are allowed to build for less arches. Defaults to ``None``.
111114
:raises IIBError: if the index image build fails.
112115
"""
113116
reset_docker_config()
@@ -134,6 +137,7 @@ def handle_containerized_add_request(
134137
bundles=bundles,
135138
distribution_scope=distribution_scope,
136139
binary_image_config=binary_image_config,
140+
binary_image_less_arches_allowed_versions=binary_image_less_arches_allowed_versions,
137141
),
138142
)
139143
from_index_resolved = prebuild_info['from_index_resolved']

iib/workers/tasks/build_containerized_create_empty_index.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import shutil
55
import tempfile
66
from pathlib import Path
7-
from typing import Dict, Optional
7+
from typing import Dict, Optional, List
88

99
from iib.common.common_utils import get_binary_versions
1010
from iib.common.tracing import instrument_tracing
@@ -122,6 +122,7 @@ def handle_containerized_create_empty_index_request(
122122
labels: Optional[Dict[str, str]] = None,
123123
binary_image_config: Optional[Dict[str, Dict[str, str]]] = None,
124124
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
125+
binary_image_less_arches_allowed_versions: Optional[List[str]] = None,
125126
) -> None:
126127
"""
127128
Coordinate the work needed to create empty index using containerized workflow.
@@ -151,6 +152,7 @@ def handle_containerized_create_empty_index_request(
151152
_binary_image=binary_image,
152153
from_index=from_index,
153154
binary_image_config=binary_image_config,
155+
binary_image_less_arches_allowed_versions=binary_image_less_arches_allowed_versions,
154156
),
155157
)
156158

iib/workers/tasks/build_containerized_fbc_operations.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def handle_containerized_fbc_operation_request(
6060
binary_image_config: Optional[Dict[str, Dict[str, str]]] = None,
6161
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
6262
used_fbc_fragment: bool = False,
63+
binary_image_less_arches_allowed_versions: Optional[List[str]] = None,
6364
) -> None:
6465
"""
6566
Add fbc fragments to an fbc index image.
@@ -77,6 +78,8 @@ def handle_containerized_fbc_operation_request(
7778
(values) in order to push their catalogs into GitLab.
7879
:param bool used_fbc_fragment: flag indicating if the original request used fbc_fragment
7980
(single) instead of fbc_fragments (array). Used for backward compatibility.
81+
:param list binary_image_less_arches_allowed_versions: list of versions of the binary image
82+
that are allowed to build for less arches. Defaults to ``None``.
8083
"""
8184
reset_docker_config()
8285
set_request_state(request_id, 'in_progress', 'Resolving the fbc fragments')
@@ -98,6 +101,7 @@ def handle_containerized_fbc_operation_request(
98101
fbc_fragments=fbc_fragments,
99102
distribution_scope=distribution_scope,
100103
binary_image_config=binary_image_config,
104+
binary_image_less_arches_allowed_versions=binary_image_less_arches_allowed_versions,
101105
),
102106
)
103107

iib/workers/tasks/build_containerized_merge.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def handle_containerized_merge_request(
7575
graph_update_mode: Optional[str] = None,
7676
ignore_bundle_ocp_version: Optional[bool] = False,
7777
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
78+
binary_image_less_arches_allowed_versions: Optional[List[str]] = None,
7879
parallel_threads: int = 5,
7980
) -> None:
8081
"""
@@ -121,6 +122,7 @@ def handle_containerized_merge_request(
121122
target_index=target_index,
122123
distribution_scope=distribution_scope,
123124
binary_image_config=binary_image_config,
125+
binary_image_less_arches_allowed_versions=binary_image_less_arches_allowed_versions,
124126
),
125127
)
126128

iib/workers/tasks/build_containerized_regenerate_bundle.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import tempfile
55
import textwrap
66
from pathlib import Path
7-
from typing import Any, Dict, Optional
7+
from typing import Any, Dict, List, Optional
88

99
import ruamel.yaml
1010

@@ -68,6 +68,7 @@ def handle_containerized_regenerate_bundle_request(
6868
registry_auths: Optional[Dict[str, Any]] = None,
6969
bundle_replacements: Optional[Dict[str, str]] = None,
7070
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
71+
binary_image_less_arches_allowed_versions: Optional[List[str]] = None,
7172
regenerate_bundle_repo_key: str = 'regenerate-bundle',
7273
) -> None:
7374
"""
@@ -84,6 +85,8 @@ def handle_containerized_regenerate_bundle_request(
8485
(values) in order to push their catalogs into GitLab.
8586
:param str regenerate_bundle_repo_key: the key to look up the actual repo URL from
8687
index_to_gitlab_push_map, defaults to ``regenerate-bundle``.
88+
:param list binary_image_less_arches_allowed_versions: list of versions of the binary image
89+
that are allowed to build for less arches. Defaults to ``None``.
8790
:raises IIBError: if the regenerate bundle image build fails.
8891
"""
8992
bundle_replacements = bundle_replacements or {}

iib/workers/tasks/build_containerized_rm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def handle_containerized_rm_request(
6363
binary_image_config: Optional[Dict[str, Dict[str, str]]] = None,
6464
build_tags: Optional[List[str]] = None,
6565
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
66+
binary_image_less_arches_allowed_versions: Optional[List[str]] = None,
6667
) -> None:
6768
"""
6869
Coordinate the work needed to remove the input operators using containerized workflow.
@@ -90,6 +91,8 @@ def handle_containerized_rm_request(
9091
:param list build_tags: List of tags which will be applied to intermediate index images.
9192
:param dict index_to_gitlab_push_map: the dict mapping index images (keys) to GitLab repos
9293
(values) in order to remove their catalogs from GitLab.
94+
:param list binary_image_less_arches_allowed_versions: list of versions of the binary image
95+
that are allowed to build for less arches. Defaults to ``None``.
9396
:raises IIBError: if the index image build fails.
9497
"""
9598
reset_docker_config()
@@ -105,6 +108,7 @@ def handle_containerized_rm_request(
105108
add_arches=add_arches,
106109
distribution_scope=distribution_scope,
107110
binary_image_config=binary_image_config,
111+
binary_image_less_arches_allowed_versions=binary_image_less_arches_allowed_versions,
108112
),
109113
)
110114

0 commit comments

Comments
 (0)