-
Notifications
You must be signed in to change notification settings - Fork 1
SS-1076 improve image pull error #368
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
Conversation
Wrapp image validation with django waffle Signed-off-by: Nikita Churikov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds validation of Docker image CPU architectures and supporting utilities.
- Introduces
DockerHubAuthenticator
andGHCRAuthenticator
for registry token retrieval. - Implements
get_manifest_list
,get_config_blob
, andget_image_architecture
to fetch and parse image architectures. - Integrates a
docker_image_architecture_validator
waffle switch intovalidate_ghcr_image
andvalidate_docker_image
to enforceamd64
images.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
studio/settings.py | Added new env vars for Docker Hub and GHCR authentication |
apps/validators/container_images.py | New registry auth classes and manifest/config-fetching utilities |
apps/helpers.py | Wired image-architecture checks behind feature flag in validators |
Comments suppressed due to low confidence (1)
apps/validators/container_images.py:135
- [nitpick] The parameter name
refence
is misspelled; consider renaming it toreference
for clarity and consistency.
def get_image_architecture(
else: | ||
logger.error("Unknown or unsupported manifest format!") | ||
|
||
return architectures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_image_architecture
can return None
on unsupported manifests, but callers assume a list. Ensure it always returns a list (possibly empty) or raise an exception to prevent runtime errors.
return architectures | |
return architectures or [] |
Copilot uses AI. Check for mistakes.
- Improved documentation for authentication classes and methods. - Added support for anonymous access in DockerHubAuthenticator (Mostly for GHCR). - Renamed `get_image_architecture` to `get_image_architectures` for clarity. - Introduced tests for GHCR and Docker Hub architecture validation. Signed-off-by: Nikita Churikov <[email protected]>
Co-authored-by: Copilot <[email protected]>
@churnikov did you choose to create the flag manually? Here's where the Depictio one gets created. |
Thanks, good idea, will do that! |
Signed-off-by: Nikita Churikov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not run this locally but LGTM.
apps/validators/container_images.py
Outdated
|
||
|
||
def get_image_architectures( | ||
*, auth: BaseRegistryAuth, repo: str, refence: str, registry: str = "registry-1.docker.io" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is refence
missing the r on purpose? haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops:))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to update .env.template
to include those variables there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, will do that:)
Co-authored-by: Jana Awada <[email protected]>
…env.template for Docker Hub credentials Signed-off-by: Nikita Churikov <[email protected]>
Link to related charts pull request ScilifelabDataCentre/serve-charts#101
TODO:
https://scilifelab.atlassian.net/wiki/spaces/AIportal/pages/3697836225/On+pulling+users+images+on+serve#Validating-incoming-images
This pull request introduces a feature to validate Docker image architectures for both Docker Hub and GitHub Container Registry (GHCR). The changes include adding new utility functions, validators, and settings to ensure Docker images are built for the correct CPU architecture (
amd64
). It also integrates a feature flag to toggle this validation.Docker image architecture validation:
amd64
) invalidate_ghcr_image
andvalidate_docker_image
functions. This validation is controlled by thedocker_image_architecture_validator
feature flag using thewaffle
library. [1] [2]New utilities for Docker and GHCR integration:
DockerHubAuthenticator
andGHCRAuthenticator
classes for handling authentication with Docker Hub and GHCR, respectively. These classes retrieve Bearer tokens for API requests.get_manifest_list
,get_config_blob
, andget_image_architecture
to fetch and parse image manifests and configurations to determine supported architectures.Configuration updates:
DOCKER_HUB_TOKEN
,DOCKER_HUB_USERNAME
,GITHUB_API_USERNAME
) tostudio/settings.py
for authentication with Docker Hub and GHCR.Checklist
If you're unsure about any of the items below, don't hesitate to ask. We're here to help!
This is simply a reminder of what we are going to look for before merging your code.
Further comments
Anything else you think we should know before merging your code!