-
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
RFC: Turn ListImages(filter) into ImageStatus #7336
Conversation
64a8f8a
to
def6ea9
Compare
Cc: @saschagrunert |
(Unit tests fail, I’ll return to this next week.) |
server/image_list.go
Outdated
if status == nil { | ||
return &types.ListImagesResponse{ | ||
Images: []*types.Image{}, | ||
}, nil | ||
} | ||
return &types.ListImagesResponse{ | ||
Images: []*types.Image{ | ||
ConvertImage(status), | ||
}, | ||
}, nil |
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.
we could update ConvertImage() to return an empty list instead of a single element, and then compress all of this to
return &types.ListImagesResponse{
Images: ConvertImage(status),
}, nil
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.
ConvertImage
is also used below, in the primary ListImages
cause, where there are almost always multiple images to collect in Images
.
It might be cleaner to move all of the filterImage.Image != ""
code out of the main body, as a rare case into a separate function out of sight. OTOH “out of sight” might be a bad idea for a corner case — entirely up to CRI-O maintainers.
Or would you prefer
resp := &types.ListImagesResponse{}
if status != nil {
resp.Images = append(resp.Images, ConvertImage(status))
}
return resp, nil
here? I don’t have a preference either way.
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.
as a rare case into a separate function out of sight.
I am open to this. Part of me feels like the code smells a bit that filters never really worked, and we probably should have them working in case kubelet uses them.
ConvertImage is also used below, in the primary ListImages cause, where there are almost always multiple images to collect in Images.
Another option is ConvertImages, which could take the filtered status here and then it could be called below. I am not feeling very convinced in any direction her--all of these are suggestions for consideration
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.
I've thought of it, I think I would prefer:
resp := &types.ListImagesResponse{}
if status != nil {
resp.Images = append(resp.Images, ConvertImage(status))
}
return resp, nil
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.
Done.
if !donePulling { | ||
continue | ||
} | ||
if os.IsNotExist(err) && imageIsBeingPulled(image) { // skip reporting errors if the images haven't finished pulling |
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.
nit: can all functions be defined underneath the functions that call them so we can read top to bottom?
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.
Moved.
9036e95
to
b076b23
Compare
b076b23
to
0702839
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #7336 +/- ##
==========================================
- Coverage 49.23% 49.18% -0.06%
==========================================
Files 136 136
Lines 15693 15672 -21
==========================================
- Hits 7727 7708 -19
+ Misses 7046 7044 -2
Partials 920 920 |
e5aac64
to
47a5bf4
Compare
/retest |
@@ -110,9 +110,6 @@ function teardown() { | |||
imageid=$(crictl images --quiet "$IMAGE:go") | |||
[ "$imageid" != "" ] | |||
|
|||
output=$(crictl images --quiet @"$imageid") |
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.
Note all these changes: the @
id syntax is no longer recognized for a “filter”, with the minimal version of this PR.
Alternatively, the new code could explicitly recognize and support the @
id syntax.
(Or, going the other extreme, all of these test commands could use crictl inspecti
instead.)
... so that we can reuse the "look up a name and get storage data" code in other places, and and eventually so that we can restructure the name lookup logic in some more distant future. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
We will also call the "resolve and get status" code from ListImages. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... now that the more complex control flow is in a helper. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Now that it is a separate function, we can just return early on a match. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
That "filter" was never really much of a filter, we always only got one image. The current logic is, effectively, the only user which accepts that specific form of heuristically-interpreted syntax (because all other non-PauseImage users of internal/storage use ResolveNames), so removing that syntax would consolidate and clarify the semantics of internal/storage names. Kubelet never calls ListImages with a filter AFAIK, so this should make no difference in practice - and it means we get to remove a chunk of code and tests. We do need to update the tests for the @id filter syntax which is no longer recognized, though. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
We have removed the only caller of that code, so start removing it. Should not change behavior (any more). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... now that we are always building a new cache. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Have ListImages itself concern itself with newImageCache and results, instead of doing that inside a helper. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
It's a nice little self-contained predicate, so move it out of line to make the caller a bit more readable. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This makes the handling of svc.imageCache a bit more transparent. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
We know we have a full image ID, so avoid the parsing complexity and c/storage lookup. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
47a5bf4
to
f7d3228
Compare
[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 |
/override ci/prow/ci-e2e |
@saschagrunert: Overrode contexts on behalf of saschagrunert: ci/prow/ci-cgroupv2-e2e-crun, ci/prow/ci-e2e In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Turn
ListImages(filter)
intoImageStatus
. That "filter" was never really much of a filter, we always only got one image.The current logic is, effectively, the only user which accepts that specific form of heuristically-interpreted syntax (because all other non-
PauseImage
users of internal/storage useResolveNames
), so removing that syntax would consolidate and clarify the semantics of internal/storage names.Kubelet never calls
ListImages
with a filter AFAIK, so this should make no difference in practice - and it means we get to remove a chunk of code and tests.Which issue(s) this PR fixes:
None
Special notes for your reviewer:
Do note that this changes how
ListImagesRequest.Filter.Image.Image
is interpreted (to be the same as the same field in of the same struct inImageStatusRequest.Image.Image
), and that might be an incompatible change.It’s quite possible that there are other non-Kubelet users of this API I’m unaware of.
I don’t really need this change to happen for signing — it clarifies how CRI-O interprets names on input, and I think that’s a bit valuable in itself, as well as the code simplification it would eventually allow (ultimately removing
getRef
entirely). But this PR is mostly a side-effect of me clarifying my thinking about which values matter and how they are parsedDoes this PR introduce a user-facing change?