diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2021-11-15 13:45:17 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2021-11-15 15:11:02 +0300 |
commit | f2b49b1e18ae11c5962575e41a7ffee581583866 (patch) | |
tree | 7e697b34f5621f1ca2a62f6124216e2a9f78a74c | |
parent | 51b78efbabefe3abd586a7d5fee12a52905a4af0 (diff) |
Rearrange method call in HealthManager to make them more testable
This commit pulls the `performHealthChecks` out of the `updateHealthChecks`
call. This makes it easier to test the behavior of the query in updateHealthChecks
when there are inserts in various orders.
-rw-r--r-- | internal/praefect/nodes/health_manager.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/internal/praefect/nodes/health_manager.go b/internal/praefect/nodes/health_manager.go index 502f8ce61..75946dbe9 100644 --- a/internal/praefect/nodes/health_manager.go +++ b/internal/praefect/nodes/health_manager.go @@ -96,7 +96,8 @@ func (hm *HealthManager) Run(ctx context.Context, ticker helper.Ticker) error { case <-ctx.Done(): return ctx.Err() case <-ticker.C(): - if err := hm.updateHealthChecks(ctx); err != nil { + virtualStorages, physicalStorages, healthy := hm.performHealthChecks(ctx) + if err := hm.updateHealthChecks(ctx, virtualStorages, physicalStorages, healthy); err != nil { if err := hm.handleError(err); err != nil { return err } @@ -126,9 +127,7 @@ func (hm *HealthManager) HealthConsensus() map[string][]string { return hm.healthConsensus.Load().(map[string][]string) } -func (hm *HealthManager) updateHealthChecks(ctx context.Context) error { - virtualStorages, physicalStorages, healthy := hm.performHealthChecks(ctx) - +func (hm *HealthManager) updateHealthChecks(ctx context.Context, virtualStorages, physicalStorages []string, healthy []bool) error { locallyHealthy := map[string][]string{} for i := range virtualStorages { if !healthy[i] { |