Skip to content
Open
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 @@ -274,6 +274,8 @@
- **Dependencies:** Bump STACKIT SDK core module from `v0.25.0` to `v0.26.0`
- [v0.22.0](services/observability/CHANGELOG.md#v0220)
- **Breaking change:** Updated `InstanceSensitiveData` model because of misbehaving API
- [v0.23.0](services/observability/CHANGELOG.md#v0230)
- **Improvement:** Use new WaiterHelper for observability waiters
- `opensearch`:
- [v0.26.3](services/opensearch/CHANGELOG.md#v0263)
- **Dependencies:** Bump STACKIT SDK core module from `v0.24.0` to `v0.24.1`
Expand Down
3 changes: 3 additions & 0 deletions services/observability/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.23.0
- **Improvement:** Use new WaiterHelper for observability waiters

## v0.22.0
- **Breaking change:** Updated `InstanceSensitiveData` model because of misbehaving API

Expand Down
2 changes: 1 addition & 1 deletion services/observability/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.22.0
v0.23.0
65 changes: 33 additions & 32 deletions services/observability/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"
"time"

Expand All @@ -23,22 +24,22 @@ const (

// CreateInstanceWaitHandler will wait for instance creation
func CreateInstanceWaitHandler(ctx context.Context, a observability.DefaultAPI, instanceId, projectId string) *wait.AsyncActionHandler[observability.GetInstanceResponse] {
handler := wait.New(func() (waitFinished bool, response *observability.GetInstanceResponse, err error) {
s, err := a.GetInstance(ctx, instanceId, projectId).Execute()
if err != nil {
return false, nil, err
}
if s == nil {
return false, nil, nil
}
if s.Id == instanceId && s.Status == GETINSTANCERESPONSESTATUS_CREATE_SUCCEEDED {
return true, s, nil
}
if s.Id == instanceId && s.Status == GETINSTANCERESPONSESTATUS_CREATE_FAILED {
return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
}
return false, nil, nil
})
waitConfig := wait.WaiterHelper[observability.GetInstanceResponse, string]{
FetchInstance: a.GetInstance(ctx, instanceId, projectId).Execute,
GetState: func(s *observability.GetInstanceResponse) (string, error) {
if s == nil {
return "", errors.New("empty response")
}
if s.Id != instanceId {
return "", fmt.Errorf("instance id mismatch: expected %s, got %s", instanceId, s.Id)
}
return s.Status, nil
},
ActiveState: []string{GETINSTANCERESPONSESTATUS_CREATE_SUCCEEDED},
ErrorState: []string{GETINSTANCERESPONSESTATUS_CREATE_FAILED},
}

handler := wait.New(waitConfig.Wait())
handler.SetTimeout(45 * time.Minute)
return handler
}
Expand Down Expand Up @@ -68,22 +69,22 @@ func UpdateInstanceWaitHandler(ctx context.Context, a observability.DefaultAPI,

// DeleteInstanceWaitHandler will wait for instance deletion
func DeleteInstanceWaitHandler(ctx context.Context, a observability.DefaultAPI, instanceId, projectId string) *wait.AsyncActionHandler[observability.GetInstanceResponse] {
handler := wait.New(func() (waitFinished bool, response *observability.GetInstanceResponse, err error) {
s, err := a.GetInstance(ctx, instanceId, projectId).Execute()
if err != nil {
return false, nil, err
}
if s == nil {
return false, nil, nil
}
if s.Id == instanceId && s.Status == GETINSTANCERESPONSESTATUS_DELETE_SUCCEEDED {
return true, s, nil
}
if s.Id == instanceId && s.Status == GETINSTANCERESPONSESTATUS_DELETE_FAILED {
return true, s, fmt.Errorf("delete failed for instance with id %s", instanceId)
}
return false, nil, nil
})
waitConfig := wait.WaiterHelper[observability.GetInstanceResponse, string]{
FetchInstance: a.GetInstance(ctx, instanceId, projectId).Execute,
GetState: func(s *observability.GetInstanceResponse) (string, error) {
if s == nil {
return "", errors.New("empty response")
}
if s.Id != instanceId {
return "", fmt.Errorf("instance id mismatch: expected %s, got %s", instanceId, s.Id)
}
return s.Status, nil
},
ActiveState: []string{GETINSTANCERESPONSESTATUS_DELETE_SUCCEEDED},
ErrorState: []string{GETINSTANCERESPONSESTATUS_DELETE_FAILED},
}

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