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

Tests: new tool to build a no-history image #5486

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

Conversation

edsantiago
Copy link
Collaborator

Script crafts a custom image with multiple layers but
no history; used in tests/bud.bats:bud-implicit-no-history test.

Signed-off-by: Ed Santiago santiago@redhat.com

None

Copy link
Contributor

openshift-ci bot commented Apr 22, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: edsantiago
Once this PR has been reviewed and has the lgtm label, please assign lsm5 for approval. 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

@edsantiago edsantiago requested a review from nalind April 22, 2024 19:11
@edsantiago
Copy link
Collaborator Author

Image pushed to quay.io/libpod/buildah-testimage-nohistory:20240422. @nalind if this is satisfactory, please feel free to use that in #5473

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.


# First layer is a copy of this script
# FIXME: find some way to add a label or annotation or something to indicate that
cp $0 $workdir/file01
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be "$workdir/file1", since seq isn't zero-padding the values it produces.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is now :-)

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand what you mean here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh..... duh, my bad. I changed seq to seq --format %02g ... but apparently I need to actually commit that change.

@nalind
Copy link
Member

nalind commented Apr 22, 2024

This depends on skopeo, which we're not using in the tests themselves, so that would be a new dependency if we ran this at test-time.

@edsantiago
Copy link
Collaborator Author

Oh, good point; I should make that clear in the header comments. This is NOT going to be run in CI or tests or anything ever. It will only be run by a human, on demand, as needed. Like, today. Then, in the future, when something else is needed such as pastel-colored layers with sprinkles.

The idea is to craft the image one time, like, right now (today), push it to quay, and then bud.bats pulls it.

Since the crafted image is stored on quay, that's what I meant by label/annotation: something that can give a human being some sort of clue when running inspect.


# Build an image config and image manifest in parallel
# FIXME: find some way to create images for other arches?
echo '{"architecture": "amd64", "os": "linux", "rootfs": {"type": "layers", "diff_ids": [' > config.json
Copy link
Member

Choose a reason for hiding this comment

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

To add labels, add "labels": {"key1": "value1" [, "key2": "value2" [...]]}, between "linux", and "rootfs":.

# Build an image config and image manifest in parallel
# FIXME: find some way to create images for other arches?
echo '{"architecture": "amd64", "os": "linux", "rootfs": {"type": "layers", "diff_ids": [' > config.json
echo '{"schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", "layers": [' > manifest.json
Copy link
Member

Choose a reason for hiding this comment

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

To add annotations, add "annotations": {"key1": "value1" [, "key2": "value2" [...]]}, between "application/vnd.oci.image.manifest.v1+json", and "layers":.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks I've been trying for the past few days to convert this script into something that'll make a manifest list with all the necessary arches, but it's really hurting my brain. I'll get back to it next week.

@edsantiago
Copy link
Collaborator Author

Well, this grew WAY out of control. Not sure it's worth pursuing any more. Will revisit it tomorrow.

(The good news is, quay.io/libpod/buildah-testimage-nohistory:20240429 now exists and seems to work in the bud test; and fails using buildah 1.26)

Script crafts a custom image with multiple layers but
no history; used in tests/bud.bats:bud-implicit-no-history test.

Signed-off-by: Ed Santiago <santiago@redhat.com>
@edsantiago
Copy link
Collaborator Author

@nalind WDYT, as an alternative to #5495?

@nalind
Copy link
Member

nalind commented May 1, 2024

I'm kind of lukewarm on this.
At test-time, we'd end up consulting the registry for an image that #5495 constructs locally. If a base image used in another test was being built with a Containerfile using scratch as a base, I don't think we'd be trying to break the part of the test that builds that image into a separate script, pushing the image the script built to a registry, and changing the test so that it pulled the image instead of building it.

@edsantiago
Copy link
Collaborator Author

I completely understand. My thinking on this is that the test script is super complicated and unmaintainable. If that test ever fails, it is likely to happen in the build-image steps and not in the make-sure-buildah-deals-with-it steps. And if that happens, the poor maintainer will spend many hours trying to figure out the build logic, then what broke, then how to fix it.

My thinking is also that there could be great value in extending this script some day such that it crafts an image with other "quirks" used for testing. (IOW, in response to your second paragraph, I think it's very important to test prebuilt known-quirky images than to spend developer time maintaining the how-do-we-build-this logic).

I'm not strong on it though. The image is now on quay, and it includes a copy of the script that built it, so it'll all be there if/when we need it.

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.

None yet

2 participants