Skip to content

Commit c3472a5

Browse files
authored
Recommend cloning the machine if can't start due to capacity (#2782)
1 parent e80948c commit c3472a5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/command/machine/start.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package machine
33
import (
44
"context"
55
"fmt"
6+
"github.com/superfly/flyctl/internal/appconfig"
7+
"strings"
68

79
"github.com/spf13/cobra"
810
"github.com/superfly/flyctl/flaps"
@@ -59,10 +61,16 @@ func runMachineStart(ctx context.Context) (err error) {
5961
func Start(ctx context.Context, machineID string) (err error) {
6062
machine, err := flaps.FromContext(ctx).Start(ctx, machineID, "")
6163
if err != nil {
62-
if err := rewriteMachineNotFoundErrors(ctx, err, machineID); err != nil {
63-
return err
64+
//TODO(dov): just do the clone
65+
switch {
66+
case strings.Contains(err.Error(), " for machine"):
67+
return fmt.Errorf("could not start machine due to lack of capacity. Try 'flyctl machine clone %s -a %s'", machineID, appconfig.NameFromContext(ctx))
68+
default:
69+
if err := rewriteMachineNotFoundErrors(ctx, err, machineID); err != nil {
70+
return err
71+
}
72+
return fmt.Errorf("could not start machine %s: %w", machineID, err)
6473
}
65-
return fmt.Errorf("could not start machine %s: %w", machineID, err)
6674
}
6775

6876
if machine.Status == "error" {

0 commit comments

Comments
 (0)