-
Notifications
You must be signed in to change notification settings - Fork 324
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
Add volumeMode checks to clone operations #410
Add volumeMode checks to clone operations #410
Conversation
pkg/controller/controller.go
Outdated
@@ -819,6 +819,23 @@ func (p *csiProvisioner) getPVCSource(options controller.ProvisionOptions) (*csi | |||
return nil, fmt.Errorf("claim in dataSource not bound or invalid") | |||
} | |||
|
|||
if options.PVC.Spec.VolumeName == "my-block-pvc" { |
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.
remove debug logs
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.
Resolved by the latest update
pkg/controller/controller_test.go
Outdated
@@ -3444,6 +3597,55 @@ func TestProvisionFromPVC(t *testing.T) { | |||
}, | |||
} | |||
|
|||
nilModePV := &v1.PersistentVolume{ |
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.
nilModePV
is the same as pv
above, and pv
can be reused instead.
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.
Yeah, I'll go through these again and verify the modes again; thanks.
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.
Resolved by the latest update
pkg/controller/controller_test.go
Outdated
} | ||
|
||
//clonePVName: "pvSrcBlockMode", | ||
blkModePV := &v1.PersistentVolume{ |
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.
(nit) blkModePV
can be instead defined as,
blkModePV := pv.DeepCopy()
blkModePV.Name = pvSrcBlockMode
blkModePV.Spec.VolumeMode = &volumeModeBlock
And corresponding test cases can be updated to reflect tc.clonePVName
as pvSrcBlockMode
This also removes the need to add blockModeClaim
below.
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 noticed some bad behavior in the tests (that I didn't track down). It seems that we're missing cleanup steps in the tests and the result of trying to do something like you suggest above is things like invalid claims, and unexpected status on PVs. I'll take a look again, maybe it was something else I had incorrect, or maybe I can more easily identify the problem. Using debug statements in the catches though, I did notice that our tests don't always fail for the reasons we're expecting them to (sort of a problem), we set expectErr: true
and let it rip, but it's not always failing for what we expect.
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 open an issue against the tests, and not necessarily failing for what we expect. I verified this when trying to copy the pv object into a block object, I suspect we might be doing this in other places.
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, there were a few flakes and incorrect errors, I have put up this PR as an initial cleanup for the tests. It does not ensure the errors are what is expected as per each test case though.
52382af
to
552ea88
Compare
Barring the issue discussed in this comment, which needs a separate resolution anyway, this PR is good to go, IMO. |
pkg/controller/controller_test.go
Outdated
cloneSupport: true, | ||
expectErr: true, | ||
}, | ||
"provision with pvc source is block request nil mode": { |
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.
Can you also add more positive and negative test cases with nil mode?
@j-griffith, can you please rebase and rework the unit tests to the new style? It should be easier now. |
|
||
} | ||
} | ||
|
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.
These checks look good to me.
This PR add checks against the volume mode between source and newly created clone of a pvc. If the source PVC does not match the requested volume mode of the newly created clone the create operation will fail.
552ea88
to
08252d6
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: j-griffith, jsafrane 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 |
…go_modules/google.golang.org/grpc-1.52.3 Bump google.golang.org/grpc from 1.52.1 to 1.52.3
/kind cleanup
What this PR does / why we need it:
This PR add checks against the volume mode between source and newly created
clone of a pvc. If the source PVC does not match the requested volume mode of
the newly created clone the create operation will fail.