Skip to content

Commit 7cb739e

Browse files
committed
Add FetchAvailableDiskTypesInZone method.
1 parent e67b896 commit 7cb739e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type AutoscalingGceClient interface {
131131
FetchZones(region string) ([]string, error)
132132
FetchAvailableCpuPlatforms() (map[string][]string, error)
133133
FetchAvailableDiskTypes(region string) (map[string][]string, error)
134+
FetchAvailableDiskTypesInZone(zone string) ([]string, error)
134135
FetchReservations() ([]*gce.Reservation, error)
135136
FetchReservationsInProject(projectId string) ([]*gce.Reservation, error)
136137
FetchListManagedInstancesResults(migRef GceRef) (string, error)
@@ -782,6 +783,23 @@ func (client *autoscalingGceClientV1) FetchAvailableDiskTypes(region string) (ma
782783
return availableDiskTypes, nil
783784
}
784785

786+
// FetchAvailableDiskTypesInZone returns a list of available disk types in a given zone.
787+
func (client *autoscalingGceClientV1) FetchAvailableDiskTypesInZone(zone string) ([]string, error) {
788+
availableDiskTypes := []string{}
789+
790+
req := client.gceService.DiskTypes.List(client.projectId, zone)
791+
if err := req.Pages(context.TODO(), func(page *gce.DiskTypeList) error {
792+
for _, diskType := range page.Items {
793+
availableDiskTypes = append(availableDiskTypes, diskType.Name)
794+
}
795+
return nil
796+
}); err != nil {
797+
return nil, err
798+
}
799+
800+
return availableDiskTypes, nil
801+
}
802+
785803
func (client *autoscalingGceClientV1) FetchMigTemplateName(migRef GceRef) (InstanceTemplateName, error) {
786804
registerRequest("instance_group_managers", "get")
787805
ctx, cancel := context.WithTimeout(context.Background(), client.operationPerCallTimeout)

cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ func (client *mockAutoscalingGceClient) FetchAvailableDiskTypes(_ string) (map[s
176176
return nil, nil
177177
}
178178

179+
func (client *mockAutoscalingGceClient) FetchAvailableDiskTypesInZone(_ string) ([]string, error) {
180+
return nil, nil
181+
}
182+
179183
func (client *mockAutoscalingGceClient) FetchReservations() ([]*gce.Reservation, error) {
180184
return nil, nil
181185
}

0 commit comments

Comments
 (0)