Skip to content

Commit

Permalink
Add additional error codes for invalid reservations to GCE client
Browse files Browse the repository at this point in the history
  • Loading branch information
hbostan committed Sep 7, 2023
1 parent 57f2814 commit 8143592
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,21 @@ func isReservationNotReady(errorCode, errorMessage string) bool {
}

func isInvalidReservationError(errorCode, errorMessage string) bool {
reservationErrors := []string{
"Incompatible AggregateReservation VMFamily",
"Could not find the given reservation with the following name",
"must use ReservationAffinity of",
"The reservation must exist in the same project as the instance",
"only compatible with Aggregate Reservations",
regexReservationErrors := []*regexp.Regexp{
regexp.MustCompile("Incompatible AggregateReservation VMFamily"),
regexp.MustCompile("Could not find the given reservation with the following name"),
regexp.MustCompile("must use ReservationAffinity of"),
regexp.MustCompile("The reservation must exist in the same project as the instance"),
regexp.MustCompile("only compatible with Aggregate Reservations"),
regexp.MustCompile("Please target a reservation with workload_type ="),
regexp.MustCompile("AggregateReservation VMFamily: should be a (.*) VM Family for instance with (.*) machine type"),
regexp.MustCompile("VM Family: (.*) is not supported for aggregate reservations. It must be one of"),
regexp.MustCompile("Reservation (.*) is incorrect for the requested resources"),
regexp.MustCompile("Zone does not currently have sufficient capacity for the requested resources"),
regexp.MustCompile("Reservation (.*) does not have sufficient capacity for the requested resources."),
}
for _, rErr := range reservationErrors {
if strings.Contains(errorMessage, rErr) {
for _, re := range regexReservationErrors {
if re.MatchString(errorMessage) {
return true
}
}
Expand Down

0 comments on commit 8143592

Please sign in to comment.