-
Notifications
You must be signed in to change notification settings - Fork 336
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
fix pvc and source PVC storageclass name comparison for pvc datasource #309
Conversation
Hi @Madhu-1. Thanks for your PR. I'm waiting for a kubernetes-csi or 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. |
/assign @j-griffith |
@@ -661,9 +661,9 @@ func (p *csiProvisioner) getPVCSource(options controller.ProvisionOptions) (*csi | |||
if sourcePVC.ObjectMeta.DeletionTimestamp != nil { | |||
return nil, fmt.Errorf("the PVC DataSource %s is currently being deleted", options.PVC.Spec.DataSource.Name) | |||
} | |||
if sourcePVC.Spec.StorageClassName != options.PVC.Spec.StorageClassName { | |||
if *sourcePVC.Spec.StorageClassName != *options.PVC.Spec.StorageClassName { |
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.
Could this be nil?
Also can we add a unit test for 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.
@msau42 yes this can be nil also. updated code and added unit testing.
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.
DataSource and rquested provisioned PVC are required to be in the same storage class. Also, I'm not sure I follow, how can the sourcePVC have a "nil" storage class? Once it's provisioned it will have a storage class, even if one wasn't specified at creation, the default class would be used and the object would have a storage class assigned to it no?
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.
@j-griffith this is a kind of safety check, will it cause any issue if we do nil
check?
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.
It won't hurt at all, and might as well err on the side of caution.
/ok-to-test |
@j-griffith actually does storageclass need to be the same for cloning? From a user's perspective, you at least want the content to be cloned, but do you require that all the underlying storage properties are exactly the same (ie hdd vs sdd?) |
@msau42 , Re
We should not require properties exactly the same as dev-test clone could very well use cheaper media like hdd over it's original source's media which could be on faster media ssd. |
@j-griffith I have updated some of the test cases PTAL. |
@j-griffith I will leave it to you. As you have more information about it |
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.
Minor nits on the tests; also if you can fix the title s/comparion/comparison/ that'd be great.
pkg/controller/controller_test.go
Outdated
clientSet = fakeclientset.NewSimpleClientset(claim, pv) | ||
|
||
// Create a fake claim as our PVC DataSource | ||
claim := fakeClaim(srcName, "fake-claim-uid", "1Gi", pvName, v1.ClaimBound, &invalidSCName) |
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.
The use of "invalidSCName" here confuses things, you have a positive test (expected not to fail) where you create a DS and a new provision request using "invalidSCName" variable). That's somewhat confusing when glancing over the tests.
pkg/controller/controller_test.go
Outdated
@@ -2145,7 +2146,9 @@ func runDeleteTest(t *testing.T, k string, tc deleteTestcase) { | |||
func TestProvisionFromPVC(t *testing.T) { | |||
var requestedBytes int64 = 1000 | |||
invalidSCName := "invalid-sc" |
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.
Initially "invalidSCName" worked nicely because it was default or invalid; but if we explicitly add the SC names (which is a good idea) we should use names that aren't misleading; just like "test-sc-1" and "test-sc-2" that way it's not confusing on what we're expecting. There's actually nothing "invalid" about the sc name here (yes part of this is my original implementation, but we should fix it up here).
pkg/controller/controller_test.go
Outdated
@@ -2145,7 +2146,9 @@ func runDeleteTest(t *testing.T, k string, tc deleteTestcase) { | |||
func TestProvisionFromPVC(t *testing.T) { | |||
var requestedBytes int64 = 1000 | |||
invalidSCName := "invalid-sc" | |||
fakesc := "fake-sc" |
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.
See my note above, we should do something like "fakesc-1" and "fakesc-2" and avoid confusion and make it clear if there is a mismatch.
pkg/controller/controller_test.go
Outdated
} | ||
|
||
if tc.restoredVolSizeBig { | ||
controllerServer.EXPECT().CreateVolume(gomock.Any(), gomock.Any()).Return(nil, errors.New("source volume size is bigger than requested volume size")).Times(1) |
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 the extra space in "source volume..."
pkg/controller/controller_test.go
Outdated
// Create a fake claim as our PVC DataSource | ||
claim := fakeClaim(srcName, "fake-claim-uid", "1Gi", pvName, v1.ClaimBound, &invalidSCName) | ||
// Create a fake claim with invalid PV | ||
claimInvalidPV := fakeClaim(invalidPVC, "fake-claim-uid", "1Gi", "pv-not-present", v1.ClaimBound, &invalidSCName) |
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 should probably be "invalidClaim" instead of "claimInvalidPV"
pv := &v1.PersistentVolume{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: pvName, | ||
}, | ||
Spec: v1.PersistentVolumeSpec{ | ||
PersistentVolumeSource: v1.PersistentVolumeSource{ | ||
CSI: &v1.CSIPersistentVolumeSource{ | ||
Driver: "test-driver", | ||
Driver: driverName, |
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 missed that, thanks!
pkg/controller/controller_test.go
Outdated
volOpts: controller.ProvisionOptions{ | ||
StorageClass: &storagev1.StorageClass{ | ||
ReclaimPolicy: &deletePolicy, | ||
Parameters: map[string]string{}, | ||
}, | ||
PVName: pvName, | ||
PVName: "test-name", |
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.
Might as well use a variable for this one as well (ie replace "test-name" with a variable).
compare storage class string, instead of comparing the string address. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
@j-griffith addressed review comments, PTAL |
@j-griffith anything needed on this one? |
/approve |
@Madhu-1 Sorry, I dropped this one; looks good to me now, thanks for making those changes. |
/assign @lpabon |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: j-griffith, Madhu-1, msau42 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 |
/retest |
/unassign @lpabon |
/retest |
3 similar comments
/retest |
/retest |
/retest |
/test pull-kubernetes-csi-external-provisioner-1-13-on-kubernetes-1-13 |
Wooohooo! |
master: update release-tools + OWNERS
What type of PR is this?
This fixes the issue in storageclass name comparison for PVC creation with datasource=PersistanceVolumeClaim
/kind bug
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #308
Special notes for your reviewer:
Does this PR introduce a user-facing change?: