Skip to content

Commit e28b5b5

Browse files
authored
fix: dsa wait handlers (#1817)
* fix: waiter for - logme - mariadb - opensearch - redis - rabbitmq * Adapted tests * Update CHANGELOG.md
1 parent bf29127 commit e28b5b5

File tree

16 files changed

+338
-289
lines changed

16 files changed

+338
-289
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
## Release (2025-XX-YY)
22
- `cdn`: [v0.2.0](services/cdn/CHANGELOG.md#v020-2025-04-01)
33
- **API enhancement:** Provide waiter infrastructure
4+
- `logme`: [v0.21.2](services/logme/CHANGELOG.md#v0212-2025-04-02)
5+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
6+
- **Deprecation:** Deprecated `InstanceStateSuccess`, `InstanceStateFailed`, `InstanceTypeCreate`, `InstanceTypeUpdate`, `InstanceTypeDelete` and will be removed after 2nd October 2025
7+
- `mariadb`: [v0.21.2](services/mariadb/CHANGELOG.md#v0212-2025-04-02)
8+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
9+
- **Deprecation:** Deprecated `InstanceStateSuccess`, `InstanceStateFailed`, `InstanceTypeCreate`, `InstanceTypeUpdate`, `InstanceTypeDelete` and will be removed after 2nd October 2025
10+
- `opensearch`: [v0.20.2](services/opensearch/CHANGELOG.md#v0202-2025-04-02)
11+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
12+
- **Deprecation:** Deprecated `InstanceStateSuccess`, `InstanceStateFailed`, `InstanceTypeCreate`, `InstanceTypeUpdate`, `InstanceTypeDelete` and will be removed after 2nd October 2025
13+
- `redis`: [v0.21.2](services/redis/CHANGELOG.md#v0212-2025-04-02)
14+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
15+
- **Deprecation:** Deprecated `InstanceStateSuccess`, `InstanceStateFailed`, `InstanceTypeCreate`, `InstanceTypeUpdate`, `InstanceTypeDelete` and will be removed after 2nd October 2025
16+
- `rabbitmq`: [v0.21.2](services/rabbitmq/CHANGELOG.md#v0212-2025-04-02)
17+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
18+
- **Deprecation:** Deprecated `InstanceStateSuccess`, `InstanceStateFailed`, `InstanceTypeCreate`, `InstanceTypeUpdate`, `InstanceTypeDelete` and will be removed after 2nd October 2025
19+
20+
421

522
## Release (2025-03-27)
23+
624
- `alb`: [v0.2.1](services/alb/CHANGELOG.md#v021-2025-03-27)
725
- **Bugfix:** Removed ConfigureRegion() from API client
826
- `cdn`: [v0.1.1](services/cdn/CHANGELOG.md#v011-2025-03-27)

services/logme/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.21.2 (2025-04-02)
2+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
3+
- **Deprecation:** Deprecated `InstanceStateSuccess`, `InstanceStateFailed`, `InstanceTypeCreate`, `InstanceTypeUpdate`, `InstanceTypeDelete` and will be removed after 2nd October 2025
4+
15
## v0.21.1 (2025-03-19)
26
- **Internal:** Backwards compatible change to generated code
37

services/logme/wait/wait.go

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@ import (
1313
)
1414

1515
const (
16+
InstanceStatusActive = "active"
17+
InstanceStatusFailed = "failed"
18+
InstanceStatusStopped = "stopped"
19+
InstanceStatusCreating = "creating"
20+
InstanceStatusDeleting = "deleting"
21+
InstanceStatusUpdating = "updating"
22+
23+
// Deprecated: InstanceStateSuccess is deprecated and will be removed after 2nd October 2025.
1624
InstanceStateSuccess = "succeeded"
17-
InstanceStateFailed = "failed"
18-
InstanceTypeCreate = "create"
19-
InstanceTypeUpdate = "update"
20-
InstanceTypeDelete = "delete"
25+
// Deprecated: InstanceStateFailed is deprecated and will be removed after 2nd October 2025.
26+
InstanceStateFailed = "failed"
27+
// Deprecated: InstanceTypeCreate is deprecated and will be removed after 2nd October 2025.
28+
InstanceTypeCreate = "create"
29+
// Deprecated: InstanceTypeUpdate is deprecated and will be removed after 2nd October 2025.
30+
InstanceTypeUpdate = "update"
31+
// Deprecated: InstanceTypeDelete is deprecated and will be removed after 2nd October 2025.
32+
InstanceTypeDelete = "delete"
2133
)
2234

2335
// Interface needed for tests
@@ -37,14 +49,18 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
3749
if err != nil {
3850
return false, nil, err
3951
}
40-
if s.InstanceId == nil || s.LastOperation == nil || s.LastOperation.Type == nil || s.LastOperation.State == nil {
41-
return false, nil, fmt.Errorf("create failed for instance with id %s. The response is not valid: the instance id, the last operation type or the state are missing", instanceId)
52+
if s.Status == nil {
53+
return false, nil, fmt.Errorf("create failed for instance with id %s. The response is not valid: the status is missing", instanceId)
4254
}
43-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeCreate && *s.LastOperation.State == InstanceStateSuccess {
55+
switch *s.Status {
56+
case InstanceStatusActive:
4457
return true, s, nil
45-
}
46-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeCreate && *s.LastOperation.State == InstanceStateFailed {
47-
return true, s, fmt.Errorf("create failed for instance with id %s: %s", instanceId, *s.LastOperation.Description)
58+
case InstanceStatusFailed:
59+
var failedDescription string
60+
if s.LastOperation != nil && s.LastOperation.Description != nil {
61+
failedDescription = *s.LastOperation.Description
62+
}
63+
return true, s, fmt.Errorf("create failed for instance with id %s: %s", instanceId, failedDescription)
4864
}
4965
return false, nil, nil
5066
})
@@ -59,14 +75,18 @@ func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceIn
5975
if err != nil {
6076
return false, nil, err
6177
}
62-
if s.InstanceId == nil || s.LastOperation == nil || s.LastOperation.Type == nil || s.LastOperation.State == nil {
63-
return false, nil, fmt.Errorf("update failed for instance with id %s. The response is not valid: the instance id, the last operation type or the state are missing", instanceId)
78+
if s.Status == nil {
79+
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)
6480
}
65-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeUpdate && *s.LastOperation.State == InstanceStateSuccess {
81+
switch *s.Status {
82+
case InstanceStatusActive:
6683
return true, s, nil
67-
}
68-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeUpdate && *s.LastOperation.State == InstanceStateFailed {
69-
return true, s, fmt.Errorf("update failed for instance with id %s: %s", instanceId, *s.LastOperation.Description)
84+
case InstanceStatusFailed:
85+
var failedDescription string
86+
if s.LastOperation != nil && s.LastOperation.Description != nil {
87+
failedDescription = *s.LastOperation.Description
88+
}
89+
return true, s, fmt.Errorf("update failed for instance with id %s: %s", instanceId, failedDescription)
7090
}
7191
return false, nil, nil
7292
})
@@ -79,13 +99,13 @@ func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
7999
handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
80100
s, err := a.GetInstanceExecute(ctx, projectId, instanceId)
81101
if err == nil {
82-
if s.LastOperation == nil || s.LastOperation.Type == nil || s.LastOperation.State == nil || s.LastOperation.Description == nil {
83-
return false, nil, fmt.Errorf("delete failed for instance with id %s. The response is not valid: The last operation type, description or the state are missing", instanceId)
102+
if s.LastOperation == nil || s.LastOperation.Description == nil || s.Status == nil {
103+
return false, nil, fmt.Errorf("delete failed for instance with id %s. The response is not valid: The status or last operation description are missing", instanceId)
84104
}
85-
if *s.LastOperation.Type != InstanceTypeDelete {
105+
if *s.Status != InstanceStatusDeleting {
86106
return false, nil, nil
87107
}
88-
if *s.LastOperation.State == InstanceStateSuccess {
108+
if *s.Status == InstanceStatusActive {
89109
if strings.Contains(*s.LastOperation.Description, "DeleteFailed") || strings.Contains(*s.LastOperation.Description, "failed") {
90110
return true, nil, fmt.Errorf("instance was deleted successfully but has errors: %s", *s.LastOperation.Description)
91111
}

services/logme/wait/wait_test.go

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,21 @@ type apiClientInstanceMocked struct {
2121
resourceDescription string
2222
}
2323

24-
var (
25-
instanceTypeCreate = InstanceTypeCreate
26-
instanceTypeUpdate = InstanceTypeUpdate
27-
instanceTypeDelete = InstanceTypeDelete
28-
)
24+
const deleteOperation = "delete"
2925

3026
func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _ string) (*logme.Instance, error) {
3127
if a.getFails {
3228
return nil, &oapierror.GenericOpenAPIError{
3329
StatusCode: 500,
3430
}
3531
}
36-
if *a.resourceOperation == InstanceTypeDelete && a.resourceState == InstanceStateSuccess {
32+
if a.resourceOperation != nil && *a.resourceOperation == deleteOperation && a.resourceState == InstanceStatusActive {
3733
if a.deletionSucceedsWithErrors {
3834
return &logme.Instance{
3935
InstanceId: &a.resourceId,
36+
Status: &a.resourceState,
4037
LastOperation: &logme.InstanceLastOperation{
4138
Description: &a.resourceDescription,
42-
Type: a.resourceOperation,
43-
State: &a.resourceState,
4439
},
4540
}, nil
4641
}
@@ -51,11 +46,7 @@ func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _ str
5146

5247
return &logme.Instance{
5348
InstanceId: &a.resourceId,
54-
LastOperation: &logme.InstanceLastOperation{
55-
Description: &a.resourceDescription,
56-
Type: a.resourceOperation,
57-
State: &a.resourceState,
58-
},
49+
Status: utils.Ptr(a.resourceState),
5950
}, nil
6051
}
6152

@@ -96,14 +87,14 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
9687
{
9788
desc: "create_succeeded",
9889
getFails: false,
99-
resourceState: InstanceStateSuccess,
90+
resourceState: InstanceStatusActive,
10091
wantErr: false,
10192
wantResp: true,
10293
},
10394
{
10495
desc: "create_failed",
10596
getFails: false,
106-
resourceState: InstanceStateFailed,
97+
resourceState: InstanceStatusFailed,
10798
wantErr: true,
10899
wantResp: true,
109100
},
@@ -126,21 +117,16 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
126117
instanceId := "foo-bar"
127118

128119
apiClient := &apiClientInstanceMocked{
129-
getFails: tt.getFails,
130-
resourceId: instanceId,
131-
resourceOperation: &instanceTypeCreate,
132-
resourceState: tt.resourceState,
120+
getFails: tt.getFails,
121+
resourceId: instanceId,
122+
resourceState: tt.resourceState,
133123
}
134124

135125
var wantRes *logme.Instance
136126
if tt.wantResp {
137127
wantRes = &logme.Instance{
138128
InstanceId: &instanceId,
139-
LastOperation: &logme.InstanceLastOperation{
140-
Type: &instanceTypeCreate,
141-
State: utils.Ptr(tt.resourceState),
142-
Description: utils.Ptr(""),
143-
},
129+
Status: utils.Ptr(tt.resourceState),
144130
}
145131
}
146132

@@ -170,14 +156,14 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
170156
{
171157
desc: "update_succeeded",
172158
getFails: false,
173-
resourceState: InstanceStateSuccess,
159+
resourceState: InstanceStatusActive,
174160
wantErr: false,
175161
wantResp: true,
176162
},
177163
{
178164
desc: "update_failed",
179165
getFails: false,
180-
resourceState: InstanceStateFailed,
166+
resourceState: InstanceStatusFailed,
181167
wantErr: true,
182168
wantResp: true,
183169
},
@@ -200,21 +186,16 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
200186
instanceId := "foo-bar"
201187

202188
apiClient := &apiClientInstanceMocked{
203-
getFails: tt.getFails,
204-
resourceId: instanceId,
205-
resourceOperation: &instanceTypeUpdate,
206-
resourceState: tt.resourceState,
189+
getFails: tt.getFails,
190+
resourceId: instanceId,
191+
resourceState: tt.resourceState,
207192
}
208193

209194
var wantRes *logme.Instance
210195
if tt.wantResp {
211196
wantRes = &logme.Instance{
212197
InstanceId: &instanceId,
213-
LastOperation: &logme.InstanceLastOperation{
214-
Type: &instanceTypeUpdate,
215-
State: utils.Ptr(tt.resourceState),
216-
Description: utils.Ptr(""),
217-
},
198+
Status: utils.Ptr(tt.resourceState),
218199
}
219200
}
220201

@@ -246,22 +227,22 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
246227
desc: "delete_succeeded",
247228
getFails: false,
248229
deleteSucceeedsWithErrors: false,
249-
resourceState: InstanceStateSuccess,
230+
resourceState: InstanceStatusActive,
250231
wantErr: false,
251232
wantResp: true,
252233
},
253234
{
254235
desc: "delete_failed",
255236
getFails: false,
256237
deleteSucceeedsWithErrors: false,
257-
resourceState: InstanceStateFailed,
238+
resourceState: InstanceStatusFailed,
258239
wantErr: true,
259240
wantResp: true,
260241
},
261242
{
262243
desc: "delete_succeeds_with_errors",
263244
getFails: false,
264-
resourceState: InstanceStateSuccess,
245+
resourceState: InstanceStatusActive,
265246
deleteSucceeedsWithErrors: true,
266247
resourceDescription: "Deleting resource: cf failed with error: DeleteFailed",
267248
wantErr: true,
@@ -283,7 +264,7 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
283264
getFails: tt.getFails,
284265
deletionSucceedsWithErrors: tt.deleteSucceeedsWithErrors,
285266
resourceId: instanceId,
286-
resourceOperation: &instanceTypeDelete,
267+
resourceOperation: utils.Ptr(deleteOperation),
287268
resourceDescription: tt.resourceDescription,
288269
resourceState: tt.resourceState,
289270
}

services/mariadb/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.21.2 (2025-04-02)
2+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
3+
- **Deprecation:** Deprecated `InstanceStateSuccess`, `InstanceStateFailed`, `InstanceTypeCreate`, `InstanceTypeUpdate`, `InstanceTypeDelete` and will be removed after 2nd October 2025
4+
15
## v0.21.1 (2025-03-19)
26
- **Internal:** Backwards compatible change to generated code
37

services/mariadb/wait/wait.go

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@ import (
1313
)
1414

1515
const (
16+
InstanceStatusActive = "active"
17+
InstanceStatusFailed = "failed"
18+
InstanceStatusStopped = "stopped"
19+
InstanceStatusCreating = "creating"
20+
InstanceStatusDeleting = "deleting"
21+
InstanceStatusUpdating = "updating"
22+
23+
// Deprecated: InstanceStateSuccess is deprecated and will be removed after 2nd October 2025.
1624
InstanceStateSuccess = "succeeded"
17-
InstanceStateFailed = "failed"
18-
InstanceTypeCreate = "create"
19-
InstanceTypeUpdate = "update"
20-
InstanceTypeDelete = "delete"
25+
// Deprecated: InstanceStateFailed is deprecated and will be removed after 2nd October 2025.
26+
InstanceStateFailed = "failed"
27+
// Deprecated: InstanceTypeCreate is deprecated and will be removed after 2nd October 2025.
28+
InstanceTypeCreate = "create"
29+
// Deprecated: InstanceTypeUpdate is deprecated and will be removed after 2nd October 2025.
30+
InstanceTypeUpdate = "update"
31+
// Deprecated: InstanceTypeDelete is deprecated and will be removed after 2nd October 2025.
32+
InstanceTypeDelete = "delete"
2133
)
2234

2335
// Interface needed for tests
@@ -37,14 +49,18 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
3749
if err != nil {
3850
return false, nil, err
3951
}
40-
if s.InstanceId == nil || s.LastOperation == nil || s.LastOperation.Type == nil || s.LastOperation.State == nil {
41-
return false, nil, fmt.Errorf("create failed for instance with id %s. The response is not valid: the instance id, the last operation type or the state are missing", instanceId)
52+
if s.Status == nil {
53+
return false, nil, fmt.Errorf("create failed for instance with id %s. The response is not valid: the status is missing", instanceId)
4254
}
43-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeCreate && *s.LastOperation.State == InstanceStateSuccess {
55+
switch *s.Status {
56+
case InstanceStatusActive:
4457
return true, s, nil
45-
}
46-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeCreate && *s.LastOperation.State == InstanceStateFailed {
47-
return true, s, fmt.Errorf("create failed for instance with id %s: %s", instanceId, *s.LastOperation.Description)
58+
case InstanceStatusFailed:
59+
var failedDescription string
60+
if s.LastOperation != nil && s.LastOperation.Description != nil {
61+
failedDescription = *s.LastOperation.Description
62+
}
63+
return true, s, fmt.Errorf("create failed for instance with id %s: %s", instanceId, failedDescription)
4864
}
4965
return false, nil, nil
5066
})
@@ -59,14 +75,18 @@ func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceIn
5975
if err != nil {
6076
return false, nil, err
6177
}
62-
if s.InstanceId == nil || s.LastOperation == nil || s.LastOperation.Type == nil || s.LastOperation.State == nil {
63-
return false, nil, fmt.Errorf("update failed for instance with id %s. The response is not valid: the instance id, the last operation type or the state are missing", instanceId)
78+
if s.Status == nil {
79+
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)
6480
}
65-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeUpdate && *s.LastOperation.State == InstanceStateSuccess {
81+
switch *s.Status {
82+
case InstanceStatusActive:
6683
return true, s, nil
67-
}
68-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeUpdate && *s.LastOperation.State == InstanceStateFailed {
69-
return true, s, fmt.Errorf("update failed for instance with id %s: %s", instanceId, *s.LastOperation.Description)
84+
case InstanceStatusFailed:
85+
var failedDescription string
86+
if s.LastOperation != nil && s.LastOperation.Description != nil {
87+
failedDescription = *s.LastOperation.Description
88+
}
89+
return true, s, fmt.Errorf("update failed for instance with id %s: %s", instanceId, failedDescription)
7090
}
7191
return false, nil, nil
7292
})
@@ -79,13 +99,13 @@ func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
7999
handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
80100
s, err := a.GetInstanceExecute(ctx, projectId, instanceId)
81101
if err == nil {
82-
if s.LastOperation == nil || s.LastOperation.Type == nil || s.LastOperation.State == nil || s.LastOperation.Description == nil {
83-
return false, nil, fmt.Errorf("delete failed for instance with id %s. The response is not valid: The last operation type, description or the state are missing", instanceId)
102+
if s.LastOperation == nil || s.LastOperation.Description == nil || s.Status == nil {
103+
return false, nil, fmt.Errorf("delete failed for instance with id %s. The response is not valid: The status or last operation description are missing", instanceId)
84104
}
85-
if *s.LastOperation.Type != InstanceTypeDelete {
105+
if *s.Status != InstanceStatusDeleting {
86106
return false, nil, nil
87107
}
88-
if *s.LastOperation.State == InstanceStateSuccess {
108+
if *s.Status == InstanceStatusActive {
89109
if strings.Contains(*s.LastOperation.Description, "DeleteFailed") || strings.Contains(*s.LastOperation.Description, "failed") {
90110
return true, nil, fmt.Errorf("instance was deleted successfully but has errors: %s", *s.LastOperation.Description)
91111
}

0 commit comments

Comments
 (0)