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

podman-remote cp, varlink API CopyTo &CopyFrom #3568

Closed
wants to merge 1 commit into from

Conversation

QiWang19
Copy link
Contributor

@QiWang19 QiWang19 commented Jul 12, 2019

Implemented podman-remote cp adding varlink API CopyTo & CopyFrom
close #4207
Copy inside remote machine

// source file: from remote container
// destination: remote file system
$ bin/podman-remote cp  adc8:/ctrfile local:/home/qiwang/Documents/file
// source file:  from remote machine
// destination:  remote container
$ bin/podman-remote cp local:/home/qiwang/Documents/f.txt adc8:/f26

Copy between local and remote container

// source file: local file system
// destination:  remote container
$ bin/podman-remote cp remote:/home/qiwan/Documents/f.txt adc8:/ctrfile
// source file: from remote container
// destination: local file system
$ bin/podman-remote cp  adc8:/ctrfile remote:/home/qiwan/Documents/file

Varlink API

// Copy file ctrf from containrt de3f to /home/qiwan/Documents/ctrfile
$ sudo varlink call -m unix:/run/podman/io.podman/io.podman.CopyFrom '{"dest": "local", "srcPath": "/ctrf", "srcfMode": 0600, "destPath": "/home/qiwan/Documents/ctrfile", "extract": false, "pause": true, "ctrNameorId": "de3f"}'
{
  "path": [
    "/home/qiwan/Documents/ctrfile"
  ]
}
// Copy and extract /home/qiwan/Documents/f1.tar to container de3f
$ sudo varlink call -m unix:/run/podman/io.podman/io.podman.CopyTo '{"src": "local", "srcPath": "/home/qiwan/Documents/f1.tar", "srcfMode":0600, "destPath": "/archivef", "extract":true, "pause": true, "ctrNameorId": "de3f"}'
{
  "path": "/var/lib/containers/storage/overlay/e451e85006f6215f805b33257b2bea8dad60ab390af758060af0587f345bdfb2/merged/archivef"
}

Signed-off-by: Qi Wang qiwan@redhat.com

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: QiWang19
To complete the pull request process, please assign mrunalp
You can assign the PR to them by writing /assign @mrunalp in a comment when ready.

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

@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 12, 2019
@QiWang19
Copy link
Contributor Author

@jwhonce
Does this satisfy the requirements https://jira.coreos.com/browse/RUN-351?
changed the return value of CopyFrom and CopyTo from file size to file path in order to locate file when podman-remote cp.

pkg/varlinkapi/transfers.go Outdated Show resolved Hide resolved
@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #3531) made this pull request unmergeable. Please resolve the merge conflicts.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 16, 2019
Copy link
Member

@jwhonce jwhonce left a comment

Choose a reason for hiding this comment

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

A lot of debug and error msg that don't appear to have context when run on a system with multiple users.

I believe this covers the requirements. /cc @baude

pkg/adapter/containers.go Show resolved Hide resolved
pkg/adapter/containers.go Show resolved Hide resolved
if strings.HasSuffix(dest, "/") {
destPath = fmt.Sprintf("%s/", destPath)
}
reply, err := iopodman.CopyTo().Send(r.Conn, varlink.Upgrade, location, srcPath, 0600, destPath, extract, pause, ctr.ID())
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't mode match Src file vs. hard coded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the source file is from the remote file system this augument is not useful under this situation.

}
reply, err := iopodman.CopyTo().Send(r.Conn, varlink.Upgrade, location, srcPath, 0600, destPath, extract, pause, ctr.ID())
if err != nil {
return errors.Wrapf(err, "varlink call CopyTo error")
Copy link
Member

Choose a reason for hiding this comment

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

Does err have context to what happened?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

return nil
}

err := r.CopyToContainer(src, dest, srcPath, destPath, extract, pause, ctr)
Copy link
Member

Choose a reason for hiding this comment

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

No mode?

pkg/adapter/containers_remote.go Show resolved Hide resolved
}

// untar tempFile under os.TempDir() if the source is a file and not archive
tempTarball, err := os.Open(srcFilePath)
Copy link
Member

Choose a reason for hiding this comment

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

Does the tarball carry the modes for the source files and directory path? If so that could clean up the API a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. I'll check. But the mode argument is only useful when using CopyTo() to copy to remote. It is not useful in the CopyFrom or the varlink call

cmd/podman/varlink/io.podman.varlink Show resolved Hide resolved
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 24, 2019
@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #3767) made this pull request unmergeable. Please resolve the merge conflicts.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2019
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 29, 2019
@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #4001) made this pull request unmergeable. Please resolve the merge conflicts.

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #4165) made this pull request unmergeable. Please resolve the merge conflicts.

@QiWang19 QiWang19 force-pushed the copyto branch 3 times, most recently from cbe485d to bc0799e Compare October 9, 2019 19:56
@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #4197) made this pull request unmergeable. Please resolve the merge conflicts.

