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

Make fstype configurable in external provisioner #400

Merged
merged 3 commits into from Jun 17, 2020

Conversation

humblec
Copy link
Contributor

@humblec humblec commented Feb 4, 2020

At present the fstype is set to ext4 if nothing is passed in storage-class.
However a SP could prefer to have different fstype for many reasons for their
driver/volumes. This patch enables SP who is using the external-provisioner
to choose the fstype which they want to have it.

Fix# #328

Signed-off-by: Humble Chirammal hchiramm@redhat.com

/kind bug

What this PR does / why we need it:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

ACTION REQUIRED: The fstype on provisioned PVs no longer defaults to "ext4". A `defaultFStype` arg is added to the provisioner. Admins can also specify this `fstype` via storage class parameter. If `fstype` is set in storage class parameter, it will be used. The sidecar arg is only checked if fstype is not set in the SC param.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 4, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @humblec. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 4, 2020
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 4, 2020
@humblec
Copy link
Contributor Author

humblec commented Feb 4, 2020

@jsafrane @msau42 ptal .

@humblec
Copy link
Contributor Author

humblec commented Feb 4, 2020

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 4, 2020
@humblec
Copy link
Contributor Author

humblec commented Feb 4, 2020

/assign @jsafrane
/assign @msau42

@humblec
Copy link
Contributor Author

humblec commented Feb 4, 2020

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@humblec: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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.

@jsafrane
Copy link
Contributor

jsafrane commented Feb 5, 2020

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 5, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 17, 2020
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 18, 2020
@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 27, 2020
@xing-yang
Copy link
Contributor

/lgtm

@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
cmd/csi-provisioner/csi-provisioner.go Outdated Show resolved Hide resolved
@@ -518,8 +519,8 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
if fsTypesFound > 1 {
return nil, controller.ProvisioningFinished, fmt.Errorf("fstype specified in parameters with both \"fstype\" and \"%s\" keys", prefixedFsTypeKey)
}
if len(fsType) == 0 {
fsType = defaultFSType
if fsType == "" && p.defaultFSType != "" {
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 add unit tests that test the various combinations?

  • StorageClass set + default set
  • StorageClass unset + default set
  • StorageClass set + default unset
  • StorageClass unset + default unset

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the test cases ! ..

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed 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. labels Jun 14, 2020
@humblec
Copy link
Contributor Author

humblec commented Jun 14, 2020

/retest

@humblec
Copy link
Contributor Author

humblec commented Jun 14, 2020

The newly added test TestFSTypeProvision pass:


/usr/local/go/bin/go test -timeout 30s github.com/kubernetes-csi/external-provisioner/pkg/controller -run ^(TestFSTypeProvision)$

ok  	github.com/kubernetes-csi/external-provisioner/pkg/controller	(cached)

Even when I run individual test on TestProvision it pass:

 /usr/local/go/bin/go test -timeout 30s github.com/kubernetes-csi/external-provisioner/pkg/controller -run ^(TestProvision)$

ok  	github.com/kubernetes-csi/external-provisioner/pkg/controller

But when I run the controller package level test it fails: The failure says CSIPersistentVolumeSource is nil where it expected to have ext4 in the CSI PV source based on existing tests.

 --- FAIL: TestProvision (0.08s)
    controller_test.go:1828: Running test: provision with any volume data source
    controller_test.go:1828: Running test: provision with default secrets
    controller_test.go:1921: test "provision with default secrets": expected PV: &CSIPersistentVolumeSource{Driver:test-driver,VolumeHandle:test-volume-id,ReadOnly:false,FSType:ext4,VolumeAttributes:map[string]string{storage.kubernetes.io/csiProvisionerIdentity: test-provisioner,},ControllerPublishSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},NodeStageSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},NodePublishSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},ControllerExpandSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},}, got: &CSIPersistentVolumeSource{Driver:test-driver,VolumeHandle:test-volume-id,ReadOnly:false,FSType:,VolumeAttributes:map[string]string{storage.kubernetes.io/csiProvisionerIdentity: test-provisioner,},ControllerPublishSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},NodeStageSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},NodePublishSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},ControllerExpandSecretRef:&SecretReference{Name:default-secret,Namespace:default-ns,},}
    controller_test.go:1828: Running test: provision with volume mode(Filesystem)
    controller_test.go:1921: test "provision with volume mode(Filesystem)": expected PV: &CSIPersistentVolumeSource{Driver:test-driver,VolumeHandle:test-volume-id,ReadOnly:false,FSType:ext4,VolumeAttributes:map[string]string{storage.kubernetes.io/csiProvisionerIdentity: test-provisioner,},ControllerPublishSecretRef:nil,NodeStageSecretRef:nil,NodePublishSecretRef:nil,ControllerExpandSecretRef:nil,}, got: &CSIPersistentVolumeSource{Driver:test-driver,VolumeHandle:test-volume-id,ReadOnly:false,FSType:,VolumeAttributes:map[string]string{storage.kubernetes.io/csiProvisionerIdentity: test-provisioner,},ControllerPublishSecretRef:nil,NodeStageSecretRef:nil,NodePublishSecretRef:nil,ControllerExpandSecretRef:nil,} 

@humblec
Copy link
Contributor Author

humblec commented Jun 15, 2020

@msau42 @jsafrane @xing-yang any thoughts on why few of the existing tests ( For ex: TestProvision) are failing randomly when package-level test is triggered ?

There are 4 combinations added here:

    StorageClass set + default set
    StorageClass unset + default set
    StorageClass set + default unset
    StorageClass unset + default unset

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
@humblec
Copy link
Contributor Author

humblec commented Jun 17, 2020

@msau42 I believe this is good to go in!

}

if tc.expectedPVSpec != nil {
if pv.Name != tc.expectedPVSpec.Name {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the test logic would be cleaner if we did a deepequal of the entire pv spec, instead of matching individual fields one by one. But we can consider cleaning that up separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will do that in a follow-up PR. There are some more places it need to be done in this file anyway.

@msau42
Copy link
Collaborator

msau42 commented Jun 17, 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 Jun 17, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: humblec, 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 /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 17, 2020
@k8s-ci-robot k8s-ci-robot merged commit c1de898 into kubernetes-csi:master Jun 17, 2020
K8s 1.19 automation moved this from In progress to Done Jun 17, 2020
@k8s-ci-robot k8s-ci-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jul 31, 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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
No open projects
K8s 1.19
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

8 participants