mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #70384 from grayluck/hccheck-cleanup
Remove return value of mergeHealthChecks. Simplified HC equivalence check
This commit is contained in:
commit
9a5b262532
@ -640,7 +640,7 @@ func makeHTTPHealthCheck(name, path string, port int32) *compute.HttpHealthCheck
|
|||||||
// The HC interval will be reconciled to 8 seconds.
|
// The HC interval will be reconciled to 8 seconds.
|
||||||
// If the existing health check is larger than the default interval,
|
// If the existing health check is larger than the default interval,
|
||||||
// the configuration will be kept.
|
// the configuration will be kept.
|
||||||
func mergeHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) *compute.HttpHealthCheck {
|
func mergeHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) {
|
||||||
if hc.CheckIntervalSec > newHC.CheckIntervalSec {
|
if hc.CheckIntervalSec > newHC.CheckIntervalSec {
|
||||||
newHC.CheckIntervalSec = hc.CheckIntervalSec
|
newHC.CheckIntervalSec = hc.CheckIntervalSec
|
||||||
}
|
}
|
||||||
@ -653,16 +653,23 @@ func mergeHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) *compute.HttpHeal
|
|||||||
if hc.HealthyThreshold > newHC.HealthyThreshold {
|
if hc.HealthyThreshold > newHC.HealthyThreshold {
|
||||||
newHC.HealthyThreshold = hc.HealthyThreshold
|
newHC.HealthyThreshold = hc.HealthyThreshold
|
||||||
}
|
}
|
||||||
return newHC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// needToUpdateHTTPHealthChecks checks whether the http healthcheck needs to be
|
// needToUpdateHTTPHealthChecks checks whether the http healthcheck needs to be
|
||||||
// updated.
|
// updated.
|
||||||
func needToUpdateHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) bool {
|
func needToUpdateHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) bool {
|
||||||
changed := hc.Port != newHC.Port || hc.RequestPath != newHC.RequestPath || hc.Description != newHC.Description
|
switch {
|
||||||
changed = changed || hc.CheckIntervalSec < newHC.CheckIntervalSec || hc.TimeoutSec < newHC.TimeoutSec
|
case
|
||||||
changed = changed || hc.UnhealthyThreshold < newHC.UnhealthyThreshold || hc.HealthyThreshold < newHC.HealthyThreshold
|
hc.Port != newHC.Port,
|
||||||
return changed
|
hc.RequestPath != newHC.RequestPath,
|
||||||
|
hc.Description != newHC.Description,
|
||||||
|
hc.CheckIntervalSec < newHC.CheckIntervalSec,
|
||||||
|
hc.TimeoutSec < newHC.TimeoutSec,
|
||||||
|
hc.UnhealthyThreshold < newHC.UnhealthyThreshold,
|
||||||
|
hc.HealthyThreshold < newHC.HealthyThreshold:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Cloud) ensureHTTPHealthCheck(name, path string, port int32) (hc *compute.HttpHealthCheck, err error) {
|
func (g *Cloud) ensureHTTPHealthCheck(name, path string, port int32) (hc *compute.HttpHealthCheck, err error) {
|
||||||
@ -685,7 +692,7 @@ func (g *Cloud) ensureHTTPHealthCheck(name, path string, port int32) (hc *comput
|
|||||||
klog.V(4).Infof("Checking http health check params %s", name)
|
klog.V(4).Infof("Checking http health check params %s", name)
|
||||||
if needToUpdateHTTPHealthChecks(hc, newHC) {
|
if needToUpdateHTTPHealthChecks(hc, newHC) {
|
||||||
klog.Warningf("Health check %v exists but parameters have drifted - updating...", name)
|
klog.Warningf("Health check %v exists but parameters have drifted - updating...", name)
|
||||||
newHC = mergeHTTPHealthChecks(hc, newHC)
|
mergeHTTPHealthChecks(hc, newHC)
|
||||||
if err := g.UpdateHTTPHealthCheck(newHC); err != nil {
|
if err := g.UpdateHTTPHealthCheck(newHC); err != nil {
|
||||||
klog.Warningf("Failed to reconcile http health check %v parameters", name)
|
klog.Warningf("Failed to reconcile http health check %v parameters", name)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -415,7 +415,7 @@ func (g *Cloud) ensureInternalHealthCheck(name string, svcName types.NamespacedN
|
|||||||
|
|
||||||
if needToUpdateHealthChecks(hc, expectedHC) {
|
if needToUpdateHealthChecks(hc, expectedHC) {
|
||||||
klog.V(2).Infof("ensureInternalHealthCheck: health check %v exists but parameters have drifted - updating...", name)
|
klog.V(2).Infof("ensureInternalHealthCheck: health check %v exists but parameters have drifted - updating...", name)
|
||||||
expectedHC = mergeHealthChecks(hc, expectedHC)
|
mergeHealthChecks(hc, expectedHC)
|
||||||
if err := g.UpdateHealthCheck(expectedHC); err != nil {
|
if err := g.UpdateHealthCheck(expectedHC); err != nil {
|
||||||
klog.Warningf("Failed to reconcile http health check %v parameters", name)
|
klog.Warningf("Failed to reconcile http health check %v parameters", name)
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -637,7 +637,7 @@ func firewallRuleEqual(a, b *compute.Firewall) bool {
|
|||||||
// The HC interval will be reconciled to 8 seconds.
|
// The HC interval will be reconciled to 8 seconds.
|
||||||
// If the existing health check is larger than the default interval,
|
// If the existing health check is larger than the default interval,
|
||||||
// the configuration will be kept.
|
// the configuration will be kept.
|
||||||
func mergeHealthChecks(hc, newHC *compute.HealthCheck) *compute.HealthCheck {
|
func mergeHealthChecks(hc, newHC *compute.HealthCheck) {
|
||||||
if hc.CheckIntervalSec > newHC.CheckIntervalSec {
|
if hc.CheckIntervalSec > newHC.CheckIntervalSec {
|
||||||
newHC.CheckIntervalSec = hc.CheckIntervalSec
|
newHC.CheckIntervalSec = hc.CheckIntervalSec
|
||||||
}
|
}
|
||||||
@ -650,18 +650,24 @@ func mergeHealthChecks(hc, newHC *compute.HealthCheck) *compute.HealthCheck {
|
|||||||
if hc.HealthyThreshold > newHC.HealthyThreshold {
|
if hc.HealthyThreshold > newHC.HealthyThreshold {
|
||||||
newHC.HealthyThreshold = hc.HealthyThreshold
|
newHC.HealthyThreshold = hc.HealthyThreshold
|
||||||
}
|
}
|
||||||
return newHC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// needToUpdateHealthChecks checks whether the healthcheck needs to be updated.
|
// needToUpdateHealthChecks checks whether the healthcheck needs to be updated.
|
||||||
func needToUpdateHealthChecks(hc, newHC *compute.HealthCheck) bool {
|
func needToUpdateHealthChecks(hc, newHC *compute.HealthCheck) bool {
|
||||||
if hc.HttpHealthCheck == nil || newHC.HttpHealthCheck == nil {
|
switch {
|
||||||
|
case
|
||||||
|
hc.HttpHealthCheck == nil,
|
||||||
|
newHC.HttpHealthCheck == nil,
|
||||||
|
hc.HttpHealthCheck.Port != newHC.HttpHealthCheck.Port,
|
||||||
|
hc.HttpHealthCheck.RequestPath != newHC.HttpHealthCheck.RequestPath,
|
||||||
|
hc.Description != newHC.Description,
|
||||||
|
hc.CheckIntervalSec < newHC.CheckIntervalSec,
|
||||||
|
hc.TimeoutSec < newHC.TimeoutSec,
|
||||||
|
hc.UnhealthyThreshold < newHC.UnhealthyThreshold,
|
||||||
|
hc.HealthyThreshold < newHC.HealthyThreshold:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
changed := hc.HttpHealthCheck.Port != newHC.HttpHealthCheck.Port || hc.HttpHealthCheck.RequestPath != newHC.HttpHealthCheck.RequestPath || hc.Description != newHC.Description
|
return false
|
||||||
changed = changed || hc.CheckIntervalSec < newHC.CheckIntervalSec || hc.TimeoutSec < newHC.TimeoutSec
|
|
||||||
changed = changed || hc.UnhealthyThreshold < newHC.UnhealthyThreshold || hc.HealthyThreshold < newHC.HealthyThreshold
|
|
||||||
return changed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// backendsListEqual asserts that backend lists are equal by instance group link only
|
// backendsListEqual asserts that backend lists are equal by instance group link only
|
||||||
|
Loading…
Reference in New Issue
Block a user