diff --git a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go index c16475bcf14a..3d2447306127 100644 --- a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go +++ b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go @@ -453,15 +453,19 @@ 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("instance configuration is optimized for ([a-z0-9*-]+) workloads"), + regexp.MustCompile("instance configuration is optimized for ([a-z0-9*-]+) workloads"), + regexp.MustCompile("should be a ([a-zA-Z0-9*-]+) VM Family for instance with ([a-zA-Z0-9*\\ -]*) machine type"), + regexp.MustCompile("is not supported for aggregate reservations. It must be one of"), } - for _, rErr := range reservationErrors { - if strings.Contains(errorMessage, rErr) { + for _, re := range regexReservationErrors { + if re.MatchString(errorMessage) { return true } }