Skip to content

Commit

Permalink
Handle reservation capacity exceeded error separately
Browse files Browse the repository at this point in the history
  • Loading branch information
norbertcyran committed Oct 2, 2024
1 parent f79e8d4 commit 27dcba4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const (
// be scaled up because the associated reservation was not ready.
ErrorReservationNotReady = "RESERVATION_NOT_READY"

// ErrorReservationCapacityExceeded is an error code for InstanceErrorInfo if the node group couldn't
// be scaled up because the associated reservation's capacity has been exceeded.
ErrorReservationCapacityExceeded = "RESERVATION_CAPACITY_EXCEEDED"

// ErrorUnsupportedTpuConfiguration is an error code for InstanceErrorInfo if the
// node group couldn't be scaled up because of invalid TPU configuration.
ErrorUnsupportedTpuConfiguration = "UNSUPPORTED_TPU_CONFIGURATION"
Expand All @@ -92,8 +96,6 @@ var (
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."),
regexp.MustCompile("Specified reservation (.*) does not have available resources for the request."),
regexp.MustCompile("Specified reservations (.*) do not exist"),
}
)
Expand Down Expand Up @@ -581,6 +583,11 @@ func GetErrorInfo(errorCode, errorMessage, instanceStatus string, previousErrorI
ErrorClass: cloudprovider.OtherErrorClass,
ErrorCode: ErrorInvalidReservation,
}
} else if isReservationCapacityExceeded(errorMessage) {
return &cloudprovider.InstanceErrorInfo{
ErrorClass: cloudprovider.OtherErrorClass,
ErrorCode: ErrorReservationCapacityExceeded,
}
} else if isTpuConfigurationInvalidError(errorCode, errorMessage) {
return &cloudprovider.InstanceErrorInfo{
ErrorClass: cloudprovider.OtherErrorClass,
Expand Down Expand Up @@ -662,6 +669,11 @@ func isReservationNotReady(errorMessage string) bool {
return strings.Contains(errorMessage, "it requires reservation to be in READY state")
}

func isReservationCapacityExceeded(errorMessage string) bool {
re := regexp.MustCompile("Specified reservation (.*) does not have available resources for the request.")
return re.MatchString(errorMessage)
}

func isInvalidReservationError(errorMessage string) bool {
for _, re := range regexReservationErrors {
if re.MatchString(errorMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func TestErrors(t *testing.T) {
{
errorCodes: []string{"CONDITION_NOT_MET"},
errorMessage: "Specified reservation 'rsv-name' does not have available resources for the request.",
expectedErrorCode: "INVALID_RESERVATION",
expectedErrorCode: "RESERVATION_CAPACITY_EXCEEDED",
expectedErrorClass: cloudprovider.OtherErrorClass,
},
{
Expand Down

0 comments on commit 27dcba4

Please sign in to comment.