Skip to content

Conversation

sarveshkaushal
Copy link
Contributor

Right now copy method throws runtime error if Tar is not present in the target container. Added a check for it before proceeding with copying process.
Note: This will only work for the containers which has POSIX based underlying image

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 10, 2020
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 10, 2020
@sarveshkaushal
Copy link
Contributor Author

/assign @yue9944882

Copy link
Member

@yue9944882 yue9944882 left a comment

Choose a reason for hiding this comment

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

thanks for fixing this! i presume this makes the original function no-op when the tar is not present, which can be sometimes even more confusing for the users to troubleshoot. how do you think about declaring a checked exception like CopyNotSupportedException?

if (!f.isDirectory() && !f.mkdirs()) {
throw new IOException("create directory failed: " + f);
// Test that 'tar' is present in the container?
if (isTarPresentInContainer(namespace, pod, container)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (isTarPresentInContainer(namespace, pod, container)) {
if (!isTarPresentInContainer(namespace, pod, container)) {
// do something
}

nit: plz reverse the test for a cleaner indent?

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 was originally thinking of exception but wasn't sure of the name. I have created an exception CopyNotSupportedException in io.kubernetes.client.util.exception package. Hope that is right place for it. I have also flipped the if check. Also added the CopyNotSupportedException in respective calling methods.

Copy link
Member

@yue9944882 yue9944882 left a comment

Choose a reason for hiding this comment

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

/lgtm

@brendandburns for another review

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 11, 2020
@yue9944882 yue9944882 added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jun 11, 2020
@brendandburns
Copy link
Contributor

Thanks for the PR

Ultimately, we may want to use ephemeral containers when they become more mature.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, sarveshkaushal

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 13, 2020
@k8s-ci-robot k8s-ci-robot merged commit 4cd1cbd into kubernetes-client:master Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants