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

API changes to support migration of inline in-tree volumes to CSI #77703

Merged
merged 3 commits into from
May 31, 2019
Merged

API changes to support migration of inline in-tree volumes to CSI #77703

merged 3 commits into from
May 31, 2019

Conversation

ddebroy
Copy link
Member

@ddebroy ddebroy commented May 9, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
This PR brings in the API changes needed to support migration of inline in-tree volumes to CSI. It introduces a new field InlineVolumeSpec *v1.PersistentVolumeSpec in VolumeAttachmentSource.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
Supersedes https://github.com/kubernetes/kubernetes/pull/77364/files

Design (referred from KEP): https://github.com/kubernetes/community/blob/master/contributors/design-proposals/storage/csi-migration.md#in-line-volumes

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 9, 2019
@ddebroy
Copy link
Member Author

ddebroy commented May 9, 2019

/sig storage
/cc @davidz627 @msau42 @leakingtapan

@k8s-ci-robot k8s-ci-robot added the sig/storage Categorizes an issue or PR as relevant to SIG Storage. label May 9, 2019
@davidz627
Copy link
Contributor

/assign @davidz627 @liggitt @msau42
/label api-review

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label May 9, 2019
@davidz627
Copy link
Contributor

/priority important-critical
/kind feature

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 9, 2019
@davidz627
Copy link
Contributor

/remove-priority critical-urgent
/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. labels May 9, 2019
pkg/apis/storage/types.go Outdated Show resolved Hide resolved
pkg/apis/storage/validation/validation.go Outdated Show resolved Hide resolved
pkg/apis/storage/validation/validation.go Show resolved Hide resolved
@ddebroy
Copy link
Member Author

ddebroy commented May 10, 2019

/retest

@ddebroy
Copy link
Member Author

ddebroy commented May 29, 2019

/retest

1 similar comment
@davidz627
Copy link
Contributor

/retest

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@dstrebel
Copy link
Contributor

Hello! We are starting Code Freeze for 1.15. Is this PR still planned to be included in 1.15?

@liggitt
Copy link
Member

liggitt commented May 30, 2019

yes

/retest

@ddebroy
Copy link
Member Author

ddebroy commented May 30, 2019

/test pull-kubernetes-kubemark-e2e-gce-big

@ddebroy
Copy link
Member Author

ddebroy commented May 30, 2019

So looks like while this PR was making it's way through, the Azure file CSI translator also landed in master. Will reconcile the changes here with the required interface in Azure file and resubmit

I0530 06:49:56.791] /bazel-scratch/.cache/bazel/_bazel_prow/48d5366022b4e3197674c8d6e2bee219/sandbox/linux-sandbox/1591/execroot/io_k8s_kubernetes/staging/src/k8s.io/csi-translation-lib/plugins/azure_disk.go:45:5: cannot use &azureDiskCSITranslator literal (type *azureDiskCSITranslator) as type InTreePlugin in assignment:
I0530 06:49:56.792] *azureDiskCSITranslator does not implement InTreePlugin (missing CanSupportInline method)
I0530 06:49:56.793] /bazel-scratch/.cache/bazel/_bazel_prow/48d5366022b4e3197674c8d6e2bee219/sandbox/linux-sandbox/1591/execroot/io_k8s_kubernetes/staging/src/k8s.io/csi-translation-lib/plugins/azure_disk.go:53:9: cannot use &azureDiskCSITranslator literal (type *azureDiskCSITranslator) as type InTreePlugin in return argument:
I0530 06:49:56.793] *azureDiskCSITranslator does not implement InTreePlugin (missing CanSupportInline method)
I0530 06:49:56.794] /bazel-scratch/.cache/bazel/_bazel_prow/48d5366022b4e3197674c8d6e2bee219/sandbox/linux-sandbox/1591/execroot/io_k8s_kubernetes/staging/src/k8s.io/csi-translation-lib/plugins/azure_file.go:40:5: cannot use &azureFileCSITranslator literal (type *azureFileCSITranslator) as type InTreePlugin in assignment:
I0530 06:49:56.794] *azureFileCSITranslator does not implement InTreePlugin (missing CanSupportInline method)
I0530 06:49:56.796] /bazel-scratch/.cache/bazel/_bazel_prow/48d5366022b4e3197674c8d6e2bee219/sandbox/linux-sandbox/1591/execroot/io_k8s_kubernetes/staging/src/k8s.io/csi-translation-lib/plugins/azure_file.go:48:9: cannot use &azureFileCSITranslator literal (type *azureFileCSITranslator) as type InTreePlugin in return argument:
I0530 06:49:56.796] *azureFileCSITranslator does not implement InTreePlugin (missing CanSupportInline method)

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 30, 2019
@ddebroy
Copy link
Member Author

ddebroy commented May 30, 2019

@dstrebel please note that this PR was approved and LGTMed before code freeze. However as it was going through the testing as part of final merge to master, a new PR landed in master that added AzureFile and AzureDisk support for CSI translation and those two plugins needed to be enhanced to add inline volume support interfaces.

So this PR now needed to be updated to enhance AzureFile and AzureDisk with the CSI translation support for inline volumes to resolve the build failures detected during the second round testing before merging to master: #77703 (comment)

@ddebroy
Copy link
Member Author

ddebroy commented May 30, 2019

/cc @andyzhangx

