@@ -73,7 +73,7 @@ type GCECompute interface {
73
73
ListZones (ctx context.Context , region string ) ([]string , error )
74
74
ListSnapshots (ctx context.Context , filter string , maxEntries int64 , pageToken string ) ([]* computev1.Snapshot , string , error )
75
75
GetSnapshot (ctx context.Context , project , snapshotName string ) (* computev1.Snapshot , error )
76
- CreateSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error )
76
+ CreateSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string , storageLocations string ) (* computev1.Snapshot , error )
77
77
DeleteSnapshot (ctx context.Context , project , snapshotName string ) error
78
78
}
79
79
@@ -787,13 +787,13 @@ func (cloud *CloudProvider) DeleteSnapshot(ctx context.Context, project, snapsho
787
787
return nil
788
788
}
789
789
790
- func (cloud * CloudProvider ) CreateSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
790
+ func (cloud * CloudProvider ) CreateSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string , storageLocations string ) (* computev1.Snapshot , error ) {
791
791
klog .V (5 ).Infof ("Creating snapshot %s for volume %v" , snapshotName , volKey )
792
792
switch volKey .Type () {
793
793
case meta .Zonal :
794
- return cloud .createZonalDiskSnapshot (ctx , project , volKey , snapshotName )
794
+ return cloud .createZonalDiskSnapshot (ctx , project , volKey , snapshotName , storageLocations )
795
795
case meta .Regional :
796
- return cloud .createRegionalDiskSnapshot (ctx , project , volKey , snapshotName )
796
+ return cloud .createRegionalDiskSnapshot (ctx , project , volKey , snapshotName , storageLocations )
797
797
default :
798
798
return nil , fmt .Errorf ("could not create snapshot, key was neither zonal nor regional, instead got: %v" , volKey .String ())
799
799
}
@@ -864,9 +864,10 @@ func (cloud *CloudProvider) resizeRegionalDisk(ctx context.Context, project stri
864
864
return requestGb , nil
865
865
}
866
866
867
- func (cloud * CloudProvider ) createZonalDiskSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
867
+ func (cloud * CloudProvider ) createZonalDiskSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string , storageLocations string ) (* computev1.Snapshot , error ) {
868
868
snapshotToCreate := & computev1.Snapshot {
869
- Name : snapshotName ,
869
+ Name : snapshotName ,
870
+ StorageLocations : strings .Split (storageLocations , "," ),
870
871
}
871
872
872
873
_ , err := cloud .service .Disks .CreateSnapshot (project , volKey .Zone , volKey .Name , snapshotToCreate ).Context (ctx ).Do ()
@@ -878,9 +879,10 @@ func (cloud *CloudProvider) createZonalDiskSnapshot(ctx context.Context, project
878
879
return cloud .waitForSnapshotCreation (ctx , project , snapshotName )
879
880
}
880
881
881
- func (cloud * CloudProvider ) createRegionalDiskSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
882
+ func (cloud * CloudProvider ) createRegionalDiskSnapshot (ctx context.Context , project string , volKey * meta.Key , snapshotName string , storageLocations string ) (* computev1.Snapshot , error ) {
882
883
snapshotToCreate := & computev1.Snapshot {
883
- Name : snapshotName ,
884
+ Name : snapshotName ,
885
+ StorageLocations : strings .Split (storageLocations , "," ),
884
886
}
885
887
886
888
_ , err := cloud .service .RegionDisks .CreateSnapshot (project , volKey .Region , volKey .Name , snapshotToCreate ).Context (ctx ).Do ()
0 commit comments