Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Jun 24, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Improve output of verify-e2e-images.sh

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.

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?

NONE

/assign @BenTheElder

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 24, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Jun 24, 2025
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 24, 2025
@pohly
Copy link
Contributor Author

pohly commented Jun 24, 2025

/sig testing

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 24, 2025
# 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=$?
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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]

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@pohly pohly changed the title verify-e2e-images.sh enhancements WIP: verify-e2e-images.sh enhancements Jun 24, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 24, 2025
@pohly pohly force-pushed the test-verify-images branch from 0acfa00 to 9083f5d Compare June 25, 2025 07:07
@pohly pohly changed the title WIP: verify-e2e-images.sh enhancements verify-e2e-images.sh enhancements Jun 25, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 25, 2025
pohly added 2 commits June 25, 2025 10:30
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.
@pohly pohly force-pushed the test-verify-images branch from 9083f5d to 49ebabb Compare June 25, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants