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

Implement --archive flag for podman cp #10804

Merged
merged 1 commit into from
Jul 1, 2021

Conversation

matejvasek
Copy link
Contributor

@matejvasek matejvasek commented Jun 28, 2021

Implement --archive flag for podman cp

This PR implements for direction when a container is a destination, not a source.

resolves #10801

Signed-off-by: Matej Vasek [email protected]

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 28, 2021
@rhatdan
Copy link
Member

rhatdan commented Jun 28, 2021

You should also add the other follow-link option

-L, --follow-link Always follow symbol link in SRC_PATH

I am not sure what it does, but we need to have it implemented.

@matejvasek matejvasek force-pushed the fix-cp-sub-cmd branch 3 times, most recently from cdafa5d to 56d259c Compare June 29, 2021 00:52
ARCHIVE_TEST_ERROR="1"
fi

# TODO: uid/gid should be also preserved on way back (GET request)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is however task for another PR.

@matejvasek
Copy link
Contributor Author

You should also add the other follow-link option

-L, --follow-link Always follow symbol link in SRC_PATH

I am not sure what it does, but we need to have it implemented.

I would prefer this to be done in another PR.

@matejvasek matejvasek changed the title [WIP]Implement --archive flag for podman cp Implement --archive flag for podman cp Jun 29, 2021
@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 Jun 29, 2021
cmd/podman/containers/cp.go Outdated Show resolved Hide resolved
cmd/podman/containers/cp.go Outdated Show resolved Hide resolved
docs/source/markdown/podman-cp.1.md Outdated Show resolved Hide resolved
libpod/container_api.go Show resolved Hide resolved
pkg/domain/entities/engine_container.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 29, 2021
@vrothberg
Copy link
Member

You should also add the other follow-link option
-L, --follow-link Always follow symbol link in SRC_PATH
I am not sure what it does, but we need to have it implemented.

I would prefer this to be done in another PR.

Yes, this should be another PR.

@matejvasek matejvasek force-pushed the fix-cp-sub-cmd branch 2 times, most recently from 3d5e292 to 1b58fb6 Compare June 29, 2021 12:58
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.

Thanks! Looking like a good direction.

cmd/podman/containers/cp.go Outdated Show resolved Hide resolved
pkg/api/handlers/compat/containers_archive.go Outdated Show resolved Hide resolved
pkg/bindings/containers/archive.go Show resolved Hide resolved
pkg/domain/entities/containers.go Show resolved Hide resolved
@matejvasek matejvasek force-pushed the fix-cp-sub-cmd branch 4 times, most recently from 4c3f4e0 to 596bfaa Compare June 29, 2021 13:56
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.

I just realized it's a breaking change to the bindings.

We should be able to handle everything on the client side in cmd/podman though. Both, copier.Put and copier.Get allow for chowning. In order to get the data, I think we need to extend podman container inspect with the necessary information about the user.

The only drawback is that the libpod/archive endpoint would not chown by default anymore, which is a risk I am willing to take.

cmd/podman/containers/cp.go Outdated Show resolved Hide resolved
docs/source/markdown/podman-cp.1.md Show resolved Hide resolved
@@ -49,12 +49,17 @@ func Stat(ctx context.Context, nameOrID string, path string) (*entities.Containe
return statReport, finalErr
}

func CopyFromArchive(ctx context.Context, nameOrID string, path string, reader io.Reader) (entities.ContainerCopyFunc, error) {
func CopyFromArchive(ctx context.Context, nameOrID string, path string, reader io.Reader, options *CopyOptions) (entities.ContainerCopyFunc, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for noticing just now. This would break the bindings which is something we cannot do at the moment without having to bump Podman to 4.0.

@matejvasek
Copy link
Contributor Author

I just realized it's a breaking change to the bindings.

@vrothberg
There should be some compatibility:
User can use old podman-remote or an application compiled with old Binding lib it should work against new server.

@vrothberg
Copy link
Member

I just realized it's a breaking change to the bindings.

@vrothberg
There should be some compatibility:
User can use old podman-remote or an application compiled with old Binding lib it should work against new server.

Very fair point. Seems like we'd break one way or another :(

@baude @rhatdan WDYT?

@matejvasek
Copy link
Contributor Author

Very fair point. Seems like we'd break one way or another :(

Too bad that Go doesn't have function overloading 😞

@vrothberg
Copy link
Member

Very fair point. Seems like we'd break one way or another :(

Too bad that Go doesn't have function overloading disappointed

An alternative solution would be to add a new function to the bindings which supports the new option. Add a clear comment that this will be removed with 4.0 and should not be used by any outside user. It's a trick but sounds like a good compromise at the moment. We can move on with the work and existing (bindings) users won't suddenly break.

@matejvasek
Copy link
Contributor Author

@vrothberg @rhatdan PTAL

@matejvasek
Copy link
Contributor Author

That would work as well. Nice idea. Please make sure to drop a `// FIXME: drop variadic args with Podman 4.0`` in the code.

I thought we would keep the variadic. If they are to be deleted then I rather do original suggestion.

@vrothberg
Copy link
Member

That would work as well. Nice idea. Please make sure to drop a `// FIXME: drop variadic args with Podman 4.0`` in the code.

I thought we would keep the variadic.

Yes, for consistency with other bindings.

If they are to be deleted then I rather do original suggestion.

OK, sounds good to me. Thank you!

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 30, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matejvasek, 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

@matejvasek matejvasek force-pushed the fix-cp-sub-cmd branch 6 times, most recently from 9e7a39b to f71d271 Compare June 30, 2021 19:22
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.

Other than the naming nit: LGTM
@mheon PTAL

@rhatdan
Copy link
Member

rhatdan commented Jul 1, 2021

/lgtm
@matejvasek Could you open a PR with containers/common to add --archive as a option, so users who want the Docker defaults can change the way podman works.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 1, 2021
@rhatdan
Copy link
Member

rhatdan commented Jul 1, 2021

BTW @matejvasek nice work and thanks.

@openshift-merge-robot openshift-merge-robot merged commit 955c1d2 into containers:main Jul 1, 2021
@matejvasek
Copy link
Contributor Author

@matejvasek Could you open a PR with containers/common to add --archive as a option, so users who want the Docker defaults can change the way podman works.

to containers/common? where?

@rhatdan
Copy link
Member

rhatdan commented Jul 1, 2021

@vrothberg
Copy link
Member

To add a new field to containers.conf which, if set, would overwrite the default value of --archive.

I think it should go under the "[engine]" table. Naming is always the hardest ... "chown_copied_files"?

@rhatdan
Copy link
Member

rhatdan commented Jul 1, 2021

Yes this one will need a good description.

@ocafebabe
Copy link

@matejvasek are there still plans to implement "follow-link" (-L) like docker?

@matejvasek
Copy link
Contributor Author

@ocafebabe I haven't seen need for it so far (for my use), but feel free to submit PR.

@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 Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 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. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman cp chowns files
5 participants