From 5b4883c7aee1f6ec595c8e7130cfe6c8c647aebd Mon Sep 17 00:00:00 2001 From: Artur Troian Date: Thu, 16 Jun 2022 18:41:59 -0400 Subject: [PATCH] fix(provider): remove waitgroup for lease withdraw (#1618) fixes #eng-282 Signed-off-by: Artur Troian --- provider/balance_checker.go | 4 ++-- provider/cluster/manager.go | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/provider/balance_checker.go b/provider/balance_checker.go index 0f432e133c..6d338d0111 100644 --- a/provider/balance_checker.go +++ b/provider/balance_checker.go @@ -197,6 +197,8 @@ func (bc *balanceChecker) run(startCh chan<- error) { <-lState.tm.C } } + + bc.log.Debug("shutdown complete") }() leaseCheckCh := make(chan leaseCheckResponse, 1) @@ -308,8 +310,6 @@ loop: } } } - - bc.log.Debug("shutdown complete") } func (bc *balanceChecker) timerFunc(ctx context.Context, d time.Duration, lid mtypes.LeaseID, scheduledWithdraw bool, ch chan<- leaseCheckResponse) *time.Timer { diff --git a/provider/cluster/manager.go b/provider/cluster/manager.go index 97652706fe..db39f3f180 100644 --- a/provider/cluster/manager.go +++ b/provider/cluster/manager.go @@ -239,13 +239,14 @@ loop: dm.log.Debug("read from runch during shutdown") } - dm.log.Debug("waiting on dm.wg") - dm.wg.Wait() - if nil != dm.withdrawal { dm.log.Debug("waiting on withdrawal") - dm.withdrawal.lc.Shutdown(nil) + <-dm.withdrawal.lc.Done() } + + dm.log.Debug("waiting on dm.wg") + dm.wg.Wait() + dm.log.Info("shutdown complete") } @@ -256,12 +257,6 @@ func (dm *deploymentManager) startWithdrawal() error { return err } - dm.wg.Add(1) - go func() { - defer dm.wg.Done() - <-dm.lc.Done() - }() - return nil }