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

manifest, push: implement --add-compression to push with compressed variants. #19468

Merged

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Aug 1, 2023

This is a feature PR for containers/image feature merged in below PR:

Adds a new flag --add-compression to manifest push, which when added will push existing manifest on host while replicating the instances with required compression.

manifest, push: implement --add-compression to push with compressed variants.

Similar implementation to: containers/buildah#4912

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 1, 2023
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Aug 1, 2023
@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 1, 2023

Needs: containers/common#1590 (review)
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 1, 2023
@flouthoc flouthoc force-pushed the manifest-add-compression branch from d738d08 to ffbf32e Compare August 1, 2023 15:18
@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 1, 2023

Suspecting issues due to some change in c/common testing it here: #19472

@flouthoc flouthoc force-pushed the manifest-add-compression branch from ffbf32e to 7c64566 Compare August 1, 2023 16:52
@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 1, 2023

@containers/podman-maintainers PTAL PR is similar to containers/buildah#4912

@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 1, 2023

@mtrmac PTAL

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Podman maintainers, please take a look as well — I think I have a general understanding but there are certainly aspects of the engine / remote API design that I’m missing.

Makes sure that requested compression variant for each platform is added to the manifest list keeping original instance
intact in the same manifest list. Supported values are (`gzip`, `zstd` and `zstd:chunked`)

Note: This is different than `--compression` which replaces the instance with requested with specified compression
Copy link
Collaborator

Choose a reason for hiding this comment

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

That option is named --compression-format in Podman.

Copy link
Member

Choose a reason for hiding this comment

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

Can we just extend --compression to be a comma separated list.

--compression gzip,zstd

I think that makes for a better User UI.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right now the two have quite different semantics, as the text above says.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure why you say that.
If I say --compression gzip, then it is going to push the image if it has gzip compression or change the compression to gzip if it was something else.
If I push --compression gzip,zstd then I would figure it is going to push gzip and zstd, even if the original was something different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rhatdan We have already used --add-compression since it was overlapping with --compression on buildah side, it will be good here for consistency.

Extending --compression changes functionality for example --compression gzip will replace instances , but --compression gzip,zstd will only replace gzip and add zstd while changing the order of input will change functionality entirely consider --compression zstd,gzip it will replace zstd and add gzip.

We had a prior discussion here: containers/common#1585

Copy link
Collaborator

Choose a reason for hiding this comment

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

The existing --compress prefers to reuse blobs, even if they don’t use the expected algorithm. That’s a long-standing behavior and I wouldn’t be surprised if users by now relied on it.

(It’s not necessarily the option semantics we would design now as the default, if we were building the CLI from scratch with the feature set of the underlying codebase as of today, but I think the years of past practice change the calculation. @flouthoc is already working on making it possible to force using the requested algorithm independently from the cloning functionality, but that’s not this PR.)

pkg/api/handlers/libpod/manifests.go Outdated Show resolved Hide resolved
pkg/api/handlers/libpod/manifests.go Outdated Show resolved Hide resolved
pkg/domain/entities/images.go Outdated Show resolved Hide resolved
pkg/domain/infra/abi/manifest.go Outdated Show resolved Hide resolved
cmd/podman/manifest/inspect.go Outdated Show resolved Hide resolved
@flouthoc flouthoc force-pushed the manifest-add-compression branch 3 times, most recently from b9dc2aa to 9f64ac9 Compare August 2, 2023 02:10
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks, this looks close to done to me.

At this point I’ll need to defer to actual Podman experts — please review independently.

pkg/bindings/manifests/manifests.go Outdated Show resolved Hide resolved
pkg/domain/entities/images.go Outdated Show resolved Hide resolved
@flouthoc flouthoc force-pushed the manifest-add-compression branch from 9f64ac9 to 1363a56 Compare August 2, 2023 04:12
@flouthoc flouthoc force-pushed the manifest-add-compression branch from 1363a56 to 3e2d9ca Compare August 2, 2023 08:33
@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 2, 2023

Rebased. @containers/podman-maintainers PTAL

cmd/podman/manifest/push.go Outdated Show resolved Hide resolved
pkg/api/handlers/libpod/manifests.go Show resolved Hide resolved
Comment on lines +93 to +95
if ! type -p skopeo; then
skip "skopeo not available"
fi
Copy link
Member

Choose a reason for hiding this comment

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

to my knowledge skopeo is a hard requirement so this skip makes no sense
cc @edsantiago

Copy link
Collaborator Author

@flouthoc flouthoc Aug 2, 2023

Choose a reason for hiding this comment

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

