Skip to content

Commit 72dfcb1

Browse files
yashvardhannanavatilipoja
authored andcommitted
Fix Rm request private registry bug
IIB wasn't using the private registry token to pull the index for fbc images in rm requests Refers to CLOUDDST-15975
1 parent 43ad143 commit 72dfcb1

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

iib/workers/tasks/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ def handle_rm_request(
10111011
from_index=from_index_resolved,
10121012
operators=operators,
10131013
binary_image=prebuild_info['binary_image'],
1014+
overwrite_from_index_token=overwrite_from_index_token,
10141015
)
10151016

10161017
else:

iib/workers/tasks/opm_operations.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ def opm_registry_rm_fbc(
550550
from_index: str,
551551
operators: List[str],
552552
binary_image: str,
553+
overwrite_from_index_token: Optional[str] = None,
553554
) -> None:
554555
"""
555556
Remove operator/s from a File Based Catalog index image.
@@ -563,10 +564,17 @@ def opm_registry_rm_fbc(
563564
removed from the output index image.
564565
:param str binary_image: the pull specification of the container image where the opm binary
565566
gets copied from. This should point to a digest or stable tag.
567+
:param str overwrite_from_index_token: the token used for overwriting the input
568+
``from_index`` image. This is required to use ``overwrite_from_index``.
569+
The format of the token must be in the format "user:password".
566570
"""
571+
from iib.workers.tasks.utils import set_registry_token
572+
567573
log.info('Removing %s from a FBC Image %s', operators, from_index)
568574
log.info('Using the existing database from %s', from_index)
569-
index_db_path = get_hidden_index_database(from_index=from_index, base_dir=base_dir)
575+
576+
with set_registry_token(overwrite_from_index_token, from_index, append=True):
577+
index_db_path = get_hidden_index_database(from_index=from_index, base_dir=base_dir)
570578

571579
_opm_registry_rm(index_db_path, operators, base_dir)
572580
fbc_dir = opm_migrate(index_db=index_db_path, base_dir=base_dir)

tests/test_workers/test_tasks/test_opm_operations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ def test_opm_registry_add_fbc(
349349
@mock.patch('iib.workers.tasks.opm_operations.opm_migrate')
350350
@mock.patch('iib.workers.tasks.opm_operations._opm_registry_rm')
351351
@mock.patch('iib.workers.tasks.opm_operations.get_hidden_index_database')
352+
@mock.patch('iib.workers.tasks.utils.set_registry_token')
352353
def test_opm_registry_rm_fbc(
354+
mock_srt,
353355
mock_ghid,
354356
mock_orr,
355357
mock_om,
@@ -364,10 +366,7 @@ def test_opm_registry_rm_fbc(
364366
mock_om.return_value = fbc_dir
365367

366368
opm_operations.opm_registry_rm_fbc(
367-
tmpdir,
368-
from_index,
369-
operators,
370-
'some:image',
369+
tmpdir, from_index, operators, 'some:image', overwrite_from_index_token='some_token'
371370
)
372371

373372
mock_orr.assert_called_once_with(
@@ -376,6 +375,7 @@ def test_opm_registry_rm_fbc(
376375
tmpdir,
377376
)
378377

378+
mock_srt.assert_called_once_with('some_token', 'some_index:latest', append=True)
379379
mock_om.assert_called_once_with(index_db=index_db_file, base_dir=tmpdir)
380380
mock_ogd.assert_called_once_with(
381381
fbc_dir=fbc_dir,

0 commit comments

Comments
 (0)