-
Notifications
You must be signed in to change notification settings - Fork 40.9k
verify-e2e-images.sh enhancements #132478
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
base: master
Are you sure you want to change the base?
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pohly 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 |
/sig testing |
hack/verify-e2e-images.sh
Outdated
# diff context is irrelevant here because of sorting. | ||
# Instead we want to know about old images (no longer in use, need to be removed) | ||
# and new images (should not get added). | ||
>&2 diff -Napr --old-line-format="obsolete image: %L" --new-line-format="forbidden image: %L" --unchanged-line-format="" <(printf '%s\n' "${PERMITTED_IMAGES[@]}") <(printf '%s\n' "${IMAGES[@]}") || ret=$? |
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 was worried about depending on GNU diff, but -Naupr
isn't part of the POSIX standard either, so perhaps this is okay?
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.
-Naupr
works with macOS diff, these flags do not.
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.
$ diff --version
Apple diff (based on FreeBSD diff)
$ diff
usage: diff [-aBbdilpTtw] [-c | -e | -f | -n | -q | -u] [--ignore-case]
[--no-ignore-case] [--normal] [--strip-trailing-cr] [--tabsize]
[-I pattern] [-F pattern] [-L label] file1 file2
diff [-aBbdilpTtw] [-I pattern] [-L label] [--ignore-case]
[--no-ignore-case] [--normal] [--strip-trailing-cr] [--tabsize]
[-F pattern] -C number file1 file2
diff [-aBbdiltw] [-I pattern] [--ignore-case] [--no-ignore-case]
[--normal] [--strip-trailing-cr] [--tabsize] -D string file1 file2
diff [-aBbdilpTtw] [-I pattern] [-L label] [--ignore-case]
[--no-ignore-case] [--normal] [--tabsize] [--strip-trailing-cr]
[-F pattern] -U number file1 file2
diff [-aBbdilNPprsTtw] [-c | -e | -f | -n | -q | -u] [--ignore-case]
[--no-ignore-case] [--normal] [--tabsize] [-I pattern] [-L label]
[-F pattern] [-S name] [-X file] [-x pattern] dir1 dir2
diff [-aBbditwW] [--expand-tabs] [--ignore-all-blanks]
[--ignore-blank-lines] [--ignore-case] [--minimal]
[--no-ignore-file-name-case] [--strip-trailing-cr]
[--suppress-common-lines] [--tabsize] [--text] [--width]
-y | --side-by-side file1 file2
diff [--help] [--version]
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.
Normally when requiring a gnu utility we do so explicitly, and we do so for things that are difficult to do without (e.g. bash versus mere posix sh), we've rarely required another tool.
The line formatting could be accomplished with something like sed.
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.
Ack, so a different solution is needed after all.
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 with post-processing now, please take another look.
0acfa00
to
9083f5d
Compare
Before: Diffing e2e image list ... --- /dev/fd/63 2025-06-24 09:32:43.736397729 +0200 +++ /dev/fd/62 2025-06-24 09:32:43.736397729 +0200 @@ -5,7 +5,7 @@ invalid.registry.k8s.io/invalid/alpine registry.k8s.io/build-image/distroless-iptables registry.k8s.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver registry.k8s.io/e2e-test-images/agnhost -registry.k8s.io/e2e-test-images/apparmor-loader +registry.k8s.io/e2e-test-images/apparmor-no-such-image registry.k8s.io/e2e-test-images/busybox registry.k8s.io/e2e-test-images/httpd registry.k8s.io/e2e-test-images/ipc-utils FAIL: e2e images do not match the approved list! For this test, apparmor-loader was commented out in .permitted-images (making it a forbidden unknown image) and apparmor-no-such-image was added (making it an obsolete image). Problems with the output: - The position of old and new image lists was reversed. - It's not clear what is being diffed. Not referencing .permitted-images directly probably was meant to discourage using some image other than agnhost, but developers can easily find the file anyway and are shown some other images in the diff context. After: Diffing e2e image list ... obsolete image: registry.k8s.io/e2e-test-images/apparmor-no-such-image forbidden image: registry.k8s.io/e2e-test-images/apparmor-loader FAIL: current e2e images do not match the approved list in test/images/.permitted-images! This mentions test/images/.permitted-images because developers might have to edit it if some image really becomes obsolete.
If the command failed in the <( ... ) expression, the return code was ignored and the script continued with potentially no output. Not likely, but it's still better to invoke the command where pipefail will catch a non-zero exit code. For example, broken test registration could cause this. There should be no log output, but if there is, failing explicitly is better than ignoring it (on stderr) or treating it like an image (on stdout). Found when experimenting with the logging configuration of e2e.test, currently there is no such unwanted log output.
9083f5d
to
49ebabb
Compare
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Improve output of verify-e2e-images.sh
Before:
For this test, apparmor-loader was commented out in .permitted-images (making it a forbidden unknown image) and apparmor-no-such-image was added (making it an obsolete image).
Problems with the output:
After:
This mentions test/images/.permitted-images because developers might have to edit it if some image really becomes obsolete.
additional validation of e2e.test --list-images output
If the command failed in the
<( ... )
expression, the return code was ignored and the script continued with potentially no output. Not likely, but it's still better to invoke the command where pipefail will catch a non-zero exit code. For example, broken test registration could cause this.There should be no log output, but if there is, failing explicitly is better than ignoring it (on stderr) or treating it like an image (on stdout). Found when experimenting with the logging configuration of e2e.test, currently there is no such unwanted log output.
Which issue(s) this PR is related to:
N/A
Special notes for your reviewer:
Does this PR introduce a user-facing change?
/assign @BenTheElder