Skip to content

Commit

Permalink
Merge pull request kubernetes#5666 from azylinski/gce-autoscaling-fet…
Browse files Browse the repository at this point in the history
…ch-reservations

Add FetchReservations to GCE Autoscaling client
  • Loading branch information
k8s-ci-robot authored Apr 13, 2023
2 parents 1a37590 + b6c887c commit 76fc21e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type AutoscalingGceClient interface {
FetchMigsWithName(zone string, filter *regexp.Regexp) ([]string, error)
FetchZones(region string) ([]string, error)
FetchAvailableCpuPlatforms() (map[string][]string, error)
FetchReservations() ([]*gce.Reservation, error)

// modifying resources
ResizeMig(GceRef, int64) error
Expand Down Expand Up @@ -508,3 +509,15 @@ func (client *autoscalingGceClientV1) FetchMigsWithName(zone string, name *regex
}
return links, nil
}

func (client *autoscalingGceClientV1) FetchReservations() ([]*gce.Reservation, error) {
reservations := make([]*gce.Reservation, 0)
call := client.gceService.Reservations.AggregatedList(client.projectId)
err := call.Pages(context.TODO(), func(ls *gce.ReservationAggregatedList) error {
for _, items := range ls.Items {
reservations = append(reservations, items.Reservations...)
}
return nil
})
return reservations, err
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (client *mockAutoscalingGceClient) FetchAvailableCpuPlatforms() (map[string
return nil, nil
}

func (client *mockAutoscalingGceClient) FetchReservations() ([]*gce.Reservation, error) {
return nil, nil
}

func (client *mockAutoscalingGceClient) ResizeMig(_ GceRef, _ int64) error {
return nil
}
Expand Down

0 comments on commit 76fc21e

Please sign in to comment.