From f0ef01de5b9c09d67170b81e94be2126bde3fa7f Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Sun, 23 Aug 2020 18:10:14 +0300 Subject: [PATCH] storagenode/gracefulexit: retry workers faster Change-Id: Ica20a691ff117a2b36a6362ee1fed21ce49a9ac1 --- storagenode/gracefulexit/chore.go | 8 +++++++- storagenode/gracefulexit/chore_test.go | 2 ++ storagenode/gracefulexit/common.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/storagenode/gracefulexit/chore.go b/storagenode/gracefulexit/chore.go index fa453ed5d..a3db725a8 100644 --- a/storagenode/gracefulexit/chore.go +++ b/storagenode/gracefulexit/chore.go @@ -99,14 +99,20 @@ func (chore *Chore) Run(ctx context.Context) (err error) { } }) } - chore.limiter.Wait() return nil }) + chore.limiter.Wait() + return err } +// TestWaitForWorkers waits for any pending worker to finish. +func (chore *Chore) TestWaitForWorkers() { + chore.limiter.Wait() +} + // Close closes chore. func (chore *Chore) Close() error { chore.Loop.Close() diff --git a/storagenode/gracefulexit/chore_test.go b/storagenode/gracefulexit/chore_test.go index 0bb5e7d1f..ebf57134c 100644 --- a/storagenode/gracefulexit/chore_test.go +++ b/storagenode/gracefulexit/chore_test.go @@ -106,6 +106,8 @@ func exitSatellite(ctx context.Context, t *testing.T, planet *testplanet.Planet, // run the SN chore again to start processing transfers. exitingNode.GracefulExit.Chore.Loop.TriggerWait() + // wait for workers to finish + exitingNode.GracefulExit.Chore.TestWaitForWorkers() // check that there are no more items to process queueItems, err = satellite1.DB.GracefulExit().GetIncomplete(ctx, exitStatus.NodeID, 10, 0) diff --git a/storagenode/gracefulexit/common.go b/storagenode/gracefulexit/common.go index 6374d0253..55422143a 100644 --- a/storagenode/gracefulexit/common.go +++ b/storagenode/gracefulexit/common.go @@ -21,7 +21,7 @@ var ( // Config for graceful exit. type Config struct { - ChoreInterval time.Duration `help:"how often to run the chore to check for satellites for the node to exit." releaseDefault:"15m" devDefault:"10s"` + ChoreInterval time.Duration `help:"how often to run the chore to check for satellites for the node to exit." releaseDefault:"1m" devDefault:"10s"` NumWorkers int `help:"number of workers to handle satellite exits" default:"4"` NumConcurrentTransfers int `help:"number of concurrent transfers per graceful exit worker" default:"5"` MinBytesPerSecond memory.Size `help:"the minimum acceptable bytes that an exiting node can transfer per second to the new node" default:"5KB"`