-
Notifications
You must be signed in to change notification settings - Fork 260
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
feat: volume clone from source volume #426
feat: volume clone from source volume #426
Conversation
var volCap *csi.VolumeCapability | ||
if len(req.GetVolumeCapabilities()) > 0 { | ||
volCap = req.GetVolumeCapabilities()[0] | ||
} |
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 am not sure if req capabilities apply for both src and dst volume internal mounting. I took this from here:
csi-driver-nfs/pkg/nfs/controllerserver.go
Lines 120 to 123 in 5edf03c
var volCap *csi.VolumeCapability | |
if len(req.GetVolumeCapabilities()) > 0 { | |
volCap = req.GetVolumeCapabilities()[0] | |
} |
75ab0ff
to
52620bf
Compare
Pull Request Test Coverage Report for Build 4417866944
💛 - Coveralls |
52620bf
to
96c3078
Compare
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.
this PR lgtm, could you also write an e2e test for volume cloning, you could refer to https://github.com/kubernetes-sigs/azuredisk-csi-driver/blob/master/test/e2e/dynamic_provisioning_test.go#L539-L570
there is an easier way to add volume cloning test, just add csi-driver-nfs/test/external-e2e/testdriver.yaml Lines 9 to 14 in af29ce4
|
96c3078
to
88b7cda
Compare
88b7cda
to
61a6301
Compare
/retest maybe someone else should trigger @k8s-ci-robot, all of these tests currently fail with
|
/retest |
/ok-to-test |
/retest |
/retest |
the failure in
the for
seems unrelated, maybe debian package name changed? I will take a look |
@wozniakjan: The
Use In response to this:
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. |
/test pull-csi-driver-nfs-integration this seems to work just fine, another transient glitch in the matrix?
|
sanity test is failing in clone volume test:
|
pkg/nfs/controllerserver.go
Outdated
|
||
// recursive 'cp' with '-a' to handle symlinks. Note that the source path must include trailing '/.', | ||
// which is the reason why 'filepath.Join()' is not used as it would perform path cleaning | ||
out, err := exec.Command("cp", "-a", fmt.Sprintf("%v%v.", srcPath, filepath.Separator), dstPath).CombinedOutput() |
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.
per the sanity test failure,
controllerserver.go:351] copied /tmp/sanity-controller-source-vol-1BFA11DF-89190C95/sanity-controller-source-vol-1BFA11DF-89190C95 -> /tmp/sanity-controller-vol-from-vol-1BFA11DF-89190C95/sanity-controller-vol-from-vol-1BFA11DF-89190C95 output: cp: cannot stat '/tmp/sanity-controller-source-vol-1BFA11DF-89190C95/sanity-controller-source-vol-1BFA11DF-89190C9547.': No such file or directory
it should be cp -a /tmp/sanity-controller-source-vol-1BFA11DF-89190C95/* /tmp/sanity-controller-vol-from-vol-1BFA11DF-89190C95/
?
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 it is expected given the implementation of getInternalVolumePath()
because volume has a subdir
I0314 09:08:26.078270 7781 utils.go:95] GRPC response: {"volume":{"volume_context":{"server":"127.0.0.1","share":"/","subdir":"sanity-controller-source-vol-1BFA11DF-89190C95"},"volume_id":"127.0.0.1##sanity-controller-source-vol-1BFA11DF-89190C95#"}}
csi-driver-nfs/pkg/nfs/controllerserver.go
Lines 367 to 374 in af29ce4
// Get internal path where the volume is created | |
// The reason why the internal path is "workingDir/subDir/subDir" is because: | |
// - the semantic is actually "workingDir/volId/subDir" and volId == subDir. | |
// - we need a mount directory per volId because you can have multiple | |
// CreateVolume calls in parallel and they may use the same underlying share. | |
// Instead of refcounting how many CreateVolume calls are using the same | |
// share, it's simpler to just do a mount per request. | |
func getInternalVolumePath(workingMountDir string, vol *nfsVolume) string { |
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.
actually, I think I see it now
I0314 09:08:26.178668 7781 controllerserver.go:351] copied /tmp/sanity-controller-source-vol-1BFA11DF-89190C95/sanity-controller-source-vol-1BFA11DF-89190C95 -> /tmp/sanity-controller-vol-from-vol-1BFA11DF-89190C95/sanity-controller-vol-from-vol-1BFA11DF-89190C95 output: cp: cannot stat '/tmp/sanity-controller-source-vol-1BFA11DF-89190C95/sanity-controller-source-vol-1BFA11DF-89190C9547.': No such file or directory
there should not be any path terminated with just .
, only /.
,
FROM TEST: /tmp/sanity-controller-source-vol-1BFA11DF-89190C95/sanity-controller-source-vol-1BFA11DF-89190C9547.
EXP SRC: /tmp/sanity-controller-source-vol-1BFA11DF-89190C95/sanity-controller-source-vol-1BFA11DF-89190C9547/.
EXP DST: /tmp/sanity-controller-source-vol-1BFA11DF-89190C95/sanity-controller-source-vol-1BFA11DF-89190C9547
looks like filepath.Separator
was an empty string?
trying hardcoded trailing /.
for src path and slightly improved the logging in 784da6f
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.
tests are passing now, looks like using /
instead of filepath.Separator
did the trick.
@andyzhangx I am not sure if that is a big issue for portability. Technically using cp
imho already restricts this to run with the expectation of POSIX file paths. Supporting POSIX and windows separator may not have much of an impact from the OS portability point of view.
910ee3c
to
784da6f
Compare
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.
/lgtm
thanks for the contribution!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, wozniakjan 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR introduces a first step towards supporting snapshots - volume cloning from other volumes. It's implemented as outlined in #30 (comment), and it is just an invocation of
cp -a [src]/. [dst]
to recursively copy the content of the source volume to the destination volume and adequately treat soft and hard links.I would like to first get a consensus on the design decisions and then I can follow up with snapshots and volume copy from snapshots.
Which issue(s) this PR fixes:
first step towards implementing #31
Special notes for your reviewer:
Does this PR introduce a user-facing change?: