Skip to content

Commit

Permalink
fix: wrong check
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ragot committed Feb 23, 2024
1 parent c3dab70 commit 6a03058
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/fctl/cmd/stack/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func waitStackReady(cmd *cobra.Command, client *membershipclient.APIClient, prof
var stackRsp *membershipclient.CreateStackResponse

waitTime := 2 * time.Second
sum := 2 * time.Second

// Hack to ignore first Status
<-time.After(waitTime)

for {
stackRsp, resp, err = client.DefaultApi.GetStack(cmd.Context(), stack.OrganizationId, stack.Id).Execute()
if err != nil {
Expand All @@ -26,14 +31,16 @@ func waitStackReady(cmd *cobra.Command, client *membershipclient.APIClient, prof
return nil, fmt.Errorf("stack %s not found", stack.Id)
}

if stack.Status == "READY" {
if stackRsp.Data.Status == "READY" {
return stackRsp.Data, nil
}

if waitTime > 2*time.Minute {
pterm.Warning.Println("Waiting for stack to be ready...")
return nil, fmt.Errorf("there might a problem with the stack scheduling, retry and if the problem persists please contact the support")
}

sum += waitTime
select {
case <-time.After(waitTime):
case <-cmd.Context().Done():
Expand Down

0 comments on commit 6a03058

Please sign in to comment.