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

[draft] feat: Implement KEP3751 ("ControllerModifyVolume") #2344

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

umagnus
Copy link
Contributor

@umagnus umagnus commented Jun 7, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

feat: Implement KEP3751 ("ControllerModifyVolume")
Implements support for modifying volumes via KEP3751 (https://kep.k8s.io/3751)

Which issue(s) this PR fixes:

Fixes #

Requirements:

Special notes for your reviewer:

I0627 02:52:59.490914       1 utils.go:105] GRPC call: /csi.v1.Controller/ControllerModifyVolume
I0627 02:52:59.490952       1 utils.go:106] GRPC request: {"mutable_parameters":{"DiskIOPSReadWrite":"5000","DiskMBpsReadWrite":"1200"},"volume_id":"/subscriptions/8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8/resourceGroups/MC_aks-yxytest_group_aks-yxytest_eastus/providers/Microsoft.Compute/disks/pvc-526c35c8-87d2-4a67-8cee-99e3b6ce3b3f"}
I0627 02:52:59.875553       1 controllerserver.go:437] begin to modify azure disk() account type() rg() location()
I0627 02:52:59.875586       1 azure_managedDiskController.go:420] azureDisk - modifying managed Name:pvc-526c35c8-87d2-4a67-8cee-99e3b6ce3b3f, StorageAccountType:, DiskIOPSReadWrite:5000, DiskMBpsReadWrite:1200
I0627 02:53:03.174198       1 azure_managedDiskController.go:486] azureDisk - modified new MD Name:pvc-526c35c8-87d2-4a67-8cee-99e3b6ce3b3f StorageAccountType:
I0627 02:53:03.174248       1 controllerserver.go:466] modify azure disk() account type() rg() location() successfully
I0627 02:53:03.174608       1 azure_metrics.go:115] "Observed Request Latency" latency_seconds=3.298678755 request="azuredisk_csi_driver_controller_modify_volume" resource_group="mc_aks-yxytest_group_aks-yxytest_eastus" subscription_id="8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8" source="disk.csi.azure.com" volumeid="/subscriptions/8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8/resourceGroups/MC_aks-yxytest_group_aks-yxytest_eastus/providers/Microsoft.Compute/disks/pvc-526c35c8-87d2-4a67-8cee-99e3b6ce3b3f" result_code="succeeded"

I0627 06:58:30.405618       1 utils.go:105] GRPC call: /csi.v1.Controller/ControllerModifyVolume
I0627 06:58:30.405664       1 utils.go:106] GRPC request: {"mutable_parameters":{"cachingMode":"None","skuName":"StandardSSD_LRS"},"volume_id":"/subscriptions/8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8/resourceGroups/MC_aks-yxytest_group_aks-yxytest_eastus/providers/Microsoft.Compute/disks/pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a"}
I0627 06:58:30.533276       1 controllerserver.go:437] begin to modify azure disk() account type(StandardSSD_LRS) rg() location()
I0627 06:58:30.533333       1 azure_managedDiskController.go:420] azureDisk - modifying managed Name:pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a, StorageAccountType:StandardSSD_LRS, DiskIOPSReadWrite:, DiskMBpsReadWrite:
I0627 06:58:33.598201       1 azure_managedDiskController.go:486] azureDisk - modified new MD Name:pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a StorageAccountType:StandardSSD_LRS
I0627 06:58:33.598251       1 controllerserver.go:466] modify azure disk() account type(StandardSSD_LRS) rg() location() successfully
I0627 06:58:33.598305       1 azure_metrics.go:115] "Observed Request Latency" latency_seconds=3.064952723 request="azuredisk_csi_driver_controller_modify_volume" resource_group="mc_aks-yxytest_group_aks-yxytest_eastus" subscription_id="8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8" source="disk.csi.azure.com" volumeid="/subscriptions/8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8/resourceGroups/MC_aks-yxytest_group_aks-yxytest_eastus/providers/Microsoft.Compute/disks/pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a" result_code="succeeded"

I0627 07:14:17.551830       1 utils.go:105] GRPC call: /csi.v1.Controller/ControllerModifyVolume
I0627 07:14:17.551909       1 utils.go:106] GRPC request: {"mutable_parameters":{"skuName":"Premium_LRS"},"volume_id":"/subscriptions/8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8/resourceGroups/MC_aks-yxytest_group_aks-yxytest_eastus/providers/Microsoft.Compute/disks/pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a"}
I0627 07:14:17.634946       1 controllerserver.go:437] begin to modify azure disk() account type(Premium_LRS) rg() location()
I0627 07:14:17.635000       1 azure_managedDiskController.go:420] azureDisk - modifying managed Name:pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a, StorageAccountType:Premium_LRS, DiskIOPSReadWrite:, DiskMBpsReadWrite:
I0627 07:14:20.141664       1 azure_managedDiskController.go:486] azureDisk - modified new MD Name:pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a StorageAccountType:Premium_LRS
I0627 07:14:20.141707       1 controllerserver.go:466] modify azure disk() account type(Premium_LRS) rg() location() successfully
I0627 07:14:20.141760       1 azure_metrics.go:115] "Observed Request Latency" latency_seconds=2.506722411 request="azuredisk_csi_driver_controller_modify_volume" resource_group="mc_aks-yxytest_group_aks-yxytest_eastus" subscription_id="8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8" source="disk.csi.azure.com" volumeid="/subscriptions/8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8/resourceGroups/MC_aks-yxytest_group_aks-yxytest_eastus/providers/Microsoft.Compute/disks/pvc-11b511bb-c767-42c9-9fae-cf31c641ab4a" result_code="succeeded"
I0627 07:14:20.141795       1 utils.go:112] GRPC response: {}

