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

inventory: sort the images based on the sorted tags and not in the hash #251

Closed
wants to merge 2 commits into from

Conversation

cpanato
Copy link
Member

@cpanato cpanato commented Aug 5, 2020

Context:
We generate the image promotion for K/K artifacts and we notice the yaml file produced was something like

- name: conformance
  dmap:
    "sha256:10b30e54a6367e69c52c22998f6f154475b7c94b7a674324f1b96b549048c50e": ["v1.19.0-rc.2"]
    "sha256:288138b199735aa767b042a2bbdc211fb852bf2e5e8368ab45e42fa1ddb0373f": ["v1.19.0-rc.3"]
    "sha256:4fccdf9bfd019a8871729a23d9be4055466b98f857fd811b2141f90bc60c86cc": ["v1.19.0-rc.4"]
- name: conformance-amd64
  dmap:
    "sha256:8c053fbfe74da394cf2c9ace242a060a27f62cb701b0d76f1377e14c0cc7ce4e": ["v1.19.0-rc.2"]
    "sha256:c84f41a851478e60c143e9dd98fe9ab3caca08ed598652a8e308d47855c3ab43": ["v1.19.0-rc.3"]
    "sha256:ea2b4c82b7b524aa1dc86da3d75ac142bc6ccd188e57df2f06cc220052c1eb9c": ["v1.19.0-rc.4"]
- name: conformance-arm
  dmap:
    "sha256:aac6803b665bc435193caa03ced25d7dfc4dd06f5e671fffcf8866abcefbdc15": ["v1.19.0-rc.3"]
    "sha256:b92cc0d5f677e10243fe886d049647fc3b2b6fed1f69ac3d4fd2ece6a36f207e": ["v1.19.0-rc.4"]
    "sha256:de8a15f9c32e0c025bd3231ccfc8e8a0872b6978ab225a0c262d2e04cbe9cad7": ["v1.19.0-rc.2"]
- name: conformance-arm64
  dmap:
    "sha256:255fe1e95ccd523817357db40eb56cef8ab6d93bb4fe30972a08dbc2f2be1ddf": ["v1.19.0-rc.2"]
    "sha256:2f9aaecaa147cfe2c33d89a4d23c15de9585ba444d756e21eb26f35400550930": ["v1.19.0-rc.3"]
    "sha256:9a85df6915994be54e2f4bfdb0447eb52dfb13ffdd7840847a8ec1d19cfc2be7": ["v1.19.0-rc.4"]
- name: conformance-ppc64le
  dmap:
    "sha256:2f7821c58fef43dec3d7cd8a92f6406c80855c60ce1cf80046c169859a3cf9ea": ["v1.19.0-rc.2"]
    "sha256:790627063d4c15d7e1fb75c49f86b78bd82de60d0c5fa288837af23be6803770": ["v1.19.0-rc.4"]
    "sha256:e296f92d5a5255c69eec77ab34ddd63048a839b58074c6bb58041a096651ce5e": ["v1.19.0-rc.3"]
....

(can see the full file in this PR)
The Images are sorted by the hashes and @hasheddan came with the idea if we can sort that by the tags. Maybe is useful and this PR address that

Looking at the code when we are doing the sort the first step is to sort the tags because it can have multiple tags for the same hash. And then it sort the items by the hash.

the change here switch to sort by the tag, and since the tags is already sorted we take the first element in the tag array and use that to sort the items.

Applying that to the same PR that we did above we get

- name: conformance
  dmap:
    "sha256:10b30e54a6367e69c52c22998f6f154475b7c94b7a674324f1b96b549048c50e": ["v1.19.0-rc.2"]
    "sha256:288138b199735aa767b042a2bbdc211fb852bf2e5e8368ab45e42fa1ddb0373f": ["v1.19.0-rc.3"]
    "sha256:4fccdf9bfd019a8871729a23d9be4055466b98f857fd811b2141f90bc60c86cc": ["v1.19.0-rc.4"]
