diff --git a/weed/admin/plugin/plugin_scheduler_test.go b/weed/admin/plugin/plugin_scheduler_test.go index 8db5c9e3b..118a4cf5d 100644 --- a/weed/admin/plugin/plugin_scheduler_test.go +++ b/weed/admin/plugin/plugin_scheduler_test.go @@ -834,19 +834,22 @@ func TestGracefulShutdownDuringIteration(t *testing.T) { pluginSvc, err := New(Options{ IdleSleepDuration: time.Millisecond, + ClusterContextProvider: func(_ context.Context) (*plugin_pb.ClusterContext, error) { + return &plugin_pb.ClusterContext{}, nil + }, }) if err != nil { t.Fatalf("New: %v", err) } - // Register an enabled job type. + // Register an enabled job type so the scheduler loop has work to consider. err = pluginSvc.SaveJobTypeConfig(&plugin_pb.PersistedJobTypeConfig{ JobType: "vacuum", AdminRuntime: &plugin_pb.AdminRuntimeConfig{ - Enabled: true, - DetectionTimeoutSeconds: 5, - MaxJobsPerDetection: 10, - GlobalExecutionConcurrency: 1, + Enabled: true, + DetectionTimeoutSeconds: 5, + MaxJobsPerDetection: 10, + GlobalExecutionConcurrency: 1, PerWorkerExecutionConcurrency: 1, }, }) @@ -860,7 +863,7 @@ func TestGracefulShutdownDuringIteration(t *testing.T) { }, }) - // Shutdown immediately — the scheduler loop should exit cleanly. + // Shutdown while the scheduler loop is actively iterating. done := make(chan struct{}) go func() { pluginSvc.Shutdown() diff --git a/weed/admin/view/app/plugin.templ b/weed/admin/view/app/plugin.templ index 492e494dc..d5114950d 100644 --- a/weed/admin/view/app/plugin.templ +++ b/weed/admin/view/app/plugin.templ @@ -2852,7 +2852,12 @@ templ Plugin(page string) { var allJobs = await allJobsPromise; var allActivities = await allActivitiesPromise; var schedulerStates = await schedulerPromise; - var schedulerStatus = await schedulerStatusPromise; + var schedulerStatus = null; + try { + schedulerStatus = await schedulerStatusPromise; + } catch (e) { + console.error('Failed to fetch scheduler status:', e); + } state.jobs = Array.isArray(allJobs) ? allJobs : []; state.activities = Array.isArray(allActivities) ? allActivities : [];