diff --git a/CHANGELOG.md b/CHANGELOG.md index aed2b0ea5..bb4853a14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,8 +78,11 @@ - **Feature:** Add new enum `GetProviderOptionsRequestVersionState` - [v1.4.1](services/ske/CHANGELOG.md#v141) - Bump STACKIT SDK core module from `v0.19.0` to `v0.20.0` -- `sqlserverflex`: [v1.3.2](services/sqlserverflex/CHANGELOG.md#v132) - - Bump STACKIT SDK core module from `v0.19.0` to `v0.20.0` +- `sqlserverflex`: + - [v1.3.3](services/sqlserverflex/CHANGELOG.md#v133) + - **Bugfix:** Adjust waiters to fail only in `Failure` or `Unknown` state + - [v1.3.2](services/sqlserverflex/CHANGELOG.md#v132) + - Bump STACKIT SDK core module from `v0.19.0` to `v0.20.0` - `stackitmarketplace`: [v1.17.1](services/stackitmarketplace/CHANGELOG.md#v1171) - Bump STACKIT SDK core module from `v0.19.0` to `v0.20.0` - `core`: [v0.20.0](core/CHANGELOG.md#v0200) diff --git a/services/sqlserverflex/CHANGELOG.md b/services/sqlserverflex/CHANGELOG.md index b7df7d787..1040908de 100644 --- a/services/sqlserverflex/CHANGELOG.md +++ b/services/sqlserverflex/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.3.3 +- **Bugfix:** Adjust waiters to fail only in `Failure` or `Unknown` state + ## v1.3.2 - Bump STACKIT SDK core module from `v0.19.0` to `v0.20.0` diff --git a/services/sqlserverflex/VERSION b/services/sqlserverflex/VERSION index bb8edae97..1b0c03e2f 100644 --- a/services/sqlserverflex/VERSION +++ b/services/sqlserverflex/VERSION @@ -1 +1 @@ -v1.3.2 \ No newline at end of file +v1.3.3 \ No newline at end of file diff --git a/services/sqlserverflex/wait/wait.go b/services/sqlserverflex/wait/wait.go index 2115c919c..5f1563be3 100644 --- a/services/sqlserverflex/wait/wait.go +++ b/services/sqlserverflex/wait/wait.go @@ -2,8 +2,10 @@ package wait import ( "context" + "errors" "fmt" "net/http" + "strings" "time" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" @@ -34,19 +36,13 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface if s == nil || s.Item == nil || s.Item.Id == nil || *s.Item.Id != instanceId || s.Item.Status == nil { return false, nil, nil } - switch *s.Item.Status { - default: - return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Item.Status) - case InstanceStateEmpty: - return false, s, nil - case InstanceStateProcessing: - return false, s, nil - case InstanceStateUnknown: - return false, s, nil - case InstanceStateSuccess: + switch strings.ToLower(*s.Item.Status) { + case strings.ToLower(InstanceStateSuccess): return true, s, nil - case InstanceStateFailed: + case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed): return true, s, fmt.Errorf("create failed for instance with id %s", instanceId) + default: + return false, s, nil } }) handler.SetTimeout(45 * time.Minute) @@ -64,19 +60,13 @@ func UpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface if s == nil || s.Item == nil || s.Item.Id == nil || *s.Item.Id != instanceId || s.Item.Status == nil { return false, nil, nil } - switch *s.Item.Status { - default: - return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Item.Status) - case InstanceStateEmpty: - return false, s, nil - case InstanceStateProcessing: - return false, s, nil - case InstanceStateUnknown: - return false, s, nil - case InstanceStateSuccess: + switch strings.ToLower(*s.Item.Status) { + case strings.ToLower(InstanceStateSuccess): return true, s, nil - case InstanceStateFailed: + case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed): return true, s, fmt.Errorf("update failed for instance with id %s", instanceId) + default: + return false, s, nil } }) handler.SetSleepBeforeWait(2 * time.Second) @@ -96,7 +86,8 @@ func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface if err == nil { return false, nil, nil } - oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped + var oapiErr *oapierror.GenericOpenAPIError + ok := errors.As(err, &oapiErr) if !ok { return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") }