Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FetchAvailableDiskTypes to GCE Client #6845

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading