-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
Conversation
/sig storage |
/assign @davidz627 @liggitt @msau42 |
/priority important-critical |
/remove-priority critical-urgent |
/retest |
/retest |
1 similar comment
/retest |
/retest Review the full test history for this PR. Silence the bot with an |
Hello! We are starting Code Freeze for 1.15. Is this PR still planned to be included in 1.15? |
yes /retest |
/test pull-kubernetes-kubemark-e2e-gce-big |
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
|
/retest Review the full test history for this PR. Silence the bot with an |
Signed-off-by: Deep Debroy <[email protected]>
…umes Signed-off-by: Deep Debroy <[email protected]>
Signed-off-by: Deep Debroy <[email protected]>
@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) |
/cc @andyzhangx |
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.
/lgtm
LGTM for azure part, thanks
/retest |
}, | ||
} | ||
|
||
if *azureSource.CachingMode != "" { |
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.
should this be if azureSource.CachingMode != nil && *azureSource.CachingMode {
?
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.
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 != "" { |
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.
should this be if azureSource.FSType != nil && *azureSource.FSType {
?
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.
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, |
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.
similar comments about nil checks on these fields before dereferencing them
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.
#78524 to fix this both above and in TranslateInTreePVToCSI
@@ -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) |
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.
shouldn't we check that the cast was successful ?
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.
no, this is well tested and is a programmer error if any other type comes through here
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.
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
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.
No, PrepareForCreate is an interface all strategies implement
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.
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) |
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 line can be removed.
The assignment happens on line 58
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.
Hi @tedyu, thank you for the suggestions. This PR has already merged. Could you please submit a cleanup PR for the nit you mentioned
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 #78659
What type of PR is this?
/kind api-change
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?: