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

Log a warning message when "architecture" label is missing under "Labels" #561

Merged
merged 1 commit into from
Aug 17, 2023
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
9 changes: 8 additions & 1 deletion iib/workers/tasks/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,16 @@ def _build_image(dockerfile_dir: str, dockerfile_name: str, request_id: int, arc
exc_msg=f'Failed to build the container image on the arch {arch}',
)
log.debug('Verifying that %s was built with expected arch %s', destination, arch)
archmap = get_worker_config()['iib_supported_archs']
archmap = worker_config['iib_supported_archs']
destination_arch = get_image_label(local_destination, 'architecture')

if not destination_arch:
log.warn(
'The "architecture" label was not found under "Labels".'
'Skipping the check that confirms if the architecture label was set correctly.'
)
return

if destination_arch not in archmap.values() or destination_arch != archmap.get(arch):
log.warning("Wrong arch created for %s", destination)
raise ExternalServiceError(
Expand Down
7 changes: 6 additions & 1 deletion tests/test_workers/test_tasks/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
@mock.patch('iib.workers.tasks.build.run_cmd')
def test_build_image(mock_run_cmd, mock_get_label, arch):
mock_run_cmd.return_value = None
mock_get_label.return_value = worker_config['iib_supported_archs'][arch]

if arch == 'arm64':
mock_get_label.return_value = ''
else:
mock_get_label.return_value = worker_config['iib_supported_archs'][arch]

build._build_image('/some/dir', 'some.Dockerfile', 3, arch)
destination = f'iib-build:3-{arch}'
local_destination = f'containers-storage:localhost/{destination}'
Expand Down