Copy link
Member

@andyzhangx andyzhangx left a comment

Choose a reason for hiding this comment

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

/lgtm
LGTM for azure part, thanks

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 30, 2019
@ddebroy
Copy link
Member Author

ddebroy commented May 30, 2019

/retest

},
}

if *azureSource.CachingMode != "" {
Copy link
Member

@liggitt liggitt May 30, 2019

Choose a reason for hiding this comment

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

should this be if azureSource.CachingMode != nil && *azureSource.CachingMode {?

Copy link
Member Author

@ddebroy ddebroy May 30, 2019

Choose a reason for hiding this comment

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

good catch! I think we should just check for if azureSource.CachingMode != nil rather than something along the lines of if azureSource.CachingMode != nil && *azureSource.CachingMode != "" So:

        if azureSource.CachingMode != nil {
                pv.Spec.PersistentVolumeSource.CSI.VolumeAttributes[azureDiskCachingMode] = string(*azureSource.CachingMode)
        }

Seems like this is something applicable to the above code as well for the regular TranslateInTreePVToCSI already there for AzureDisk at https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/csi-translation-lib/plugins/azure_disk.go#L79.

#78524 to fix it it both places.

if *azureSource.CachingMode != "" {
pv.Spec.PersistentVolumeSource.CSI.VolumeAttributes[azureDiskCachingMode] = string(*azureSource.CachingMode)
}
if *azureSource.FSType != "" {
Copy link
Member

Choose a reason for hiding this comment

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

should this be if azureSource.FSType != nil && *azureSource.FSType {?

Copy link
Member Author

@ddebroy ddebroy May 30, 2019

Choose a reason for hiding this comment

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

Thinking of changing this block to:

        if azureSource.FSType != nil {
                pv.Spec.PersistentVolumeSource.CSI.FSType = *azureSource.FSType
                pv.Spec.PersistentVolumeSource.CSI.VolumeAttributes[azureDiskFSType] = *azureSource.FSType
        }

Applies to both inline portion in this PR as well as https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/csi-translation-lib/plugins/azure_disk.go#L83 .

#78524 to fix it in both places.

Not quite sure @andyzhangx why the FSType needs to be passed as a VolumeAttribute parameter on top of the field?

Driver: AzureDiskDriverName,
VolumeHandle: azureSource.DataDiskURI,
ReadOnly: *azureSource.ReadOnly,
FSType: *azureSource.FSType,
Copy link
Member

Choose a reason for hiding this comment

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

similar comments about nil checks on these fields before dereferencing them

Copy link
Member Author

Choose a reason for hiding this comment

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

#78524 to fix this both above and in TranslateInTreePVToCSI

@k8s-ci-robot k8s-ci-robot merged commit b7fa33e into kubernetes:master May 31, 2019
@@ -53,13 +55,20 @@ func (volumeAttachmentStrategy) PrepareForCreate(ctx context.Context, obj runtim
groupVersion = schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
}

volumeAttachment := obj.(*storage.VolumeAttachment)
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we check that the cast was successful ?

Copy link
Member

Choose a reason for hiding this comment

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

no, this is well tested and is a programmer error if any other type comes through here

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of the following ?

diff --git a/pkg/registry/storage/volumeattachment/strategy.go b/pkg/registry/storage/volumeattachment/strategy.go
index 183fe02d95..b3468d9370 100644
--- a/pkg/registry/storage/volumeattachment/strategy.go
+++ b/pkg/registry/storage/volumeattachment/strategy.go
@@ -48,20 +48,17 @@ func (volumeAttachmentStrategy) NamespaceScoped() bool {
 }

 // ResetBeforeCreate clears the Status field which is not allowed to be set by end users on creation.
-func (volumeAttachmentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
+func (volumeAttachmentStrategy) PrepareForCreate(ctx context.Context, volumeAttachment *storage.VolumeAttachment) {
        var groupVersion schema.GroupVersion

        if requestInfo, found := genericapirequest.RequestInfoFrom(ctx); found {
                groupVersion = schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
        }

-       volumeAttachment := obj.(*storage.VolumeAttachment)
-
        switch groupVersion {
        case storageapiv1beta1.SchemeGroupVersion:
                // allow modification of status for v1beta1
        default:
-               volumeAttachment := obj.(*storage.VolumeAttachment)
                volumeAttachment.Status = storage.VolumeAttachmentStatus{}
        }

This would make the parameter type more visible.

thanks

Copy link
Member

Choose a reason for hiding this comment

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

No, PrepareForCreate is an interface all strategies implement

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for the explanation.

@@ -53,13 +55,20 @@ func (volumeAttachmentStrategy) PrepareForCreate(ctx context.Context, obj runtim
groupVersion = schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
}

volumeAttachment := obj.(*storage.VolumeAttachment)

switch groupVersion {
case storageapiv1beta1.SchemeGroupVersion:
// allow modification of status for v1beta1
default:
volumeAttachment := obj.(*storage.VolumeAttachment)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line can be removed.

The assignment happens on line 58

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @tedyu, thank you for the suggestions. This PR has already merged. Could you please submit a cleanup PR for the nit you mentioned

Copy link
Contributor

Choose a reason for hiding this comment

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

see #78659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. 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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Status: API review completed, 1.15
Development

Successfully merging this pull request may close these issues.

10 participants