image
image

Release note:

none

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 7, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @umagnus. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 7, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: umagnus
Once this PR has been reviewed and has the lgtm label, please assign edreed for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@andyzhangx
Copy link
Member

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

umagnus commented Jun 26, 2024

/retest

pkg/azuredisk/azure_managedDiskController.go Outdated Show resolved Hide resolved
pkg/azuredisk/controllerserver.go Outdated Show resolved Hide resolved
}

model := armcompute.DiskUpdate{
SKU: &armcompute.DiskSKU{
Copy link
Member

Choose a reason for hiding this comment

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

are these two parameters necessary in DiskUpdate struct? IMO, if only sku is needed, then only update sku, otherwise only update diskProperties

Copy link
Member

Choose a reason for hiding this comment

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

in L432, there is result, err := diskClient.Get(ctx, rg, options.DiskName) operation, is this necessary if disk sku is not going to be modified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I move model.SKU = &armcompute.DiskSKU{ Name: to.Ptr(diskSku), } and model.Properties = &diskProperties in update needed. But I think result, err := diskClient.Get(ctx, rg, options.DiskName) is still need because we need old disk sku in L443 and L454

pkg/azuredisk/controllerserver.go Outdated Show resolved Hide resolved
@umagnus
Copy link
Contributor Author

umagnus commented Jun 28, 2024

/retest

1 similar comment
@umagnus
Copy link
Contributor Author

umagnus commented Jun 28, 2024

/retest

}

model := armcompute.DiskUpdate{}
result, err := diskClient.Get(ctx, rg, options.DiskName)
Copy link
Member

Choose a reason for hiding this comment

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

diskClient.Get is only needed if options.StorageAccountType != "" && options.StorageAccountType != diskSku, I think this logic should move to L446

Copy link
Contributor Author

Choose a reason for hiding this comment

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

diskSku is the previous sku which is *result.SKU.Name get from result, so I think diskClient.Get is still needed

Copy link
Member

Choose a reason for hiding this comment

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

in ModifyVolume, if user does not input new disk sku, this diskClient.Get call is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we still need diskSku in L454, one condition is that the old sku is not ultrassd or premiumv2, but cx give iops and throught and no disksku. If we don't get old disk sku, we can't determine it

skuName = ""
}

if _, err := azureutils.NormalizeCachingMode(diskParams.CachingMode); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

why there is cachingmode check here since cachingmode change is not allowed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove it since azuredisk cannot change PremiumV2

}
if skuName == armcompute.DiskStorageAccountTypesPremiumV2LRS {
// PremiumV2LRS only supports None caching mode
azureutils.SetKeyValueInMap(diskParams.VolumeContext, consts.CachingModeField, string(v1.AzureDataDiskCachingNone))
Copy link
Member

Choose a reason for hiding this comment

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

so this change is also not necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove it

azureutils.SetKeyValueInMap(diskParams.VolumeContext, consts.CachingModeField, string(v1.AzureDataDiskCachingNone))
}

metricsRequest := "controller_modify_volume"
Copy link
Member

Choose a reason for hiding this comment

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

not necessary to define a new var here since it's just used once

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove it

mc.ObserveOperationWithResult(isOperationSucceeded, consts.VolumeID, diskURI)
}()

err = localDiskController.ModifyDisk(ctx, volumeOptions)
Copy link
Member

Choose a reason for hiding this comment

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

pls make same change as v1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return nil, status.Error(codes.NotFound, fmt.Sprintf("Volume not found, failed with error: %v", err))
}

mutableParams := req.GetMutableParameters()
Copy link
Member

Choose a reason for hiding this comment

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

remove this mutableParams var define, just use req.GetMutableParameters() in L327

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove it

return nil, status.Error(codes.NotFound, fmt.Sprintf("Volume not found, failed with error: %v", err))
}

mutableParams := req.GetMutableParameters()
Copy link
Member

Choose a reason for hiding this comment

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

remove this mutableParams var define, just use req.GetMutableParameters() in L327

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove it

}
}

if _, err := diskClient.Patch(ctx, rg, options.DiskName, model); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

only run diskClient.Patch if model.SKU or model.Properties is not nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@andyzhangx
Copy link
Member

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants