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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@
- **Dependencies:** Bump STACKIT SDK core module from `v0.24.1` to `v0.25.0`
- [v0.28.2](services/mariadb/CHANGELOG.md#v282)
- **Dependencies:** Bump STACKIT SDK core module from `v0.25.0` to `v0.26.0`
- [v0.29.0](services/mariadb/CHANGELOG.md#v290)
- **Improvement:** Use new WaiterHelper for Logs waiters
- `modelserving`:
- [v0.8.3](services/modelserving/CHANGELOG.md#v083)
- **Dependencies:** Bump STACKIT SDK core module from `v0.24.0` to `v0.24.1`
Expand Down
3 changes: 3 additions & 0 deletions services/mariadb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.29.0
- **Improvement:** Use new WaiterHelper for Logs waiters

## v0.28.2
- **Dependencies:** Bump STACKIT SDK core module from `v0.25.0` to `v0.26.0`

Expand Down
2 changes: 1 addition & 1 deletion services/mariadb/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.28.2
v0.29.0
59 changes: 27 additions & 32 deletions services/mariadb/v1api/wait/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wait

import (
"context"
"errors"
"fmt"
"net/http"
"strings"
Expand All @@ -23,44 +24,38 @@ const (

// CreateInstanceWaitHandler will wait for instance creation
func CreateInstanceWaitHandler(ctx context.Context, a mariadb.DefaultAPI, projectId, instanceId string) *wait.AsyncActionHandler[mariadb.Instance] {
handler := wait.New(func() (waitFinished bool, response *mariadb.Instance, err error) {
s, err := a.GetInstance(ctx, projectId, instanceId).Execute()
if err != nil {
return false, nil, err
}
if s.Status == nil {
return false, nil, fmt.Errorf("create failed for instance with id %s. The response is not valid: the status is missing", instanceId)
}
switch *s.Status {
case INSTANCESTATUS_ACTIVE:
return true, s, nil
case INSTANCESTATUS_FAILED:
return true, s, fmt.Errorf("create failed for instance with id %s: %s", instanceId, s.LastOperation.Description)
}
return false, nil, nil
})
waitConfig := wait.WaiterHelper[mariadb.Instance, string]{
FetchInstance: a.GetInstance(ctx, projectId, instanceId).Execute,
GetState: func(s *mariadb.Instance) (string, error) {
if s == nil || s.Status == nil {
return "", errors.New("response or status is nil")
}
return *s.Status, nil
},
ActiveState: []string{INSTANCESTATUS_ACTIVE},
ErrorState: []string{INSTANCESTATUS_FAILED},
}

handler := wait.New(waitConfig.Wait())
handler.SetTimeout(45 * time.Minute)
return handler
}

// PartialUpdateInstanceWaitHandler will wait for instance update
func PartialUpdateInstanceWaitHandler(ctx context.Context, a mariadb.DefaultAPI, projectId, instanceId string) *wait.AsyncActionHandler[mariadb.Instance] {
handler := wait.New(func() (waitFinished bool, response *mariadb.Instance, err error) {
s, err := a.GetInstance(ctx, projectId, instanceId).Execute()
if err != nil {
return false, nil, err
}
if s.Status == nil {
return false, nil, fmt.Errorf("update failed for instance with id %s. The response is not valid: the instance id or the status are missing", instanceId)
}
switch *s.Status {
case INSTANCESTATUS_ACTIVE:
return true, s, nil
case INSTANCESTATUS_FAILED:
return true, s, fmt.Errorf("update failed for instance with id %s: %s", instanceId, s.LastOperation.Description)
}
return false, nil, nil
})
waitConfig := wait.WaiterHelper[mariadb.Instance, string]{
FetchInstance: a.GetInstance(ctx, projectId, instanceId).Execute,
GetState: func(s *mariadb.Instance) (string, error) {
if s == nil || s.Status == nil {
return "", errors.New("response or status is nil")
}
return *s.Status, nil
},
ActiveState: []string{INSTANCESTATUS_ACTIVE},
ErrorState: []string{INSTANCESTATUS_FAILED},
}

handler := wait.New(waitConfig.Wait())
handler.SetTimeout(45 * time.Minute)
return handler
}
Expand Down
Loading