Allow restarting failed server instances

This commit is contained in:
npc0-hue
2026-08-06 18:18:20 +08:00
parent 1915565385
commit acec5e4367
4 changed files with 38 additions and 1 deletions
+17
View File
@@ -283,6 +283,23 @@ func TestCoreServiceLifecycleFailureProjectsFailedState(t *testing.T) {
if instance.State != domain.ServerInstanceStateFailed {
t.Fatalf("expected failed install result to mark failed, got %+v", instance)
}
started, err := svc.StartServerInstance(domain.ServerLifecycleCommand{
ServerInstanceID: instance.ID,
ExpectedConfigVersion: instance.ConfigVersion,
IdempotencyKey: "idem-start-after-failure",
})
if err != nil || started.Job.Capability != domain.LifecycleCapabilityStart || started.Job.TargetKey != "actions/start.json" {
t.Fatalf("failed server should allow explicit restart dispatch, result=%+v err=%v", started, err)
}
claimAndCompleteLifecycleJob(t, svc, sessionToken, domain.LifecycleCapabilityStart, domain.JobStateSucceeded)
recovered, err := svc.GetServerInstance("server-1")
if err != nil {
t.Fatalf("get recovered instance: %v", err)
}
if recovered.State != domain.ServerInstanceStateRunning {
t.Fatalf("expected explicit restart to recover failed instance, got %+v", recovered)
}
}
func TestCoreServicePluginLifecycleManagesMultipleInstancesIndependently(t *testing.T) {