@QiWang19 QiWang19 force-pushed the copyto branch 3 times, most recently from a349a6b to 33fb8e8 Compare October 11, 2019 15:52
@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #4220) made this pull request unmergeable. Please resolve the merge conflicts.

@QiWang19 QiWang19 force-pushed the copyto branch 5 times, most recently from 0e60d46 to 911d8e6 Compare October 14, 2019 14:44
@QiWang19
Copy link
Contributor Author

@jwhonce cleaned the reviews and rebased. PTAL?

Copy link
Member

@jwhonce jwhonce left a comment

Choose a reason for hiding this comment

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

There is currently a lot of duplication, but knowing we're going to refactor this code to run as the container in the future We can live with it.

"github.com/containers/storage/pkg/idtools"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1" // "github.com/opencontainers/image-spec/specs-go/v1"
Copy link
Member

Choose a reason for hiding this comment

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

Why add the comment?

}

// ParsePath parses the input of cp command returns the path and the container
func (r *LocalRuntime) ParsePath(path string) (*Container, string) {
Copy link
Member

Choose a reason for hiding this comment

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

If you move this code to pkg/util/utils.go you won't need to duplicate it between local and remote.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there will be an import circle cmd/podman imports adapter, adapter imports util, util imports adapter. Because ParsePath needs adapter.Runtime to check the input container. Can I get rid of this circle?

@@ -17,7 +17,7 @@ The container command allows you to manage containers
| checkpoint | [podman-container-checkpoint(1)](podman-container-checkpoint.1.md) | Checkpoints one or more running containers. |
| cleanup | [podman-container-cleanup(1)](podman-container-cleanup.1.md) | Cleanup the container's network and mountpoints. |
| commit | [podman-commit(1)](podman-commit.1.md) | Create new image based on the changed container. |
| cp | [podman-cp(1)](podman-cp.1.md) | Copy files/folders between a container and the local filesystem. |
| cp | [podman-cp(1)](podman-cp.1.md) | Copy files/folders between a container and the local filesystem |
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the period?

Implemented podman-remote cp adding varlink API CopyTo & CopyFrom

Copy  inside remote machine

```
// source file: from remote container
// destination: remote file system
$ bin/podman-remote cp  adc8:/ctrfile local:/home/qiwang/Documents/file
```

```
// source file: from remote container
// destination: local file system
$ bin/podman-remote cp  adc8:/ctrfile remote:/home/qiwan/Documents/file
```

Copy between local and remote container

```
// source file: local file system
// destination:  remote container
$ bin/podman-remote cp remote:/home/qiwan/Documents/f.txt adc8:/ctrfile
```

```
// source file:  from remote machine
// destination:  remote container
$ bin/podman-remote cp local:/home/qiwang/Documents/f.txt adc8:/f26
```

Varlink API

```
// Copy file ctrf from containrt de3f to /home/qiwan/Documents/ctrfile
$ sudo varlink call -m unix:/run/podman/io.podman/io.podman.CopyFrom '{"dest": "local", "srcPath": "/ctrf", "srcfMode": 0600, "destPath": "/home/qiwan/Documents/ctrfile", "extract": false, "pause": true, "ctrNameorId": "de3f"}'
{
  "path": [
    "/home/qiwan/Documents/ctrfile"
  ]
}
```

```
// Copy and extract /home/qiwan/Documents/f1.tar to container de3f
$ sudo varlink call -m unix:/run/podman/io.podman/io.podman.CopyTo '{"src": "local", "srcPath": "/home/qiwan/Documents/f1.tar", "srcfMode":0600, "destPath": "/archivef", "extract":true, "pause": true, "ctrNameorId": "de3f"}'
{
  "path": "/var/lib/containers/storage/overlay/e451e85006f6215f805b33257b2bea8dad60ab390af758060af0587f345bdfb2/merged/archivef"
}
```

Signed-off-by: Qi Wang <qiwan@redhat.com>
@QiWang19
Copy link
Contributor Author

There is currently a lot of duplication, but knowing we're going to refactor this code to run as the container in the future We can live with it.

you mean I should refactor my PR now or the whole podman-remote code will be refactored and I need to refactor my PR after that?

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #4310) made this pull request unmergeable. Please resolve the merge conflicts.

@github-actions
Copy link

This pull request had no activity for 30 days. In the absence of activity or the "do-not-close" label, the pull request will be automatically closed within 7 days.

@openshift-ci-robot
Copy link
Collaborator

@QiWang19: PR needs rebase.

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.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 29, 2019
@rhatdan
Copy link
Member

rhatdan commented Nov 29, 2019

@QiWang19 Needs a rebase.

@rhatdan rhatdan removed the stale-pr label Nov 29, 2019
@github-actions
Copy link

This pull request had no activity for 30 days. In the absence of activity or the "do-not-close" label, the pull request will be automatically closed within 7 days.

@QiWang19 QiWang19 closed this Feb 5, 2020
@QiWang19 QiWang19 deleted the copyto branch June 26, 2020 15:10
@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 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
do-not-close locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. stale-pr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support "podman-remote cp"
6 participants