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

use registry token for inspecting image from private repo [CLOUDDST-10044] #312

Merged
merged 1 commit into from
Oct 25, 2021
Merged
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
18 changes: 10 additions & 8 deletions iib/workers/tasks/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,10 +729,11 @@ def handle_add_request(
present_bundles_pull_spec = []
with tempfile.TemporaryDirectory(prefix='iib-') as temp_dir:
if from_index:
if is_image_dc(from_index):
err_msg = 'Declarative config image type is not supported yet.'
log.error(err_msg)
raise IIBError(err_msg)
with set_registry_token(overwrite_from_index_token, from_index_resolved):
if is_image_dc(from_index_resolved):
err_msg = 'Declarative config image type is not supported yet.'
log.error(err_msg)
raise IIBError(err_msg)

msg = 'Checking if bundles are already present in index image'
log.info(msg)
Expand Down Expand Up @@ -892,10 +893,11 @@ def handle_rm_request(
from_index_resolved = prebuild_info['from_index_resolved']

with tempfile.TemporaryDirectory(prefix='iib-') as temp_dir:
if is_image_dc(from_index):
err_msg = 'Declarative config image type is not supported yet.'
log.error(err_msg)
raise IIBError(err_msg)
with set_registry_token(overwrite_from_index_token, from_index_resolved):
if is_image_dc(from_index_resolved):
err_msg = 'Declarative config image type is not supported yet.'
log.error(err_msg)
raise IIBError(err_msg)

_opm_index_rm(
temp_dir,
Expand Down
2 changes: 1 addition & 1 deletion iib/workers/tasks/build_create_empty_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def handle_create_empty_index_request(

_update_index_image_build_state(request_id, prebuild_info)
with tempfile.TemporaryDirectory(prefix='iib-') as temp_dir:
if is_image_dc(from_index):
if is_image_dc(from_index_resolved):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For create-empty-index and merge-index endpoints, we don't have any tokens right? Do we have any use case where these endpoints are used with a from_index from a private registry?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree for create-empty-index. See my comment on merge-index.

err_msg = 'Declarative config image type is not supported yet.'
log.error(err_msg)
raise IIBError(err_msg)
Expand Down
2 changes: 1 addition & 1 deletion iib/workers/tasks/build_merge_index_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def handle_merge_request(
target_index_resolved = prebuild_info['target_index_resolved']

with tempfile.TemporaryDirectory(prefix='iib-') as temp_dir:
if is_image_dc(source_from_index):
if is_image_dc(source_from_index_resolved):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is overwrite_target_index_token but that doesn't seem to be used when inspecting the source index image. I think your reasoning to not set the registry secret here is correct. There would be additional changes to support that use case.

err_msg = 'Declarative config image type is not supported yet.'
log.error(err_msg)
raise IIBError(err_msg)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_workers/test_tasks/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def side_effect(_, temp_dir, *args, **kwargs):
else:
assert not mock_oia.call_args[0][5]

mock_srt.assert_called_once()
mock_srt.call_count == 2

if deprecate_bundles:
# Take into account the temporarily created index image
Expand Down