Skip to content

Commit 8069a7b

Browse files
committed
fix: waiter for
- logme - mariadb - opensearch - redis - Adapted tests - Update CHANGELOG.md
1 parent bf29127 commit 8069a7b

File tree

13 files changed

+199
-208
lines changed

13 files changed

+199
-208
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
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-01)
5+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
6+
- `mariadb`: [v0.21.2](services/mariadb/CHANGELOG.md#v0212-2025-04-01)
7+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
8+
- `opensearch`: [v0.20.2](services/opensearch/CHANGELOG.md#v0202-2025-04-01)
9+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
10+
- `redis`: [v0.21.2](services/redis/CHANGELOG.md#v0212-2025-04-01)
11+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
12+
13+
414

515
## Release (2025-03-27)
16+
617
- `alb`: [v0.2.1](services/alb/CHANGELOG.md#v021-2025-03-27)
718
- **Bugfix:** Removed ConfigureRegion() from API client
819
- `cdn`: [v0.1.1](services/cdn/CHANGELOG.md#v011-2025-03-27)

services/logme/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.21.2 (2025-04-01)
2+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
3+
14
## v0.21.1 (2025-03-19)
25
- **Internal:** Backwards compatible change to generated code
36

services/logme/wait/wait.go

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import (
1313
)
1414

1515
const (
16-
InstanceStateSuccess = "succeeded"
17-
InstanceStateFailed = "failed"
18-
InstanceTypeCreate = "create"
19-
InstanceTypeUpdate = "update"
20-
InstanceTypeDelete = "delete"
16+
InstanceStatusActive = "active"
17+
InstanceStatusFailed = "failed"
18+
InstanceStatusDeleting = "deleting"
19+
InstanceStateSuccess = "succeeded"
2120
)
2221

2322
// Interface needed for tests
@@ -37,14 +36,18 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
3736
if err != nil {
3837
return false, nil, err
3938
}
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)
39+
if s.InstanceId == nil || s.Status == nil {
40+
return false, nil, fmt.Errorf("create failed for instance with id %s. The response is not valid: the instance id or the status are missing", instanceId)
4241
}
43-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeCreate && *s.LastOperation.State == InstanceStateSuccess {
42+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusActive {
4443
return true, s, nil
4544
}
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)
45+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusFailed {
46+
var failedDescription string
47+
if s.LastOperation != nil && s.LastOperation.Description != nil {
48+
failedDescription = *s.LastOperation.Description
49+
}
50+
return true, s, fmt.Errorf("create failed for instance with id %s: %s", instanceId, failedDescription)
4851
}
4952
return false, nil, nil
5053
})
@@ -59,14 +62,18 @@ func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceIn
5962
if err != nil {
6063
return false, nil, err
6164
}
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)
65+
if s.InstanceId == nil || s.Status == nil {
66+
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)
6467
}
65-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeUpdate && *s.LastOperation.State == InstanceStateSuccess {
68+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusActive {
6669
return true, s, nil
6770
}
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)
71+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusFailed {
72+
var failedDescription string
73+
if s.LastOperation != nil && s.LastOperation.Description != nil {
74+
failedDescription = *s.LastOperation.Description
75+
}
76+
return true, s, fmt.Errorf("update failed for instance with id %s: %s", instanceId, failedDescription)
7077
}
7178
return false, nil, nil
7279
})
@@ -79,10 +86,10 @@ func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
7986
handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
8087
s, err := a.GetInstanceExecute(ctx, projectId, instanceId)
8188
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)
89+
if s.LastOperation == nil || s.Status == nil || s.LastOperation.State == nil || s.LastOperation.Description == nil {
90+
return false, nil, fmt.Errorf("delete failed for instance with id %s. The response is not valid: The status last operation type, description or the state are missing", instanceId)
8491
}
85-
if *s.LastOperation.Type != InstanceTypeDelete {
92+
if *s.Status != InstanceStatusDeleting {
8693
return false, nil, nil
8794
}
8895
if *s.LastOperation.State == InstanceStateSuccess {

services/logme/wait/wait_test.go

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ type apiClientInstanceMocked struct {
2121
resourceDescription string
2222
}
2323

24-
var (
25-
instanceTypeCreate = InstanceTypeCreate
26-
instanceTypeUpdate = InstanceTypeUpdate
27-
instanceTypeDelete = InstanceTypeDelete
24+
const (
25+
instanceTypeDelete = "delete"
2826
)
2927

3028
func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _ string) (*logme.Instance, error) {
@@ -33,10 +31,11 @@ func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _ str
3331
StatusCode: 500,
3432
}
3533
}
36-
if *a.resourceOperation == InstanceTypeDelete && a.resourceState == InstanceStateSuccess {
34+
if a.resourceOperation != nil && *a.resourceOperation == instanceTypeDelete && a.resourceState == InstanceStateSuccess {
3735
if a.deletionSucceedsWithErrors {
3836
return &logme.Instance{
3937
InstanceId: &a.resourceId,
38+
Status: &a.resourceState,
4039
LastOperation: &logme.InstanceLastOperation{
4140
Description: &a.resourceDescription,
4241
Type: a.resourceOperation,
@@ -51,11 +50,7 @@ func (a *apiClientInstanceMocked) GetInstanceExecute(_ context.Context, _, _ str
5150

5251
return &logme.Instance{
5352
InstanceId: &a.resourceId,
54-
LastOperation: &logme.InstanceLastOperation{
55-
Description: &a.resourceDescription,
56-
Type: a.resourceOperation,
57-
State: &a.resourceState,
58-
},
53+
Status: utils.Ptr(a.resourceState),
5954
}, nil
6055
}
6156

@@ -96,14 +91,14 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
9691
{
9792
desc: "create_succeeded",
9893
getFails: false,
99-
resourceState: InstanceStateSuccess,
94+
resourceState: InstanceStatusActive,
10095
wantErr: false,
10196
wantResp: true,
10297
},
10398
{
10499
desc: "create_failed",
105100
getFails: false,
106-
resourceState: InstanceStateFailed,
101+
resourceState: InstanceStatusFailed,
107102
wantErr: true,
108103
wantResp: true,
109104
},
@@ -126,21 +121,16 @@ func TestCreateInstanceWaitHandler(t *testing.T) {
126121
instanceId := "foo-bar"
127122

128123
apiClient := &apiClientInstanceMocked{
129-
getFails: tt.getFails,
130-
resourceId: instanceId,
131-
resourceOperation: &instanceTypeCreate,
132-
resourceState: tt.resourceState,
124+
getFails: tt.getFails,
125+
resourceId: instanceId,
126+
resourceState: tt.resourceState,
133127
}
134128

135129
var wantRes *logme.Instance
136130
if tt.wantResp {
137131
wantRes = &logme.Instance{
138132
InstanceId: &instanceId,
139-
LastOperation: &logme.InstanceLastOperation{
140-
Type: &instanceTypeCreate,
141-
State: utils.Ptr(tt.resourceState),
142-
Description: utils.Ptr(""),
143-
},
133+
Status: utils.Ptr(tt.resourceState),
144134
}
145135
}
146136

@@ -170,14 +160,14 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
170160
{
171161
desc: "update_succeeded",
172162
getFails: false,
173-
resourceState: InstanceStateSuccess,
163+
resourceState: InstanceStatusActive,
174164
wantErr: false,
175165
wantResp: true,
176166
},
177167
{
178168
desc: "update_failed",
179169
getFails: false,
180-
resourceState: InstanceStateFailed,
170+
resourceState: InstanceStatusFailed,
181171
wantErr: true,
182172
wantResp: true,
183173
},
@@ -200,21 +190,16 @@ func TestUpdateInstanceWaitHandler(t *testing.T) {
200190
instanceId := "foo-bar"
201191

202192
apiClient := &apiClientInstanceMocked{
203-
getFails: tt.getFails,
204-
resourceId: instanceId,
205-
resourceOperation: &instanceTypeUpdate,
206-
resourceState: tt.resourceState,
193+
getFails: tt.getFails,
194+
resourceId: instanceId,
195+
resourceState: tt.resourceState,
207196
}
208197

209198
var wantRes *logme.Instance
210199
if tt.wantResp {
211200
wantRes = &logme.Instance{
212201
InstanceId: &instanceId,
213-
LastOperation: &logme.InstanceLastOperation{
214-
Type: &instanceTypeUpdate,
215-
State: utils.Ptr(tt.resourceState),
216-
Description: utils.Ptr(""),
217-
},
202+
Status: utils.Ptr(tt.resourceState),
218203
}
219204
}
220205

@@ -254,7 +239,7 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
254239
desc: "delete_failed",
255240
getFails: false,
256241
deleteSucceeedsWithErrors: false,
257-
resourceState: InstanceStateFailed,
242+
resourceState: InstanceStatusFailed,
258243
wantErr: true,
259244
wantResp: true,
260245
},
@@ -283,7 +268,7 @@ func TestDeleteInstanceWaitHandler(t *testing.T) {
283268
getFails: tt.getFails,
284269
deletionSucceedsWithErrors: tt.deleteSucceeedsWithErrors,
285270
resourceId: instanceId,
286-
resourceOperation: &instanceTypeDelete,
271+
resourceOperation: utils.Ptr(instanceTypeDelete),
287272
resourceDescription: tt.resourceDescription,
288273
resourceState: tt.resourceState,
289274
}

services/mariadb/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.21.2 (2025-04-01)
2+
- **Bugfix:** `PartialUpdateInstanceWaitHandler` does not finish when update is succeeded
3+
14
## v0.21.1 (2025-03-19)
25
- **Internal:** Backwards compatible change to generated code
36

services/mariadb/wait/wait.go

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import (
1313
)
1414

1515
const (
16-
InstanceStateSuccess = "succeeded"
17-
InstanceStateFailed = "failed"
18-
InstanceTypeCreate = "create"
19-
InstanceTypeUpdate = "update"
20-
InstanceTypeDelete = "delete"
16+
InstanceStatusActive = "active"
17+
InstanceStatusFailed = "failed"
18+
InstanceStatusDeleting = "deleting"
19+
InstanceStateSuccess = "succeeded"
2120
)
2221

2322
// Interface needed for tests
@@ -37,14 +36,18 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
3736
if err != nil {
3837
return false, nil, err
3938
}
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)
39+
if s.InstanceId == nil || s.Status == nil {
40+
return false, nil, fmt.Errorf("create failed for instance with id %s. The response is not valid: the instance id or the status are missing", instanceId)
4241
}
43-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeCreate && *s.LastOperation.State == InstanceStateSuccess {
42+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusActive {
4443
return true, s, nil
4544
}
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)
45+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusFailed {
46+
var failedDescription string
47+
if s.LastOperation != nil && s.LastOperation.Description != nil {
48+
failedDescription = *s.LastOperation.Description
49+
}
50+
return true, s, fmt.Errorf("create failed for instance with id %s: %s", instanceId, failedDescription)
4851
}
4952
return false, nil, nil
5053
})
@@ -59,14 +62,18 @@ func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceIn
5962
if err != nil {
6063
return false, nil, err
6164
}
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)
65+
if s.InstanceId == nil || s.Status == nil {
66+
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)
6467
}
65-
if *s.InstanceId == instanceId && *s.LastOperation.Type == InstanceTypeUpdate && *s.LastOperation.State == InstanceStateSuccess {
68+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusActive {
6669
return true, s, nil
6770
}
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)
71+
if *s.InstanceId == instanceId && *s.Status == InstanceStatusFailed {
72+
var failedDescription string
73+
if s.LastOperation != nil && s.LastOperation.Description != nil {
74+
failedDescription = *s.LastOperation.Description
75+
}
76+
return true, s, fmt.Errorf("update failed for instance with id %s: %s", instanceId, failedDescription)
7077
}
7178
return false, nil, nil
7279
})
@@ -79,10 +86,10 @@ func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
7986
handler := wait.New(func() (waitFinished bool, response *struct{}, err error) {
8087
s, err := a.GetInstanceExecute(ctx, projectId, instanceId)
8188
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)
89+
if s.LastOperation == nil || s.Status == nil || s.LastOperation.State == nil || s.LastOperation.Description == nil {
90+
return false, nil, fmt.Errorf("delete failed for instance with id %s. The response is not valid: The status, last operation type, description or the state are missing", instanceId)
8491
}
85-
if *s.LastOperation.Type != InstanceTypeDelete {
92+
if *s.Status != InstanceStatusDeleting {
8693
return false, nil, nil
8794
}
8895
if *s.LastOperation.State == InstanceStateSuccess {

0 commit comments

Comments
 (0)