Skip to content

Commit

Permalink
consider machines that are in "destroying" state inactive, and keep r…
Browse files Browse the repository at this point in the history
…elease_command machine after exit
  • Loading branch information
tvdfly authored and dangra committed Jan 25, 2023
1 parent 9bd4fa7 commit 1dcbf77
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 3 additions & 2 deletions api/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const MachineFlyPlatformVersion2 = "v2"
const MachineProcessGroupApp = "app"
const MachineProcessGroupFlyAppReleaseCommand = "fly_app_release_command"
const MachineStateDestroyed = "destroyed"
const MachineStateDestroying = "destroying"
const MachineStateStarted = "started"
const MachineStateStopped = "stopped"

Expand Down Expand Up @@ -51,15 +52,15 @@ func (m Machine) ImageRefWithVersion() string {
}

func (m *Machine) IsFlyAppsPlatform() bool {
return m.Config != nil && m.Config.Metadata[MachineConfigMetadataKeyFlyPlatformVersion] == MachineFlyPlatformVersion2 && m.State != MachineStateDestroyed
return m.Config != nil && m.Config.Metadata[MachineConfigMetadataKeyFlyPlatformVersion] == MachineFlyPlatformVersion2 && m.IsActive()
}

func (m *Machine) IsFlyAppsReleaseCommand() bool {
return m.IsFlyAppsPlatform() && m.HasProcessGroup(MachineProcessGroupFlyAppReleaseCommand)
}

func (m *Machine) IsActive() bool {
return m.State != MachineStateDestroyed
return m.State != MachineStateDestroyed && m.State != MachineStateDestroying
}

func (m *Machine) HasProcessGroup(desired string) bool {
Expand Down
6 changes: 0 additions & 6 deletions internal/command/deploy/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,6 @@ func (md *machineDeployment) runReleaseCommand(ctx context.Context) error {
return fmt.Errorf("error running release_command machine: %w", err)
}
releaseCmdMachine := md.releaseCommandMachine.GetMachines()[0]
defer func() {
err := releaseCmdMachine.Destroy(ctx, true)
if err != nil {
terminal.Warnf("Error destroying release_command machine %s: %v\n", md.colorize.Bold(releaseCmdMachine.Machine().ID), err)
}
}()
// FIXME: consolidate this wait stuff with deploy waits? Especially once we improve the outpu
err = releaseCmdMachine.WaitForState(ctx, api.MachineStateStarted, md.waitTimeout)
if err != nil {
Expand Down

0 comments on commit 1dcbf77

Please sign in to comment.