Skip to content

Commit

Permalink
fix(serverless): catch 400001 error when cluster is gone
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kropachev authored and rjeczalik committed Aug 22, 2023
1 parent cf91f8f commit 1bfc3ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions internal/provider/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter
}

reqs, err := c.ListClusterRequest(ctx, clusterID, "CREATE_CLUSTER")
if scylla.IsDeletedErr(err) {
switch {
case scylla.IsDeletedErr(err):
_ = d.Set("status", "DELETED")
return nil
} else if err != nil {
case err != nil:
return diag.Errorf("error reading cluster request: %s", err)
}
if len(reqs) != 1 {
case len(reqs) != 1:
return diag.Errorf("unexpected number of cluster requests, expected 1, got: %+v", reqs)
}
_ = d.Set("request_id", reqs[0].ID)
Expand Down
10 changes: 7 additions & 3 deletions internal/provider/serverless_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ func resourceServerlessClusterRead(ctx context.Context, d *schema.ResourceData,
}

reqs, err := c.ListClusterRequest(ctx, clusterID, "CREATE_CLUSTER")
if err != nil {
switch {
case scylla.IsDeletedErr(err):
_ = d.Set("status", "DELETED")
return nil
case err != nil:
return diag.Errorf("error reading serverless cluster request: %s", err)
}
if len(reqs) != 1 {
case len(reqs) != 1:
return diag.Errorf("unexpected number of serverless cluster requests, expected 1, got: %+v", reqs)
}
_ = d.Set("request_id", reqs[0].ID)

if reqs[0].Status != "COMPLETED" {
if err := waitForCluster(ctx, c, reqs[0].ID); err != nil {
Expand Down

0 comments on commit 1bfc3ff

Please sign in to comment.