-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
new command: minikube cp
to copy files into minikube
#10198
Conversation
Hi @anencore94. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
Before coding some other feature such as 'enable -r option to copy directory', 'enable progress bar option' and the others, I want to get some reviews from you guys to check whether I am going the right way. I also wonder how to implement the test code for this. Is it ok make only functional test for scp cmd at Thanks a lot in advance! |
/assign @tstromberg |
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove TODO comments and add integration test then it will be good to do !
@anencore94 sorry for the late reply on this PR, this sounds like a good PR, lets remove the TODO notes and yes lets add an integration test to our Funcitonal Test it could be a subtest simmilar to other tests
and u can make a dummy hello world file and try to copy it using scp and validate the file was copied by
|
ae54fe2
to
5719576
Compare
245fda7
to
12fa99c
Compare
Thanks for your review @medyagh ! I added the functional test for scp cmd as your comment. Could you re-check my PR?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of shelling out to the scp
command line tool directly, let's instead copy files into minikube the way we do in other parts of the code (for things like preload, or kubernets binaries). Instead of scp:
- Create a FileAsset with the NewFileAsset function
- Using a runner, run the built in Copy() function to copy the file asset into minikube
This way anyone can copy files in, regardless of if they have scp
installed. This should also allow this command to run across all platforms, not just Linux. So, you shouldn't have to skip the functional test anymore.
Example of this in the code:
minikube/pkg/minikube/cruntime/containerd.go
Lines 350 to 357 in 6afefe6
fa, err := assets.NewFileAsset(tarballPath, targetDir, targetName, "0644") | |
if err != nil { | |
return errors.Wrap(err, "getting file asset") | |
} | |
t := time.Now() | |
if err := r.Runner.Copy(fa); err != nil { | |
return errors.Wrap(err, "copying file") | |
} |
If you need any more examples, searching for any call to asset.NewFileAsset
should get you there.
@anencore94 I agree with @priyawadhwa lets do that |
Since we're no longer using |
4da3879
to
2e1635b
Compare
@priyawadhwa I changed the implementation of scp by copy with your review comments, Thanks! I want to implement the directory copying feature with another PR. (or someone else could do this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more comments, this is almost there!
cmd/minikube/cmd/cp.go
Outdated
|
||
// cpCmd represents the cp command, similar to docker cp | ||
var cpCmd = &cobra.Command{ | ||
Use: "cp <source file path> <target file path followed by '/home/docker/'>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by this description, I thought the command would work something like:
minikube cp a.txt. /b.txt
Where does the /home/docker come in?
Additionally, we should probably insist that the second argument is an absolute path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you the prefix_path '/home/docker/' is confusing :)
By the way, when we do 'minikube ssh', the starting path is '/home/docker' since the default username is docker.
Is it ok to copy on '/somewhere' where the permission is only for 'root user' ?
I think there maybe 3 options: (or you have any idea, please let me know :) )
- minikube cp a.txt /home/docker/b.txt
- make minikube user to write '/home/docker' to see exactly where the path is.
- But, they should write the /home/docker path for every copying
- minikube cp a.txt /b.txt
- enable copy at root permissioned directory
- minikube cp a.txt b.txt
- minikube user doesn't care about the user name, but always will be at /home/docker/b.txt as what i've implemented with this version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What Option would be the best ? @priyawadhwa
In my opinion for now, option 1 or option 3 will be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should ask the user for an absolute path and try to copy to wherever they want the file copied. If it fails because the command requires sudo
, then we should provide a --force
or -f
flag which will copy over the file with root permissions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comment.
I've changed to minikube copy can copy anywhere in minikube as your opinion.
Could you re-check? @priyawadhwa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anencore94 can u plz rebase the PR (pull upstream) ?
/ok-to-test |
kvm2 Driver |
- add new feature represents cp local file into minikube - add functional test for cp command Signed-off-by: anencore94 <anencore94@kaist.ac.kr>
- only absolute path is allowed Signed-off-by: anencore94 <anencore94@kaist.ac.kr>
Thanks, I've done @medyagh |
thank you @anencore94 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anencore94, medyagh 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 |
minikube cp
to copy files into minikube
Add New Feature which represents scp command
Until now, it is possible to copy specific local file to specific path in minikube basically.
I mean 'basically' since it is possible to only file not directory.
And there are many more remaining tasks until now. (remaining problems are written in source code as
//TODO
)Fix #9930