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

bib/internal/setup: Tag validate early #475

Merged
merged 5 commits into from
Jul 4, 2024

Conversation

bearrito
Copy link

This is my first attempted commit to this project.

I'm still learning the repo structure and dev workflow. Few questions on testing.

  1. In this commit I'm relying on having images locally. I didn't see anything similar so I assume we want to avoid this/tests will fail. Is there an alternative?
  2. If I have to rely on testing by hand, how can I use local changes? I'm thinking I just https://github.com/osbuild/bootc-image-builder?tab=readme-ov-file# building and then can follow examples?

Closes: #380

@bearrito
Copy link
Author

bearrito commented Jun 15, 2024

Working, testing by hand

bearrito@home:~/Git/bootc-image-builder$ sudo podman run --rm  -it  --privileged --pull=newer --security-opt label=type:unconfined_t     -v $(pwd)/config.toml:/config.toml     -v $(pwd)/output:/output     localhost/bootc-image-builder:tag-validate   --type qcow2 quay.io/centos/centos:stream9
WARNING: The same type, major and minor should not be used for multiple devices.
... elided... ( I don't know enough to know what the warnings mean)
WARNING: The same type, major and minor should not be used for multiple devices.
Generating manifest manifest-qcow2.json
Error: cannot build manifest: image quay.io/centos/centos:stream9 is not a bootc image
2024/06/15 21:02:07 error: cannot build manifest: image quay.io/centos/centos:stream9 is not a bootc image

Copy link
Collaborator

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

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

Thank you (and sorry for the somewhat slow reply, we are usually quicker with reviews)!

This looks very nice - I have some suggestions inline about the testing, it includes two potential git commits that could be used here to. Once the testing is sorted this looks good to go to me (but an additonal pair of eyes on this from e.g. @achilleas-k would be nice)

bib/internal/setup/setup_test.go Outdated Show resolved Hide resolved
bib/internal/setup/setup.go Outdated Show resolved Hide resolved
@bearrito
Copy link
Author

bearrito commented Jun 19, 2024

@mvo5 I incorporated your patches. My editor applied my default formatting, not sure there is a formatter the project uses.

I had an issue with test_manifest.py. 5 of the tests were failing due to arch issues. Maybe this is environmental on my end?
Example:

Trying to pull quay.io/centos-bootc/fedora-bootc:eln...
Error: error creating build container: choosing an image from manifest list docker://quay.io/centos-bootc/fedora-bootc:eln: no image found in image index for architecture x86_64, variant "", OS linux
FAILED

================================================================= FAILURES ==================================================================
_______________________________________ test_manifest_disksize[quay.io/centos-bootc/fedora-bootc:eln] __

The specific tag tests were passing though.

sudo -E /home/barrett/.local/bin/pytest -s -v test/test_manifest.py::test_manifest_checks_build_container_is_bootc

=========================================================== slowest 10 durations ============================================================
2.63s call     test/test_manifest.py::test_manifest_checks_build_container_is_bootc[quay.io/centos-bootc/centos-bootc:stream9-False-None]
1.53s call     test/test_manifest.py::test_manifest_checks_build_container_is_bootc[quay.io/centos/centos:stream9-True-image quay.io/centos/centos:stream9 is not a bootc image]
1.43s setup    test/test_manifest.py::test_manifest_checks_build_container_is_bootc[quay.io/centos/centos:stream9-True-image quay.io/centos/centos:stream9 is not a bootc image]
0.00s setup    test/test_manifest.py::test_manifest_checks_build_container_is_bootc[quay.io/centos-bootc/centos-bootc:stream9-False-None]
0.00s teardown test/test_manifest.py::test_manifest_checks_build_container_is_bootc[quay.io/centos-bootc/centos-bootc:stream9-False-None]
0.00s teardown test/test_manifest.py::test_manifest_checks_build_container_is_bootc[quay.io/centos/centos:stream9-True-image quay.io/centos/centos:stream9 is not a bootc image]
============================================================= 2 passed in 5.68s =============================================================

@mvo5
Copy link
Collaborator

mvo5 commented Jun 19, 2024

Thank you for the updated PR!

@mvo5 I incorporated your patches. My editor applied my default formatting, not sure there is a formatter the project uses.

The formatitng changes are something we would like to avoid. The diff should just contain the functional changes. It might be easiest to just "git am" the two patches from #475 (comment) and force push. Note that the "happy" path of ValidateHasContainerTags is tested implicitly by any of the "test_{build,manifest}.py" that test a valid image (e.g. test_manifest..yy::test_manifest_smoke).

I had an issue with test_manifest.py. 5 of the tests were failing due to arch issues. Maybe this is environmental on my end? Example:

Trying to pull quay.io/centos-bootc/fedora-bootc:eln...
Error: error creating build container: choosing an image from manifest list docker://quay.io/centos-bootc/fedora-bootc:eln: no image found in image index for architecture x86_64, variant "", OS linux
FAILED

[..]

Thank you! I will try to reproduce, is there anything unusual about your setup that might help me to reproduce?

@achilleas-k
Copy link
Member

I got a bit lost reviewing that last commit with all the formatting changes so I edited the commits a bit. Broke out the octal literal format change into its own commit, reverted the formatting changes to test_manifest.py and fixed the import order in a separate commit.

achilleas-k
achilleas-k previously approved these changes Jun 19, 2024
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. This LGTM!

achilleas-k
achilleas-k previously approved these changes Jun 19, 2024
@mvo5 mvo5 enabled auto-merge June 21, 2024 09:20
bstrausser and others added 4 commits July 4, 2024 13:02
Check that the container has the expected bootc tags early and fail if
they are missing.
Use `0o` instead of just `0` for better readability.
Create a mock podman executable script and add it at the top of PATH.
Use it to generate output for the container tag validation.
@achilleas-k
Copy link
Member

Rebased and resolved conflict.

achilleas-k
achilleas-k previously approved these changes Jul 4, 2024
Add new `test_manifest_checks_build_container_is_bootc` test
that validates that `botoc-iamge-build manifest` fails with
the expected error on a non-bootc image url.

Note that this will implicitly check `build` too as the same
check is performed in bib for manifest and build (i.e. bib
needs to generate a manifest first before it can build).

Co-authored-by: bstrausser <bstrausser@locusrobotics.com>
Copy link
Collaborator

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

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

Thank you!

@mvo5 mvo5 added this pull request to the merge queue Jul 4, 2024
Merged via the queue into osbuild:main with commit aa6343f Jul 4, 2024
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check for containers.bootc label early on
3 participants