Skip to content

Commit

Permalink
fix: handle double create 201 response
Browse files Browse the repository at this point in the history
  • Loading branch information
akijakya committed Nov 22, 2021
1 parent afb54dc commit 84ef7a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/cli/command/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,17 @@ func runCreate(banzaiCli cli.Cli, options createOptions) error {
}

log.Debugf("create request: %#v", out)
cluster, _, err := banzaiCli.Client().ClustersApi.CreateCluster(context.Background(), orgID, out)
cluster, resp, err := banzaiCli.Client().ClustersApi.CreateCluster(context.Background(), orgID, out)
if err != nil {
cli.LogAPIError("create cluster", err, out)
return errors.WrapIf(err, "failed to create cluster")
}

if resp.StatusCode == http.StatusCreated {
log.Infof(`cluster "%s" is already being created`, out["name"])
return nil
}

log.Info("cluster is being created")
if options.wait {
for {
Expand Down

0 comments on commit 84ef7a4

Please sign in to comment.