Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions services/sqlserverflex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`

Expand Down
2 changes: 1 addition & 1 deletion services/sqlserverflex/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.3.2
v1.3.3
37 changes: 14 additions & 23 deletions services/sqlserverflex/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package wait

import (
"context"
"errors"
"fmt"
"net/http"
"strings"
"time"

"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
Expand Down Expand Up @@ -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) {
Comment thread
marceljk marked this conversation as resolved.
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)
Expand All @@ -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)
Expand All @@ -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")
}
Expand Down
Loading