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

RHEL-14922: accept a config blob alongside the "changes" slice when committing #20657

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

nalind
Copy link
Member

@nalind nalind commented Nov 10, 2023

Does this PR introduce a user-facing change?

`podman container commit` now features a `--config` option which accepts a filename containing a JSON-encoded container configuration to be merged in to the newly-created image.

Fixes #13770.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note labels Nov 10, 2023
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Nov 10, 2023
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.

just some drive by comments

@@ -29,6 +29,7 @@ type LogOptions struct {
type CommitOptions struct {
Author *string
Changes []string
Config []byte
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 accepts an io.Reader here instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Had to make it a *io.Reader to make the generator happy.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think the generator could use some improvements, IMO a pointer to a interface makes things harder to use and more likely to cause nil derefs.
Anyway this shouldn't really block your work.

@@ -164,6 +164,7 @@ type ContainerStatReport struct {
type CommitOptions struct {
Author string
Changes []string
Config []byte
Copy link
Member

Choose a reason for hiding this comment

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

also io.Reader here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Had to make it a *io.Reader to make the generator happy.

Comment on lines 37 to 39
if config := params.Get("config"); config != "" {
requestBody = strings.NewReader(config)
params.Del("config")
}
Copy link
Member

Choose a reason for hiding this comment

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

you can add schema:"-" to the type then it will not be added via ToParams()

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, thanks, I wouldn't have guessed that.

pkg/api/handlers/libpod/images.go Show resolved Hide resolved
@nalind nalind force-pushed the commit-config branch 4 times, most recently from 88dcb4f to 130fe7f Compare November 17, 2023 20:00
@nalind
Copy link
Member Author

nalind commented Nov 17, 2023

/override Build Each Commit

Copy link
Contributor

openshift-ci bot commented Nov 17, 2023

@nalind: /override requires failed status contexts, check run or a prowjob name to operate on.
The following unknown contexts/checkruns were given:

  • Build
  • Commit
  • Each

Only the following failed contexts/checkruns were expected:

  • Artifacts
  • Build Each Commit
  • Total Success
  • Verify Win Installer Build
  • machine-hyperv podman windows rootless host sqlite
  • machine-wsl podman windows rootless host sqlite
  • tide

If you are trying to override a checkrun that has a space in it, you must put a double quote on the context.

In response to this:

/override Build Each Commit

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.

@nalind
Copy link
Member Author

nalind commented Nov 17, 2023

/override "Build Each Commit"
... because the vendoring commit isn't going to be in the final version of this PR.

Copy link
Contributor

openshift-ci bot commented Nov 17, 2023

@nalind: Overrode contexts on behalf of nalind: Build Each Commit

In response to this:

/override "Build Each Commit"
... because the vendoring commit isn't going to be in the final version of this 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.

@nalind nalind force-pushed the commit-config branch 2 times, most recently from a011559 to 8b7478b Compare November 17, 2023 23:04
@nalind
Copy link
Member Author

nalind commented Nov 18, 2023

/retitle RHEL-14922: accept a config blob alongside the "changes" slice when committing

@openshift-ci openshift-ci bot changed the title WIP: RHEL-14922: accept a config blob alongside the "changes" slice when committing RHEL-14922: accept a config blob alongside the "changes" slice when committing Nov 18, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 18, 2023
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2023
@@ -164,6 +164,7 @@ type ContainerStatReport struct {
type CommitOptions struct {
Author string
Changes []string
Config io.Reader
Copy link
Member

Choose a reason for hiding this comment

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

This struct is used for the REST API as well - will this break given that io.Reader can't really be serialized over the network?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it back to a []byte.

@nalind nalind force-pushed the commit-config branch 4 times, most recently from 77c513a to 08c51ea Compare November 28, 2023 16:31
Copy link

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

@rhatdan
Copy link
Member

rhatdan commented Nov 29, 2023

LGTM
@mheon @vrothberg PTAL

@@ -36,6 +36,11 @@ Apply the following possible instructions to the created image:

Can be set multiple times.

#### **--config**=*ConfigBlobFile*

Merge the JSON-encoded container configuration from the specified file into the configuration for the image
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 point users to a specification of the configuration?

Copy link
Member Author

@nalind nalind Nov 29, 2023

Choose a reason for hiding this comment

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

It varies between OCI and Docker image formats. I don't think there's a stable location to point to for the Docker config blob format (the engine API documentation is close, but it includes the API version number) , and the OCI version is missing some interesting fields. If it wasn't being exercised in tests that I'm about to add, I could pretty easily be talked into dropping the option.
Actually, maybe even after I add the tests to the PR....

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, as written, it's a JSON-encoded copy of the structure defined at https://github.com/containers/image/blob/main/manifest/docker_schema2.go#L67. Would a pointer to that be useful enough to someone who hasn't spent time staring at that code at some point already?

Copy link
Member

Choose a reason for hiding this comment

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

Great idea, thanks @nalind

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, added. Pointed at the currently-newest tag instead of main in case the line number changes.

@nalind nalind force-pushed the commit-config branch 2 times, most recently from bd40243 to 7289285 Compare November 29, 2023 19:11
…tting

Use ParseUserNamespace instead of ParseNamespace to parse a passed-in
user namespace setting.

Signed-off-by: Nalin Dahyabhai <[email protected]>
When committing containers to create new images, accept a container
config blob being passed in the body of the API request by adding a
Config field to our API structures.  Populate it from the body of
requests that we receive, and use its contents as the body of requests
that we make.

Make the libpod commit endpoint split changes values at newlines, just
like the compat endpoint does.

Pass both the config blob and the "changes" slice to buildah's Commit()
API, so that it can handle cases where they overlap or conflict.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@nalind
Copy link
Member Author

nalind commented Nov 30, 2023

Changed a line in the description of the -v flag for build to match what buildah's doc says about it, which I think removes a bit of ambiguity.

Be specific that the `-v` flag only affects RUN instructions.  The
previous wording left it ambiguous, and people might have concluded that
it applied to ADD and COPY as well.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Dec 1, 2023

/approve
/lgtm

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

openshift-ci bot commented Dec 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nalind, rhatdan

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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2023
@openshift-merge-bot openshift-merge-bot bot merged commit c479628 into containers:main Dec 1, 2023
93 checks passed
@nalind nalind deleted the commit-config branch December 1, 2023 21:11
@nalind
Copy link
Member Author

nalind commented Feb 7, 2024

/cherry-pick v4.9.1-rhel

@openshift-cherrypick-robot
Copy link
Collaborator

@nalind: new pull request created: #21547

In response to this:

/cherry-pick v4.9.1-rhel

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.

@nalind
Copy link
Member Author

nalind commented Feb 7, 2024

/cherry-pick v4.9

@openshift-cherrypick-robot
Copy link
Collaborator

@nalind: new pull request created: #21549

In response to this:

/cherry-pick v4.9

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.

@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label May 8, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 8, 2024
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.

Docker APIv2 /commit ignores uploaded config
7 participants