Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Hiltunen <shiltunen@gitlab.com>2021-11-15 13:45:17 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2021-11-15 15:11:02 +0300
commitf2b49b1e18ae11c5962575e41a7ffee581583866 (patch)
tree7e697b34f5621f1ca2a62f6124216e2a9f78a74c
parent51b78efbabefe3abd586a7d5fee12a52905a4af0 (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.go7
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] {