diff --git a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go index c081c388085..f0185220a31 100644 --- a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go +++ b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go @@ -107,6 +107,7 @@ type AutoscalingGceClient interface { FetchMigsWithName(zone string, filter *regexp.Regexp) ([]string, error) FetchZones(region string) ([]string, error) FetchAvailableCpuPlatforms() (map[string][]string, error) + FetchAvailableDiskTypes() (map[string][]string, error) FetchReservations() ([]*gce.Reservation, error) FetchReservationsInProject(projectId string) ([]*gce.Reservation, error) FetchListManagedInstancesResults(migRef GceRef) (string, error) @@ -585,6 +586,24 @@ func (client *autoscalingGceClientV1) FetchAvailableCpuPlatforms() (map[string][ return availableCpuPlatforms, nil } +func (client *autoscalingGceClientV1) FetchAvailableDiskTypes() (map[string][]string, error) { + availableDiskTypes := make(map[string][]string) + + req := client.gceService.DiskTypes.AggregatedList(client.projectId) + if err := req.Pages(context.TODO(), func(page *gce.DiskTypeAggregatedList) error { + for _, diskTypesScopedList := range page.Items { + for _, diskType := range diskTypesScopedList.DiskTypes { + availableDiskTypes[diskType.Zone] = append(availableDiskTypes[diskType.Zone], diskType.Name) + } + } + return nil + }); err != nil { + return nil, err + } + + return availableDiskTypes, nil +} + func (client *autoscalingGceClientV1) FetchMigTemplateName(migRef GceRef) (InstanceTemplateName, error) { registerRequest("instance_group_managers", "get") igm, err := client.gceService.InstanceGroupManagers.Get(migRef.Project, migRef.Zone, migRef.Name).Do() diff --git a/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go b/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go index 5e5f519fae0..1f4e1199a5c 100644 --- a/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go +++ b/cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go @@ -107,6 +107,10 @@ func (client *mockAutoscalingGceClient) FetchAvailableCpuPlatforms() (map[string return nil, nil } +func (client *mockAutoscalingGceClient) FetchAvailableDiskTypes() (map[string][]string, error) { + return nil, nil +} + func (client *mockAutoscalingGceClient) FetchReservations() ([]*gce.Reservation, error) { return nil, nil }