Skip to content

Commit

Permalink
fix: revert: fix: resolve indefinitely queued (STOPPING_COMPLETED) tr…
Browse files Browse the repository at this point in the history
…ials (#10207)
  • Loading branch information
tayritenour authored Nov 15, 2024
1 parent 25179d0 commit 258455d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 40 deletions.
27 changes: 0 additions & 27 deletions e2e_tests/tests/cluster/test_master_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,33 +116,6 @@ def test_master_restart_reattach_recover_experiment_k8s(
_test_master_restart_reattach_recover_experiment(k8s_managed_cluster, downtime)


@pytest.mark.managed_devcluster
def test_master_agent_restart_reattach_recover_experiment(
restartable_managed_cluster: managed_cluster.ManagedCluster,
) -> None:
sess = api_utils.user_session()

try:
# Start an experiment
exp_ref = noop.create_experiment(sess, [noop.Sleep(10)])

# Kill the agent & master
restartable_managed_cluster.kill_agent()
restartable_managed_cluster.kill_master()

# Restart the agent & master
restartable_managed_cluster.restart_master()
restartable_managed_cluster.restart_agent(True)

assert exp_ref.wait(interval=0.01) == client.ExperimentState.COMPLETED
trials = exp.experiment_trials(sess, exp_ref.id)
assert (trials[0].trial.state) == bindings.trialv1State.COMPLETED
except Exception:
restartable_managed_cluster.restart_master()
restartable_managed_cluster.restart_agent()
raise


@pytest.mark.managed_devcluster
def test_master_restart_generic_task(
managed_cluster_restarts: managed_cluster.ManagedCluster,
Expand Down
20 changes: 10 additions & 10 deletions master/internal/trial.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,16 +766,16 @@ func (t *trial) transition(s model.StateWithReason) error {
InformationalReason: s.InformationalReason,
})
default:
// For StoppingKilled and StoppingErrorState, default to KillAllocation.
action := task.KillAllocation

if (t.state == model.StoppingCompletedState) || (t.state == model.StoppingCanceledState) {
action = task.TerminateAllocation
}

t.syslog.Infof("decided to %s trial", action)
if err := task.DefaultService.Signal(*t.allocationID, action, s.InformationalReason); err != nil {
t.syslog.WithError(err).Warnf("could not %s allocation during stop", action)
if action, ok := map[model.State]task.AllocationSignal{
model.StoppingCanceledState: task.TerminateAllocation,
model.StoppingKilledState: task.KillAllocation,
model.StoppingErrorState: task.KillAllocation,
}[t.state]; ok {
t.syslog.Infof("decided to %s trial", action)
err := task.DefaultService.Signal(*t.allocationID, action, s.InformationalReason)
if err != nil {
t.syslog.WithError(err).Warnf("could not %s allocation during stop", action)
}
}
}
case model.TerminalStates[t.state]:
Expand Down
5 changes: 2 additions & 3 deletions master/internal/trial_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func TestTrial(t *testing.T) {
EarlyStoppedBySearcher: false,
EarlyExitedByUserCode: false,
}))
require.True(t, alloc.AssertExpectations(t))
require.NotNil(t, tr.allocationID)

// Running stage.
require.NoError(t, tr.PatchSearcherState(experiment.TrialSearcherState{
Create: searcher.Create{},
EarlyStoppedBySearcher: true,
EarlyExitedByUserCode: false,
}))
require.True(t, alloc.AssertExpectations(t))
require.NotNil(t, tr.allocationID)

dbTrial, err := internaldb.TrialByID(context.TODO(), tr.id)
require.NoError(t, err)
Expand Down Expand Up @@ -123,7 +123,6 @@ func setup(t *testing.T) (
"StartAllocation", mock.Anything, mock.Anything, mock.Anything,
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
).Return(nil)
as.On("Signal", mock.Anything, mock.Anything, mock.Anything).Return(nil)

a, _, _ := setupAPITest(t, nil)
j := &model.Job{JobID: model.NewJobID(), JobType: model.JobTypeExperiment}
Expand Down

0 comments on commit 258455d

Please sign in to comment.