@@ -101,6 +101,7 @@ type GCECompute interface {
101
101
ValidateExistingDisk (ctx context.Context , disk * CloudDisk , params common.DiskParameters , reqBytes , limBytes int64 , multiWriter bool ) error
102
102
InsertDisk (ctx context.Context , project string , volKey * meta.Key , params common.DiskParameters , capBytes int64 , capacityRange * csi.CapacityRange , replicaZones []string , snapshotID string , volumeContentSourceVolumeID string , multiWriter bool ) error
103
103
DeleteDisk (ctx context.Context , project string , volumeKey * meta.Key ) error
104
+ UpdateDisk (ctx context.Context , project string , volKey * meta.Key , existingDisk * CloudDisk , params common.ModifyVolumeParameters ) error
104
105
AttachDisk (ctx context.Context , project string , volKey * meta.Key , readWrite , diskType , instanceZone , instanceName string , forceAttach bool ) error
105
106
DetachDisk (ctx context.Context , project , deviceName , instanceZone , instanceName string ) error
106
107
GetDiskSourceURI (project string , volKey * meta.Key ) string
@@ -442,6 +443,45 @@ func (cloud *CloudProvider) InsertDisk(ctx context.Context, project string, volK
442
443
}
443
444
}
444
445
446
+ func (cloud * CloudProvider ) UpdateDisk (ctx context.Context , project string , volKey * meta.Key , existingDisk * CloudDisk , params common.ModifyVolumeParameters ) error {
447
+
448
+ klog .V (5 ).Infof ("Updating disk %v" , volKey )
449
+
450
+ switch volKey .Type () {
451
+ case meta .Zonal :
452
+ return cloud .updateZonalDisk (ctx , project , volKey , existingDisk , params )
453
+ case meta .Regional :
454
+ return cloud .updateRegionalDisk (ctx , project , volKey , existingDisk , params )
455
+ default :
456
+ return fmt .Errorf ("could not update disk, key was neither zonal nor regional, instead got: %v" , volKey .String ())
457
+ }
458
+ }
459
+
460
+ func (cloud * CloudProvider ) updateZonalDisk (ctx context.Context , project string , volKey * meta.Key , existingDisk * CloudDisk , params common.ModifyVolumeParameters ) error {
461
+
462
+ updatedDisk := & computev1.Disk {
463
+ Name : existingDisk .GetName (),
464
+ ProvisionedIops : params .IOPS ,
465
+ ProvisionedThroughput : params .Throughput ,
466
+ }
467
+
468
+ diskUpdateOp := cloud .service .Disks .Update (project , volKey .Zone , volKey .Name , updatedDisk )
469
+ diskUpdateOp .Paths ("provisionedIops" , "provisionedThroughput" )
470
+ updateOpResult , err := diskUpdateOp .Context (ctx ).Do ()
471
+
472
+ if err != nil {
473
+ return fmt .Errorf ("error updating disk %v: %w" , volKey , err )
474
+ }
475
+
476
+ fmt .Printf ("http status : %d" , updateOpResult .HTTPStatusCode )
477
+
478
+ return nil
479
+ }
480
+
481
+ func (cloud * CloudProvider ) updateRegionalDisk (ctx context.Context , project string , volKey * meta.Key , existingDisk * CloudDisk , params common.ModifyVolumeParameters ) error {
482
+ // TODO : Implement this
483
+ return nil
484
+ }
445
485
func convertV1CustomerEncryptionKeyToBeta (v1Key * computev1.CustomerEncryptionKey ) * computebeta.CustomerEncryptionKey {
446
486
return & computebeta.CustomerEncryptionKey {
447
487
KmsKeyName : v1Key .KmsKeyName ,
0 commit comments