Skip to content

Commit

Permalink
Clone should wait for health checks to pass if any
Browse files Browse the repository at this point in the history
  • Loading branch information
rugwirobaker committed Oct 10, 2022
1 parent 0268faf commit 6c1d55a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/command/machine/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/superfly/flyctl/internal/app"
"github.com/superfly/flyctl/internal/command"
"github.com/superfly/flyctl/internal/flag"
"github.com/superfly/flyctl/internal/watch"
"github.com/superfly/flyctl/iostreams"
)

Expand Down Expand Up @@ -146,16 +147,20 @@ func runMachineClone(ctx context.Context) (err error) {
return err
}

fmt.Fprintf(out, fmt.Sprintf(" Machine %s has been created...\n", launchedMachine.ID))
fmt.Fprintf(out, " Machine %s has been created...\n", launchedMachine.ID)

fmt.Fprintf(out, fmt.Sprintf(" Waiting for machine %s to start...\n", launchedMachine.ID))
fmt.Fprintf(out, " Waiting for machine %s to start...\n", launchedMachine.ID)

// wait for a machine to be started
err = WaitForStartOrStop(ctx, launchedMachine, "start", time.Minute*5)
if err != nil {
return err
}

if err = watch.MachinesChecks(ctx, []*api.Machine{launchedMachine}); err != nil {
return fmt.Errorf("error while watching health checks: %w", err)
}

fmt.Fprintf(out, "Machine has been successfully cloned!\n")

return
Expand Down

0 comments on commit 6c1d55a

Please sign in to comment.