Skip to content

Commit badf72f

Browse files
authored
Merge pull request #8 from stackitcloud/flavor-not-found-mapping
Map flavor not found to ResourceExhausted error code
2 parents 49a6c2c + d9943b1 commit badf72f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.21.0-ske-1
1+
v0.21.0-ske-2

pkg/driver/executor/errors.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ import (
88
"fmt"
99
)
1010

11-
// NoValidHost is a part of the error message returned when there is no valid host in the zone to deploy a VM.
12-
// Matches:
13-
//
14-
// "No valid host was found."
15-
// "No valid host was found. There are not enough hosts available."
16-
const NoValidHost = "No valid host was found"
11+
const (
12+
// NoValidHost is a part of the error message returned when there is no valid host in the zone to deploy a VM.
13+
// Matches:
14+
//
15+
// "No valid host was found."
16+
// "No valid host was found. There are not enough hosts available."
17+
NoValidHost = "No valid host was found"
18+
19+
// FlavorNotFound is part of the error message returned when a flavor cannot be resolved.
20+
FlavorNotFound = "error resolving flavor"
21+
)
1722

1823
var (
1924
// ErrNotFound is returned when the requested resource could not be found.

pkg/driver/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ func mapErrorToCode(err error) codes.Code {
6969

7070
func mapErrorMessageToCode(err error) codes.Code {
7171
errorMessage := err.Error()
72-
if strings.Contains(errorMessage, executor.NoValidHost) {
72+
if strings.Contains(errorMessage, executor.NoValidHost) ||
73+
strings.Contains(errorMessage, executor.FlavorNotFound) {
7374
return codes.ResourceExhausted
7475
}
7576
return codes.Internal

0 commit comments

Comments
 (0)