From 84ef7a4eb777157d784073456b54824e370f0682 Mon Sep 17 00:00:00 2001 From: Andras Jaky Date: Mon, 22 Nov 2021 15:20:33 +0100 Subject: [PATCH] fix: handle double create 201 response --- internal/cli/command/cluster/create.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/cli/command/cluster/create.go b/internal/cli/command/cluster/create.go index 87bd556b..7f6f528e 100644 --- a/internal/cli/command/cluster/create.go +++ b/internal/cli/command/cluster/create.go @@ -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 {