-
Notifications
You must be signed in to change notification settings - Fork 1k
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 strongly encapsulated types with strict semantics for RemoveImage #7375
Conversation
For now, there are no users; that will change immediately. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
We will push the heuristics to the callers to make the heuristics explicit, very loud to readers, and most importantly to give callers well-typed data instead of ambiguous strings. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Stop using ResolveNames, push the heuristic to the caller. This violates future API rules, that will be fixed momentarily. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... to use a well-typed value, _and_ to more strictly differentiate between the "delete" and "untag" behaviors. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
It counts the tags which we are _not_ going to remove. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... then simplify the code to remove unreachable paths, simplify tests to remove unreachable error cases. All the code and test removals are enabled by having strong guarantees about the nature of the accepted input. This removes a suspicious "HasPrefix" ambiguity between image IDs and names; due to the restrictions of what strings ResolveNames actually accepts, the problematic case was not actually reachable. So, this should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
7b8a99f
to
2fd4073
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #7375 +/- ##
==========================================
+ Coverage 49.23% 49.33% +0.10%
==========================================
Files 136 138 +2
Lines 15678 15739 +61
==========================================
+ Hits 7719 7765 +46
- Misses 7039 7051 +12
- Partials 920 923 +3 |
/retest |
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.
Thank you!
// Actually Kubelet is only ever calling this with full image IDs. | ||
// So we don't really need to accept ID prefixes nor short names; | ||
// or is there another user?! |
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.
cri-tools does an ImageStatus
before removing the specified image, which leads into a ResolveNames call. So I guess we're fine.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mtrmac, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Split
ImageServer.ResolveNames
into two well-typed parsersWe will push the heuristics to the callers to make the heuristics explicit, very loud to readers, and most importantly to give callers well-typed data instead of ambiguous strings.
This introduces
storage.StorageImageID
andstorage.RegistryImageReference
types, with the intent that users dealing withinternal/storage
should only use these strongly-typed values, not strings, for image identification/referencing.Which issue(s) this PR fixes:
None
Special notes for your reviewer:
See individual commit messages for details. Overall, this should not actually change behavior of
RemoveImage
.This is the beginning of the payoff of the recent API/semantics PRs. I have two similar directly related items queued to follow:
ImageServer.ImageStatus
to accept well-typed input (StorageImageID
orRegistryImageReference
)PrepareImage
/PullImage
to acceptRegistryImageReference
and that will eliminate (or push to callers) all the heuristic “does it parse this way, that way, another way?” code paths in
internal/storage
, allowing the pull code to precisely reason about the names and to manipulate them with confidence.This PR is filed separately (leaving the rules-violating
ResolveNames
in place) to get the review of the API types and general approach quickly, to surface concerns, if any, earlier.Cc: @saschagrunert
Does this PR introduce a user-facing change?