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.
This commit is contained in:
Gavin Frazar
2025-06-26 18:06:40 +00:00
committed by GitHub
parent 1a539b7043
commit efe60fbb45
2 changed files with 21 additions and 0 deletions
+1
View File
@@ -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
}
+20
View File
@@ -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{