The tests which are using skopeo have this check directly or indirectly so I have added it here as well.

if ! type -p skopeo; then
skip "skopeo not available"
fi
skip_if_remote "running a local registry doesn't work with podman-remote"
Copy link
Member

Choose a reason for hiding this comment

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

why? Not having remote tests is a big issue. We need tests to cover remote client and API as well.
If we cannot set this up in system tests we should use e2e tests or the bindings and API tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a e2e test.

@flouthoc flouthoc force-pushed the manifest-add-compression branch 4 times, most recently from 7828753 to 22b1661 Compare August 2, 2023 15:16
@flouthoc flouthoc requested a review from Luap99 August 2, 2023 15:38
@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 2, 2023

@containers/podman-maintainers PTAL

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Absolutely non-blocking tentative suggestions — don’t let me slow down this work unnecessarily.

// 4 images must be pushed two for gzip and two for zstd
Expect(output).To(ContainSubstring("Copying 4 images generated from 2 images in list"))

session = podmanTest.Podman([]string{"run", "--rm", "--net", "host", "quay.io/skopeo/stable", "inspect", "--tls-verify=false", "--raw", "docker://localhost:5000/list:latest"})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Absolutely non-blocking: This could plausibly call c/image instead of using a subprocess.

OTOH this is easier to follow for people unfamiliar with that codebase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is similar to systems test for easier review and familiarity.

Copy link
Member

Choose a reason for hiding this comment

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

I think it would make more sense to directly execute skopeo on the host instead of pulling the image as pull are flaky and slow. We already depend on it in system test so I see no problem using it in e2e as well.

Comment on lines +176 to +182
session = podmanTest.Podman([]string{"build", "--platform", "linux/amd64", "-t", "imageone", "build/basicalpine"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))

session = podmanTest.Podman([]string{"build", "--platform", "linux/arm64", "-t", "imagetwo", "build/basicalpine"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have multi-arch image that could be used for this test without requiring a build, by any chance?

(I have no idea … and if this works, maybe we can spend CPU cycles instead of our attention.)

Copy link
Member

Choose a reason for hiding this comment

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

quay.io/libpod/20221018? Or even :00000004 if you want a tiny image.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure I'll consider it if I am going to make any further change and repush this. ( I hope this not a hard blocker since OTOH building image makes tests independent of any external image ( pulling ) which has been encouraged in past if i can recall )

Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC the Podman e2e tests already have some infrastructure to pre-pull / cache images, so that not every pull needs to reach out to the internet. But I don’t know the details by heart.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM, tests can be improved later if needed.

@flouthoc flouthoc requested a review from vrothberg August 3, 2023 08:30
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

One last nit on the docs

intact in the same manifest list. Supported values are (`gzip`, `zstd` and `zstd:chunked`)

Note: This is different than `--compression-format` which replaces the instance with requested with specified compression
while `--add-compression` makes sure than each instance has it variant added to manifest list without modifying the
Copy link
Member

Choose a reason for hiding this comment

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

For some reason I cannot propose a change via the GitHub UI but the sentence above has typos:

makes sure that each instance has its variant added to manifest list without modifying the
original instance.

I still find the note hard to understand and suggest to be more explicit and less abstract:

"Note that --compression-format controls the compression format of each instance in the manifest list. --add-compression will add another variant for each instance in the list with the specified compressions. --compression-format gzip --add-compression zstd will push a manifest list with each instance being compressed with gzip plus an additional variant of each instance being compressed with zstd."

I am sure there's a better description than mine but I find it important to be more explicit.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe worth mentioning that it can be specified multiple times.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe worth mentioning that it can be specified multiple times.

Amended text and added above line as well.

@flouthoc flouthoc force-pushed the manifest-add-compression branch 2 times, most recently from 07b7e22 to 9509e1a Compare August 3, 2023 08:49
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 3, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, Luap99, vrothberg

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:
  • OWNERS [Luap99,flouthoc,vrothberg]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Adds support for --add-compression which accepts multiple compression
formats and when used it will add all instances in a manifest list with
requested compression formats.

Signed-off-by: Aditya R <[email protected]>
@flouthoc flouthoc force-pushed the manifest-add-compression branch from 9509e1a to 346f9cb Compare August 3, 2023 08:50
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2023
@vrothberg
Copy link
Member

/lgtm
/hold

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2023
@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 3, 2023

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2023
@openshift-merge-robot openshift-merge-robot merged commit bde942e into containers:main Aug 3, 2023
@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 3, 2023

cc @TomSweeneyRedHat

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Nov 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Change to remote API; merits scrutiny lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants