Skip to content

Commit 96688e4

Browse files
authored
chore(resourcemanager): allow context cancellation while waiting (#1294)
relates to #1271
1 parent 146a310 commit 96688e4

File tree

1 file changed

+7
-2
lines changed
  • stackit/internal/services/resourcemanager/folder

1 file changed

+7
-2
lines changed

stackit/internal/services/resourcemanager/folder/resource.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,17 @@ func (r *folderResource) Create(ctx context.Context, req resource.CreateRequest,
219219
return
220220
}
221221

222-
// This sleep is currently needed due to the IAM Cache.
223-
time.Sleep(10 * time.Second)
224222
ctx = utils.SetAndLogStateFields(ctx, &resp.Diagnostics, &resp.State, map[string]any{
225223
"container_id": *folderCreateResp.ContainerId,
226224
})
227225

226+
select {
227+
case <-ctx.Done():
228+
return
229+
case <-time.After(10 * time.Second): // This sleep is currently needed due to the IAM Cache.
230+
// continue
231+
}
232+
228233
folderGetResponse, err := r.client.GetFolderDetails(ctx, *folderCreateResp.ContainerId).Execute()
229234
if err != nil {
230235
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating folder", fmt.Sprintf("Calling API: %v", err))

0 commit comments

Comments
 (0)