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

Add volumeMode checks to clone operations #410

Merged

Conversation

j-griffith
Copy link
Contributor

/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.

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 21, 2020
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 21, 2020
@@ -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" {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove debug logs

Copy link
Contributor

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

@@ -3444,6 +3597,55 @@ func TestProvisionFromPVC(t *testing.T) {
},
}

nilModePV := &v1.PersistentVolume{
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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 Show resolved Hide resolved
}

//clonePVName: "pvSrcBlockMode",
blkModePV := &v1.PersistentVolume{
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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 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.

Copy link
Contributor

@ShyamsundarR ShyamsundarR Feb 24, 2020

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.

@ShyamsundarR
Copy link
Contributor

Barring the issue discussed in this comment, which needs a separate resolution anyway, this PR is good to go, IMO.

cloneSupport: true,
expectErr: true,
},
"provision with pvc source is block request nil mode": {
Copy link
Collaborator

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?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 26, 2020
@jsafrane
Copy link
Contributor

@j-griffith, can you please rebase and rework the unit tests to the new style? It should be easier now.


}
}

Copy link
Contributor

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.
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2020
@jsafrane
Copy link
Contributor

jsafrane commented Mar 2, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2020
@k8s-ci-robot
Copy link
Contributor

[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 /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 Mar 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit efcaee7 into kubernetes-csi:master Mar 2, 2020
kbsonlong pushed a commit to kbsonlong/external-provisioner that referenced this pull request Dec 29, 2023
…go_modules/google.golang.org/grpc-1.52.3

Bump google.golang.org/grpc from 1.52.1 to 1.52.3
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants