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

[WIP] this script allows us to compare two images #669

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jiridanek
Copy link
Member

Description

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link
Contributor

openshift-ci bot commented Aug 9, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

openshift-ci bot commented Aug 9, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from jiridanek. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

# Example usage:
# ./ci/compare-images.sh quay.io/opendatahub/workbench-images@sha256:e92bf20e127e545bdf56887903dc72ad227082b8bc23f45ff4f0fc67e6430318 ghcr.io/jiridanek/notebooks/workbench-images:base-ubi9-python-3.9-jd_ubi_base_adedd4a943977ecdcb67bc6eb9eda572d10c3ddc

shopt -s globstar
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

set -Eeuxo pipefail

https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/

to fail if something needed is missing?

I happen to not have skopeo, so

./ci/compare-images.sh quay.io/opendatahub/workbench-images@sha256:e92bf20e127e545bdf56887903dc72ad227082b8bc23f45ff4f0fc67e6430318 ghcr.io/jiridanek/notebooks/workbench-images:base-ubi9-python-3.9-jd_ubi_base_adedd4a943977ecdcb67bc6eb9eda572d10c3ddc
./ci/compare-images.sh: line 26: shopt: globstar: invalid shell option name
Gathering the metadata for the image: 'quay.io/opendatahub/workbench-images@sha256:e92bf20e127e545bdf56887903dc72ad227082b8bc23f45ff4f0fc67e6430318'
Image SHA: 'e92bf20e127e545bdf56887903dc72ad227082b8bc23f45ff4f0fc67e6430318'
./ci/compare-images.sh: line 42: skopeo: command not found
./ci/compare-images.sh: line 45: skopeo: command not found

Comment on lines +69 to +71
diff -y "${tmp_dir}"/*-global-pip.txt
diff -y "${tmp_dir}"/*-local-pip.txt
diff -y "${tmp_dir}"/*-rpms.txt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these, https://man.archlinux.org/man/comm.1.en may work a little bit better?

Comment on lines +53 to +54
podman run --entrypoint /usr/bin/pip --rm -it "${image}" list > "${tmp_dir}/${image_sha}-global-pip.txt"
podman run --entrypoint /opt/app-root/bin/pip --rm -it "${image}" list > "${tmp_dir}/${image_sha}-local-pip.txt"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--disable-pip-version-check ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. We should (eventually) have the results of this available everytime we update metadata in release-2.8 etc. release branch of images, also everytime we update 2024a etc., and for every PR that makes changes to images.

Copy link
Member

@jstourac jstourac Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that is exactly my point; I'll create a tracking issue for this so I can plan this for some of next sprints then

update: https://issues.redhat.com/browse/RHOAIENG-11254
also, I realized I can't edit description of this, so once I address your concerns here, I will probably close this PR and will raise my own later on 🙂

echo "Let's compare the image metadata now:"

diff -y "${tmp_dir}"/*-size.txt
diff -y "${tmp_dir}"/*-metadata.txt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially a json, or it can be printed as json, so the diff should use that

diff <(jq --sort-keys . A.json) <(jq --sort-keys . B.json)

some people on stackoverflow suggest jd -set, https://stackoverflow.com/questions/31930041/using-jq-or-alternative-command-line-tools-to-compare-json-files

@caponetto
Copy link
Contributor

Have you seen this? Maybe it could be useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen this? Maybe it could be useful.

Not bad, but the functionality seems different. This script compares packages, whereas the linked tool compares files in the images. Guess it could be added to the script, but then it would require us to have the tool preinstalled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caponetto Actually, I tried that tool before I started to implement this my own thing. I didn't like the output of that script much. It's too verbose and shows complete differences of the image on the file level instead of the package level. I'm not sure whether this is what we want. That is why I went with our own way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I'm glad you've already considered it.

Copy link
Contributor

openshift-ci bot commented Dec 19, 2024

@jiridanek: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/notebook-rocm-ubi9-python-3-11-pr-image-mirror 570abf0 link true /test notebook-rocm-ubi9-python-3-11-pr-image-mirror
ci/prow/notebook-rocm-jupyter-min-ubi9-python-3-11-pr-image-mirror 570abf0 link true /test notebook-rocm-jupyter-min-ubi9-python-3-11-pr-image-mirror
ci/prow/runtime-rocm-pytorch-ubi9-python-3-11-pr-image-mirror 570abf0 link true /test runtime-rocm-pytorch-ubi9-python-3-11-pr-image-mirror
ci/prow/runtime-rocm-tensorflow-ubi9-python-3-11-pr-image-mirror 570abf0 link true /test runtime-rocm-tensorflow-ubi9-python-3-11-pr-image-mirror
ci/prow/intel-notebooks-e2e-tests 570abf0 link true /test intel-notebooks-e2e-tests
ci/prow/rocm-notebooks-e2e-tests 570abf0 link true /test rocm-notebooks-e2e-tests
ci/prow/rocm-runtimes-ubi9-e2e-tests 570abf0 link true /test rocm-runtimes-ubi9-e2e-tests
ci/prow/notebooks-ubi9-e2e-tests 570abf0 link true /test notebooks-ubi9-e2e-tests
ci/prow/rstudio-notebook-e2e-tests 570abf0 link true /test rstudio-notebook-e2e-tests
ci/prow/runtimes-ubi9-e2e-tests 570abf0 link true /test runtimes-ubi9-e2e-tests
ci/prow/codeserver-notebook-e2e-tests 570abf0 link true /test codeserver-notebook-e2e-tests

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants