From e0cccae7945787c9caa1648894a1dcbc460c68e0 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 3 Mar 2026 19:05:56 -0800 Subject: [PATCH] fix: add -scheduler.idleSleep flag to prevent EC integration test hang The new 17-minute default idle sleep caused TestEcEndToEnd to hang because the scheduler would not re-check for work frequently enough after the first iteration found nothing. Add -scheduler.idleSleep CLI flag (in seconds) to configure the idle sleep duration. The EC integration test now passes -scheduler.idleSleep=2 so detection runs every 2 seconds when idle. Co-Authored-By: Claude Opus 4.6 --- .../admin_dockertest/ec_integration_test.go | 2 +- weed/admin/dash/admin_server.go | 8 +++++--- weed/command/admin.go | 8 +++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test/erasure_coding/admin_dockertest/ec_integration_test.go b/test/erasure_coding/admin_dockertest/ec_integration_test.go index 21f872ea1..de6456c46 100644 --- a/test/erasure_coding/admin_dockertest/ec_integration_test.go +++ b/test/erasure_coding/admin_dockertest/ec_integration_test.go @@ -135,7 +135,7 @@ func ensureEnvironment(t *testing.T) { // 6. Start Admin os.RemoveAll(filepath.Join("tmp", "admin")) os.MkdirAll(filepath.Join("tmp", "admin"), 0755) - startWeed(t, "admin", "admin", "-master=localhost:9333", "-port=23646", "-dataDir=./tmp/admin") + startWeed(t, "admin", "admin", "-master=localhost:9333", "-port=23646", "-dataDir=./tmp/admin", "-scheduler.idleSleep=2") waitForUrl(t, AdminUrl+"/health", 60) t.Log("Environment started successfully") diff --git a/weed/admin/dash/admin_server.go b/weed/admin/dash/admin_server.go index 2bade9dec..1ac9f6df4 100644 --- a/weed/admin/dash/admin_server.go +++ b/weed/admin/dash/admin_server.go @@ -118,7 +118,7 @@ type AdminServer struct { // Type definitions moved to types.go -func NewAdminServer(masters string, templateFS http.FileSystem, dataDir string, icebergPort int) *AdminServer { +func NewAdminServer(masters string, templateFS http.FileSystem, dataDir string, icebergPort int, idleSleepDuration time.Duration) *AdminServer { grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.admin") // Create master client with multiple master support @@ -229,7 +229,8 @@ func NewAdminServer(masters string, templateFS http.FileSystem, dataDir string, } plugin, err := adminplugin.New(adminplugin.Options{ - DataDir: dataDir, + DataDir: dataDir, + IdleSleepDuration: idleSleepDuration, ClusterContextProvider: func(_ context.Context) (*plugin_pb.ClusterContext, error) { return server.buildDefaultPluginClusterContext(), nil }, @@ -238,7 +239,8 @@ func NewAdminServer(masters string, templateFS http.FileSystem, dataDir string, if err != nil && dataDir != "" { glog.Warningf("Failed to initialize plugin with dataDir=%q: %v. Falling back to in-memory plugin state.", dataDir, err) plugin, err = adminplugin.New(adminplugin.Options{ - DataDir: "", + DataDir: "", + IdleSleepDuration: idleSleepDuration, ClusterContextProvider: func(_ context.Context) (*plugin_pb.ClusterContext, error) { return server.buildDefaultPluginClusterContext(), nil }, diff --git a/weed/command/admin.go b/weed/command/admin.go index f843af39d..ebeb8f969 100644 --- a/weed/command/admin.go +++ b/weed/command/admin.go @@ -45,6 +45,7 @@ type AdminOptions struct { readOnlyPassword *string dataDir *string icebergPort *int + idleSleepSeconds *int } func init() { @@ -60,6 +61,7 @@ func init() { a.readOnlyUser = cmdAdmin.Flag.String("readOnlyUser", "", "read-only user username (optional, for view-only access)") a.readOnlyPassword = cmdAdmin.Flag.String("readOnlyPassword", "", "read-only user password (optional, for view-only access; requires adminPassword to be set)") a.icebergPort = cmdAdmin.Flag.Int("iceberg.port", 8181, "Iceberg REST Catalog port (0 to hide in UI)") + a.idleSleepSeconds = cmdAdmin.Flag.Int("scheduler.idleSleep", 0, "scheduler idle sleep in seconds between iterations when no work is found (0 = default 17 minutes)") } var cmdAdmin = &Command{ @@ -290,7 +292,11 @@ func startAdminServer(ctx context.Context, options AdminOptions, enableUI bool, } // Create admin server (plugin is always enabled) - adminServer := dash.NewAdminServer(*options.master, nil, dataDir, icebergPort) + var idleSleep time.Duration + if options.idleSleepSeconds != nil && *options.idleSleepSeconds > 0 { + idleSleep = time.Duration(*options.idleSleepSeconds) * time.Second + } + adminServer := dash.NewAdminServer(*options.master, nil, dataDir, icebergPort, idleSleep) // Show discovered filers filers := adminServer.GetAllFilers()