Skip to content

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

Merged
k8s-ci-robot merged 3 commits into
kubernetes:masterfrom
ddebroy:inline-mig-1
May 31, 2019
Merged

API changes to support migration of inline in-tree volumes to CSI#77703
k8s-ci-robot merged 3 commits into
kubernetes:masterfrom
ddebroy:inline-mig-1

Conversation

@ddebroy

@ddebroy ddebroy commented May 9, 2019

Copy link
Copy Markdown
Contributor

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

ddebroy commented May 9, 2019

Copy link
Copy Markdown
Contributor Author

/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
@k8s-ci-robot
k8s-ci-robot requested review from dchen1107 and deads2k May 9, 2019 22:52
@davidz627

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread pkg/apis/storage/types.go Outdated
Comment thread pkg/apis/storage/validation/validation.go Outdated
Comment thread pkg/registry/storage/volumeattachment/strategy.go Outdated
Comment thread pkg/apis/storage/validation/validation.go Outdated
@ddebroy

ddebroy commented May 10, 2019

Copy link
Copy Markdown
Contributor Author

/retest

@davidz627

Copy link
Copy Markdown
Contributor

/retest

@fejta-bot

Copy link
Copy Markdown

/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
Copy Markdown
Contributor

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

@liggitt

liggitt commented May 30, 2019

Copy link
Copy Markdown
Member

yes

/retest

@ddebroy

ddebroy commented May 30, 2019

Copy link
Copy Markdown
Contributor Author

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

@ddebroy

ddebroy commented May 30, 2019

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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

ddebroy added 3 commits May 30, 2019 09:34
Signed-off-by: Deep Debroy <ddebroy@docker.com>
…umes

Signed-off-by: Deep Debroy <ddebroy@docker.com>
Signed-off-by: Deep Debroy <ddebroy@docker.com>
@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

ddebroy commented May 30, 2019

Copy link
Copy Markdown
Contributor Author

@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

ddebroy commented May 30, 2019

Copy link
Copy Markdown
Contributor Author

/cc @andyzhangx

@andyzhangx andyzhangx left a comment

Copy link
Copy Markdown
Member

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

ddebroy commented May 30, 2019

Copy link
Copy Markdown
Contributor Author

/retest

},
}

if *azureSource.CachingMode != "" {

@liggitt liggitt May 30, 2019

Copy link
Copy Markdown
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.CachingMode != nil && *azureSource.CachingMode {?

@ddebroy ddebroy May 30, 2019

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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 {?

@ddebroy ddebroy May 30, 2019

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
Contributor 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
groupVersion = schema.GroupVersion{Group: requestInfo.APIGroup, Version: requestInfo.APIVersion}
}

volumeAttachment := obj.(*storage.VolumeAttachment)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

case storageapiv1beta1.SchemeGroupVersion:
// allow modification of status for v1beta1
default:
volumeAttachment := obj.(*storage.VolumeAttachment)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see #78659

mhan8796 pushed a commit to mhan8796/kubernetes that referenced this pull request Jun 26, 2026
API changes to support migration of inline in-tree volumes to CSI
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