mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-03 14:47:04 +00:00
fix: add ClusterContextProvider to shutdown test and handle status fetch errors
Address PR review nitpicks: - Add ClusterContextProvider to TestGracefulShutdownDuringIteration so the scheduler loop actually starts (New() requires it). - Wrap schedulerStatusPromise await in try/catch in plugin.templ so a failed status fetch does not break refreshJobsAndActivities rendering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
35786d72e0
commit
6289beb8f5
@@ -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()
|
||||
|
||||
@@ -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 : [];
|
||||
|
||||
Reference in New Issue
Block a user