Skip to content

Commit 76fc21e

Browse files
authored
Merge pull request kubernetes#5666 from azylinski/gce-autoscaling-fetch-reservations
Add FetchReservations to GCE Autoscaling client
2 parents 1a37590 + b6c887c commit 76fc21e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ type AutoscalingGceClient interface {
7777
FetchMigsWithName(zone string, filter *regexp.Regexp) ([]string, error)
7878
FetchZones(region string) ([]string, error)
7979
FetchAvailableCpuPlatforms() (map[string][]string, error)
80+
FetchReservations() ([]*gce.Reservation, error)
8081

8182
// modifying resources
8283
ResizeMig(GceRef, int64) error
@@ -508,3 +509,15 @@ func (client *autoscalingGceClientV1) FetchMigsWithName(zone string, name *regex
508509
}
509510
return links, nil
510511
}
512+
513+
func (client *autoscalingGceClientV1) FetchReservations() ([]*gce.Reservation, error) {
514+
reservations := make([]*gce.Reservation, 0)
515+
call := client.gceService.Reservations.AggregatedList(client.projectId)
516+
err := call.Pages(context.TODO(), func(ls *gce.ReservationAggregatedList) error {
517+
for _, items := range ls.Items {
518+
reservations = append(reservations, items.Reservations...)
519+
}
520+
return nil
521+
})
522+
return reservations, err
523+
}

cluster-autoscaler/cloudprovider/gce/mig_info_provider_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func (client *mockAutoscalingGceClient) FetchAvailableCpuPlatforms() (map[string
100100
return nil, nil
101101
}
102102

103+
func (client *mockAutoscalingGceClient) FetchReservations() ([]*gce.Reservation, error) {
104+
return nil, nil
105+
}
106+
103107
func (client *mockAutoscalingGceClient) ResizeMig(_ GceRef, _ int64) error {
104108
return nil
105109
}

0 commit comments

Comments
 (0)