-
Notifications
You must be signed in to change notification settings - Fork 813
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
[docker] fix image name when using sha256 for specs #3326
Conversation
Some orchestrators init containers with the image sha256 instead of the image name, and docker inspect returns this. If it's the case, make a docker image inspect call to get the image name and cache the result
60bb7fe
to
e0655cf
Compare
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.
minor comment on exception handling, otherwise LGTM
utils/dockerutil.py
Outdated
name = image_spec.get('RepoTags')[0] | ||
self._image_sha_to_name_mapping[image] = name | ||
return name | ||
except Exception: |
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.
This exception handling is risky. Either we expect a precise error and we should only catch that, or we catch everything with Exception
but log something. Otherwise we open the door to sneaky bugs.
utils/dockerutil.py
Outdated
name = name.split('@')[0] # Last resort, we get the name with no tag | ||
self._image_sha_to_name_mapping[image] = name | ||
return name | ||
except Exception: |
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.
diitto
utils/dockerutil.py
Outdated
return name | ||
except Exception: | ||
pass | ||
except Exception: |
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.
ditto
0c7734a
to
48d774e
Compare
What does this PR do?
Some orchestrators init containers with the image sha256 instead of the
image name, and docker inspect returns this. If it's the case, make
a docker image inspect call to get the image name and cache the result
No cache invalidation is coded as image deletion don't trigger events and obsolete image count should be significant on a typical host
Motivation
Compatibility with k8s 1.6 & Nomad
Testing Guidelines
Added unit test for the three cases we support