Skip to content

Commit

Permalink
fix incorrect state
Browse files Browse the repository at this point in the history
Signed-off-by: vietanhduong <[email protected]>
  • Loading branch information
vietanhduong committed May 30, 2023
1 parent ed4b2d0 commit dda5646
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/gcloud/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ func StartInstance(vm *apis.Vm) error {
if vm.GetState() != "TERMINATED" && vm.GetState() != "SUSPENDED" {
return errors.Errorf("instance is incorrect state (%s)", vm.GetState())
}

var cmd = "start"
if vm.GetState() == "SUSPENDED" {
cmd = "resume"
}
_, err := exec.Run(exec.Command("gcloud",
"compute",
"instances",
"start", vm.GetName(),
cmd, vm.GetName(),
"--project", vm.GetProject(),
"--zone", vm.GetZone()))
return err
Expand Down

0 comments on commit dda5646

Please sign in to comment.