-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix searching on non-searchable image registries #1821
base: main
Are you sure you want to change the base?
Conversation
I already had this container on my system: I tried a few example ones, but perhaps they're not actually there... Then I tried a container that GitHub talked about called "Super Linter", which has this as a container URI: If you add the URI without the @..., it seems like it'd work: But you have to specifically click on the item in the dropdown. (Is that intended?) If you change the focus, the entry goes blank. Also, if you try to edit the text (like if you have a typo, like copying the URI incorrectly), the entry also goes blank. However, it does seem to work if you click on the entry, so that's great! I see a related discussion at https://github.com/orgs/community/discussions/26279 which uses tags/list but it seems things need a token, so I guess that won't work for us. |
9934989
to
c0b19df
Compare
c0b19df
to
bfa093e
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.
Cheers! Please update the commit message to explain the change more verbosely (use case, reference to https://issues.redhat.com/browse/COCKPIT-1148 and the correspondig upstream and RHEL issues).
f916975
to
5a5fe4a
Compare
fedora 41 fails because of this:
I checked f40 and it gives a warning rather than "not implemented" error. Both are on version 5.2.0 idk what this means/how to fix for now, will look into it |
5a5fe4a
to
24d666e
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.
Thanks for the fixes! Next round.
This comment was marked as resolved.
This comment was marked as resolved.
It's getting there! I found two interaction problems so far:
I was testing with |
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.
(fix the issues with the spaces and hitting enter, as pointed out above; thanks!)
searches.push(...utils.fallbackRegistries.map(registry => | ||
this.activeConnection.call({ | ||
method: "GET", | ||
path: client.VERSION + "libpod/images/search", | ||
body: "", | ||
params: { | ||
term: registry + "/" + value |
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 is a significant piece of code, please add a test for fallback registries.
# Searching for container by prefix fails | ||
b.set_input_text("#create-image-image-select-typeahead", "localhost:80/my-busy") | ||
b.wait_text("button.pf-v5-c-select__menu-item.pf-m-disabled", "No images found") | ||
b.wait_in_text(".pf-v5-c-alert.pf-m-danger", "couldn't search registry") |
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 shouldn't be "danger", but "info" or "default". (It needs to be changed in the code, but it's visible here)
b.wait_text("button.pf-v5-c-select__menu-item.pf-m-disabled", "No images found") | ||
b.wait_in_text(".pf-v5-c-alert.pf-m-danger", "couldn't search registry") | ||
|
||
# Searching for full url with tag finds the image |
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.
s/url with //
@tomasmatus thanks! I cleaned up outdated review threads and comments to make the remaining stuff easier to see. There's a few small things to fix; if you really don't want to rewrite/simplify the search result loop (which is so hard to read and so easy to get wrong!), perhaps @jelly can help with that, or also me when I'm back from PTO. I also wouldn't veto landing it as-is and cleaning up later, if @jelly is ok with it. But in three weeks nobody of us will be able to follow that logic.. |
yes, I agree with this, let's not |
fixes: cockpit-project#1220 Add support to pull images from registries which do not support search API.
Utilizes `podman manifest inspect` in the background and when manifest is found for the user input image url it is possible to select this image from the search dropdown. Normal `podman search` queries are disabled when image tag is specified as the search API doesn't seem to support searching for specific tags.
a1ceaef
to
839df1d
Compare
@martinpitt if you'd like to have a look it is this Select that is misbehaving. What happens is when you type something in and press enter the input bar is cleared rather than preserve the value. It is also cleared once the input loses focus. This shouldn't be happening as the |
I can reproduce the issue on main. AFAICS the only sensible thing is to ignore the Enter key completely then -- if you type a random string into the image bar, it cannot be "accepted" as a valid value (which is usually the meaning of "Enter"). You must actually select a valid image for the dialog to make sense. Clearing an invalid value on focus change also makes sense IMHO. However, I do see how this would collide with the workflow of this PR -- it'd still force you to actually click on the search result instead of just copy&pasting an image name and doing nothing else. Did I get this right? The demo on the PF docs (v4, as that's the deprecated one) behaves in the above way: "Enter" is a no-op, and changing focus clears the input value. This doesn't do any special keyboard input tricks. My hunch is that it's the |
Pressing "Enter" in the dialog on any active form element (such as the search input or the checkboxes) previously bubbled up to the Form, which then activated the first popover help. This is unexpected and very irritating especially when using the search input. Just ignore the Enter key to fix that, similar to what the image search modal already does. See cockpit-project#1821 (comment)
@tomasmatus Fixed in #1861 . This is independent from this PR. |
const changeDialogError = (reason) => { | ||
dialogError = _("Failed to search for new images"); | ||
// TODO: add registry context, podman does not include it in the reply. | ||
dialogErrorDetail = reason ? cockpit.format(_("Failed to search for images: $0"), reason.message) : _("Failed to search for images."); |
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 added line is not executed by any test.
if (!RE_CONTAINER_TAG.test(value)) { | ||
// If there are registries configured search in them, or if a user searches for `docker.io/cockpit` let | ||
// podman search in the user specified registry. | ||
if (Object.keys(this.props.podmanInfo.registries).length !== 0 || value.includes('/')) { |
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 added line is not executed by any test.
searches.push(...utils.fallbackRegistries.map(registry => | ||
this.activeConnection.call({ | ||
method: "GET", | ||
path: client.VERSION + "libpod/images/search", | ||
body: "", | ||
params: { | ||
term: registry + "/" + value |
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.
These 7 added lines are not executed by any test.
dialogError = _("Failed to search for new images"); | ||
// TODO: add registry context, podman does not include it in the reply. | ||
dialogErrorDetail = result.reason ? cockpit.format(_("Failed to search for images: $0"), result.reason.message) : _("Failed to search for images."); | ||
} else if (!manifestResult && !imageExistsLocally(value, this.props.localImages)) { |
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 added line is not executed by any test.
Pressing "Enter" in the dialog on any active form element (such as the search input or the checkboxes) previously bubbled up to the Form, which then activated the first popover help. This is unexpected and very irritating especially when using the search input. Just ignore the Enter key to fix that, similar to what the image search modal already does. See cockpit-project#1821 (comment)
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.
Cheers @tomasmatus ! The previous review still has three current threads, and I have some more questions. This is coming together!
|
||
const changeDialogError = (reason) => { | ||
dialogError = _("Failed to search for new images"); | ||
// TODO: add registry context, podman does not include it in the reply. |
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.
Follow-up, or is that easy to do and you just forgot about it?
} | ||
|
||
Promise.allSettled(searches) | ||
.then(reply => { | ||
if (reply && this._isMounted) { | ||
let imageResults = []; | ||
let dialogError = ""; | ||
let dialogErrorDetail = ""; | ||
const manifestResult = handleManifestsQuery(reply[0]); |
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.
So if this fails, but the other search replies succeed, this quickly sets an error in the dialog, but the code below will then reset/update the error, right? I.e. that may be intended (even though it's a bit ugly). The error handling strategy should at least be commented here, or better made explicit.
// TODO: add registry context, podman does not include it in the reply. | ||
dialogErrorDetail = result.reason ? cockpit.format(_("Failed to search for images: $0"), result.reason.message) : _("Failed to search for images."); | ||
} else if (!manifestResult && !imageExistsLocally(value, this.props.localImages)) { | ||
changeDialogError(result.reason); |
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.
So this overwrites the error set by handleManifestQuery()
, which seems fine -- but it also overwrites earlier error from reply[i-1]. It probably doesn't matter that much if we show the error from the first or last registry, it just feels a bit random.
Pressing "Enter" in the dialog on any active form element (such as the search input or the checkboxes) previously bubbled up to the Form, which then activated the first popover help. This is unexpected and very irritating especially when using the search input. Just ignore the Enter key to fix that, similar to what the image search modal already does. See cockpit-project#1821 (comment)
Pressing "Enter" in the dialog on any active form element (such as the search input or the checkboxes) previously bubbled up to the Form, which then activated the first popover help. This is unexpected and very irritating especially when using the search input. Just ignore the Enter key to fix that, similar to what the image search modal already does. See #1821 (comment)
fixes: #1220
Add support to pull images from registries which do not support search API.