From efe60fbb459303a36233c1ad7ac0480ca33831c3 Mon Sep 17 00:00:00 2001 From: Gavin Frazar Date: Thu, 26 Jun 2025 14:06:40 -0400 Subject: [PATCH] Fix health check config equivalence check (#56050) The config timeout was not compared for equivalence before, but the only consequence of this was that the health check worker would not log a debug message about the config update if only the timeout setting changed. --- lib/healthcheck/config.go | 1 + lib/healthcheck/config_test.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/healthcheck/config.go b/lib/healthcheck/config.go index 6f47966631e..1de67559a7a 100644 --- a/lib/healthcheck/config.go +++ b/lib/healthcheck/config.go @@ -68,6 +68,7 @@ func (h *healthCheckConfig) equivalent(other *healthCheckConfig) bool { h.name == other.name && h.protocol == other.protocol && h.interval == other.interval && + h.timeout == other.timeout && h.healthyThreshold == other.healthyThreshold && h.unhealthyThreshold == other.unhealthyThreshold } diff --git a/lib/healthcheck/config_test.go b/lib/healthcheck/config_test.go index 8a1357ee061..d9edbe9910e 100644 --- a/lib/healthcheck/config_test.go +++ b/lib/healthcheck/config_test.go @@ -123,6 +123,12 @@ func TestHealthCheckConfig_equivalent(t *testing.T) { b: nil, want: true, }, + { + desc: "both empty", + a: &healthCheckConfig{}, + b: &healthCheckConfig{}, + want: true, + }, { desc: "one nil, one non-nil", a: &healthCheckConfig{}, @@ -135,6 +141,7 @@ func TestHealthCheckConfig_equivalent(t *testing.T) { name: "test", protocol: "http", interval: time.Second, + timeout: 500 * time.Millisecond, healthyThreshold: 3, unhealthyThreshold: 5, }, @@ -142,6 +149,7 @@ func TestHealthCheckConfig_equivalent(t *testing.T) { name: "test", protocol: "http", interval: time.Second, + timeout: 500 * time.Millisecond, healthyThreshold: 3, unhealthyThreshold: 5, }, @@ -153,6 +161,7 @@ func TestHealthCheckConfig_equivalent(t *testing.T) { name: "test", protocol: "http", interval: time.Second, + timeout: 500 * time.Millisecond, healthyThreshold: 3, unhealthyThreshold: 5, databaseLabelMatchers: types.LabelMatchers{Expression: "a", Labels: types.Labels{"a": {"a"}}}, @@ -161,6 +170,7 @@ func TestHealthCheckConfig_equivalent(t *testing.T) { name: "test", protocol: "http", interval: time.Second, + timeout: 500 * time.Millisecond, healthyThreshold: 3, unhealthyThreshold: 5, databaseLabelMatchers: types.LabelMatchers{Expression: "b", Labels: types.Labels{"b": {"b"}}}, @@ -197,6 +207,16 @@ func TestHealthCheckConfig_equivalent(t *testing.T) { }, want: false, }, + { + desc: "different timeout", + a: &healthCheckConfig{ + timeout: time.Second, + }, + b: &healthCheckConfig{ + timeout: 2 * time.Second, + }, + want: false, + }, { desc: "different healthyThreshold", a: &healthCheckConfig{