Skip to content
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: first and last image won't be detected as known image, do not add single quote to the jsonpath (#9448) #9449

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

6uliver
Copy link
Contributor

@6uliver 6uliver commented Jun 18, 2024

Fixes: #9448
Related: None
Merge before/after: None

Description
It's not necessary to add single quote to the ojsonpath parameter since Go exec Cmd won't run it in a shell and does not expand any patterns as described in the documentation: https://pkg.go.dev/os/exec#pkg-overview

With the single quote added (the original implementation) JSON path algorithm will add the single quote to string so that the result of the findKnownImages will start and end with a single quote and the list will be something like this (please note the first and last character which is a single quote):

'docker.io/library/service:e1aab03877e36438a59d1832b4e1e69dc3f990527e3e37e177cbc91a88a5b653
docker.io/rancher/klipper-helm@sha256:87db3ad354905e6d31e420476467aefcd8f37d071a8f1c8a904f4743162ae546
docker.io/rancher/klipper-helm:v0.8.3-build20240228
docker.io/rancher/mirrored-library-traefik@sha256:ca9c8fbe001070c546a75184e3fd7f08c3e47dfc1e89bff6fe2edd302accfaec
docker.io/rancher/mirrored-library-traefik:2.10.5
docker.io/rancher/mirrored-metrics-server@sha256:20b8b36f8cac9e25aa2a0ff35147b13643bfec603e7e7480886632330a3bbc59
docker.io/rancher/mirrored-metrics-server:v0.7.0
docker.io/rancher/local-path-provisioner@sha256:aee53cadc62bd023911e7f077877d047c5b3c269f9bba25724d558654f43cea0
docker.io/rancher/local-path-provisioner:v0.0.26
docker.io/rancher/mirrored-coredns-coredns@sha256:a11fafae1f8037cbbd66c5afa40ba2423936b72b4fd50a7034a7e8b955163594
docker.io/rancher/mirrored-coredns-coredns:1.10.1
docker.io/rancher/klipper-lb@sha256:558dcf96bf0800d9977ef46dca18411752618cd9dd06daeb99460c0a301d0a60
docker.io/rancher/klipper-lb:v0.4.7
docker.io/rancher/mirrored-pause@sha256:74c4244427b7312c5b901fe0f67cbc53683d06f4f24c6faee65d4182bf0fa893
docker.io/rancher/mirrored-pause:3.6'

Instead of

docker.io/library/service:e1aab03877e36438a59d1832b4e1e69dc3f990527e3e37e177cbc91a88a5b653
docker.io/rancher/klipper-helm@sha256:87db3ad354905e6d31e420476467aefcd8f37d071a8f1c8a904f4743162ae546
docker.io/rancher/klipper-helm:v0.8.3-build20240228
docker.io/rancher/mirrored-library-traefik@sha256:ca9c8fbe001070c546a75184e3fd7f08c3e47dfc1e89bff6fe2edd302accfaec
docker.io/rancher/mirrored-library-traefik:2.10.5
docker.io/rancher/mirrored-metrics-server@sha256:20b8b36f8cac9e25aa2a0ff35147b13643bfec603e7e7480886632330a3bbc59
docker.io/rancher/mirrored-metrics-server:v0.7.0
docker.io/rancher/local-path-provisioner@sha256:aee53cadc62bd023911e7f077877d047c5b3c269f9bba25724d558654f43cea0
docker.io/rancher/local-path-provisioner:v0.0.26
docker.io/rancher/mirrored-coredns-coredns@sha256:a11fafae1f8037cbbd66c5afa40ba2423936b72b4fd50a7034a7e8b955163594
docker.io/rancher/mirrored-coredns-coredns:1.10.1
docker.io/rancher/klipper-lb@sha256:558dcf96bf0800d9977ef46dca18411752618cd9dd06daeb99460c0a301d0a60
docker.io/rancher/klipper-lb:v0.4.7
docker.io/rancher/mirrored-pause@sha256:74c4244427b7312c5b901fe0f67cbc53683d06f4f24c6faee65d4182bf0fa893
docker.io/rancher/mirrored-pause:3.6

If the string of an image tag contains single quote then the stringslice.Contains(knownImages, normalizedImageRef.String()) won't match it in the loadImages so we will load it again which is not necessary.

User facing changes
This will fix the problem described in #9448 and the startup time will be significantly faster in case of one of the images is the first or the last one in the list.

@ericzzzzzzz ericzzzzzzz merged commit 3967f5c into GoogleContainerTools:main Jun 19, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

First and last images are not detected when loading images to the cluster
2 participants