@@ -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 , snapshotName string ) (* computev1.Snapshot , error )
76
- CreateSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error )
76
+ CreateSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string , storageLocations string ) (* computev1.Snapshot , error )
77
77
DeleteSnapshot (ctx context.Context , snapshotName string ) error
78
78
}
79
79
@@ -793,13 +793,13 @@ func (cloud *CloudProvider) DeleteSnapshot(ctx context.Context, snapshotName str
793
793
return nil
794
794
}
795
795
796
- func (cloud * CloudProvider ) CreateSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
796
+ func (cloud * CloudProvider ) CreateSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string , storageLocations string ) (* computev1.Snapshot , error ) {
797
797
klog .V (5 ).Infof ("Creating snapshot %s for volume %v" , snapshotName , volKey )
798
798
switch volKey .Type () {
799
799
case meta .Zonal :
800
- return cloud .createZonalDiskSnapshot (ctx , volKey , snapshotName )
800
+ return cloud .createZonalDiskSnapshot (ctx , volKey , snapshotName , storageLocations )
801
801
case meta .Regional :
802
- return cloud .createRegionalDiskSnapshot (ctx , volKey , snapshotName )
802
+ return cloud .createRegionalDiskSnapshot (ctx , volKey , snapshotName , storageLocations )
803
803
default :
804
804
return nil , fmt .Errorf ("could not create snapshot, key was neither zonal nor regional, instead got: %v" , volKey .String ())
805
805
}
@@ -870,9 +870,11 @@ func (cloud *CloudProvider) resizeRegionalDisk(ctx context.Context, volKey *meta
870
870
return requestGb , nil
871
871
}
872
872
873
- func (cloud * CloudProvider ) createZonalDiskSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
873
+ func (cloud * CloudProvider ) createZonalDiskSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ,
874
+ storageLocations string ) (* computev1.Snapshot , error ) {
874
875
snapshotToCreate := & computev1.Snapshot {
875
- Name : snapshotName ,
876
+ Name : snapshotName ,
877
+ StorageLocations : strings .Split (storageLocations , "," ),
876
878
}
877
879
878
880
_ , err := cloud .service .Disks .CreateSnapshot (cloud .project , volKey .Zone , volKey .Name , snapshotToCreate ).Context (ctx ).Do ()
@@ -884,9 +886,10 @@ func (cloud *CloudProvider) createZonalDiskSnapshot(ctx context.Context, volKey
884
886
return cloud .waitForSnapshotCreation (ctx , snapshotName )
885
887
}
886
888
887
- func (cloud * CloudProvider ) createRegionalDiskSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string ) (* computev1.Snapshot , error ) {
889
+ func (cloud * CloudProvider ) createRegionalDiskSnapshot (ctx context.Context , volKey * meta.Key , snapshotName string , storageLocations string ) (* computev1.Snapshot , error ) {
888
890
snapshotToCreate := & computev1.Snapshot {
889
- Name : snapshotName ,
891
+ Name : snapshotName ,
892
+ StorageLocations : strings .Split (storageLocations , "," ),
890
893
}
891
894
892
895
_ , err := cloud .service .RegionDisks .CreateSnapshot (cloud .project , volKey .Region , volKey .Name , snapshotToCreate ).Context (ctx ).Do ()
0 commit comments