- name: conformance-amd64
  dmap:
    "sha256:8c053fbfe74da394cf2c9ace242a060a27f62cb701b0d76f1377e14c0cc7ce4e": ["v1.19.0-rc.2"]
    "sha256:c84f41a851478e60c143e9dd98fe9ab3caca08ed598652a8e308d47855c3ab43": ["v1.19.0-rc.3"]
    "sha256:ea2b4c82b7b524aa1dc86da3d75ac142bc6ccd188e57df2f06cc220052c1eb9c": ["v1.19.0-rc.4"]
- name: conformance-arm
  dmap:
    "sha256:de8a15f9c32e0c025bd3231ccfc8e8a0872b6978ab225a0c262d2e04cbe9cad7": ["v1.19.0-rc.2"]
    "sha256:aac6803b665bc435193caa03ced25d7dfc4dd06f5e671fffcf8866abcefbdc15": ["v1.19.0-rc.3"]
    "sha256:b92cc0d5f677e10243fe886d049647fc3b2b6fed1f69ac3d4fd2ece6a36f207e": ["v1.19.0-rc.4"]
- name: conformance-arm64
  dmap:
    "sha256:255fe1e95ccd523817357db40eb56cef8ab6d93bb4fe30972a08dbc2f2be1ddf": ["v1.19.0-rc.2"]
    "sha256:2f9aaecaa147cfe2c33d89a4d23c15de9585ba444d756e21eb26f35400550930": ["v1.19.0-rc.3"]
    "sha256:9a85df6915994be54e2f4bfdb0447eb52dfb13ffdd7840847a8ec1d19cfc2be7": ["v1.19.0-rc.4"]
- name: conformance-ppc64le
  dmap:
    "sha256:2f7821c58fef43dec3d7cd8a92f6406c80855c60ce1cf80046c169859a3cf9ea": ["v1.19.0-rc.2"]
    "sha256:e296f92d5a5255c69eec77ab34ddd63048a839b58074c6bb58041a096651ce5e": ["v1.19.0-rc.3"]
    "sha256:790627063d4c15d7e1fb75c49f86b78bd82de60d0c5fa288837af23be6803770": ["v1.19.0-rc.4"]

Which is now sorted by the tags.

Feel free to close this PR if that makes no sense.

/assign @listx @dims @tpepper
/cc @saschagrunert @hasheddan

thanks for the idea Daniel!

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/release Categorizes an issue or PR as relevant to SIG Release. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 5, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cpanato
To complete the pull request process, please assign dims
You can assign the PR to them by writing /assign @dims in a comment when ready.

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

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 5, 2020
@k8s-ci-robot
Copy link
Contributor

@cpanato: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-cip-lint 96edf7a link /test pull-cip-lint
pull-cip-e2e 96edf7a link /test pull-cip-e2e
pull-cip-unit-tests 96edf7a link /test pull-cip-unit-tests

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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

@dims dims removed their assignment Aug 10, 2020
@listx
Copy link
Contributor

listx commented Aug 11, 2020

@cpanato I think the better answer is: treat the YAMLs as machine-readable data, and then use a separate tool to have different views of it (whether sorted by hash, tags, date, authorship, or whatever else). That is, we should encourage users to view the data through a tool (with different query options, etc) rather than reading the raw YAML. I've seen this pattern used in the https://www.ledger-cli.org/ tool in the world of accounting and I think we can adopt a similar approach.

WDYT?

@cpanato
Copy link
Member Author

cpanato commented Aug 12, 2020

@listx makes sense. thanks so much for the clarification.
will close this PR.
/close

@k8s-ci-robot
Copy link
Contributor

@cpanato: Closed this PR.

In response to this:

@listx makes sense. thanks so much for the clarification.
will close this PR.
/close

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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/release Categorizes an issue or PR as relevant to SIG Release. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants