Skip to content

Commit

Permalink
Merge pull request kubernetes#6845 from azylinski/gce-FetchAvailableD…
Browse files Browse the repository at this point in the history
…iskTypes

Add FetchAvailableDiskTypes to GCE Client
  • Loading branch information
k8s-ci-robot authored May 20, 2024
2 parents 1255a4b + 3975ba1 commit 696c28c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 696c28c

Please sign in to comment.