-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change GCE LB health check interval from 2s to 8s #70099
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,6 +505,14 @@ func (gce *GCECloud) ensureTargetPoolAndHealthCheck(tpExists, tpNeedsRecreation | |
return fmt.Errorf("failed to update target pool for load balancer (%s): %v", lbRefStr, err) | ||
} | ||
glog.Infof("ensureTargetPoolAndHealthCheck(%s): Updated target pool (with %d hosts).", lbRefStr, len(hosts)) | ||
if hcToCreate != nil { | ||
if hc, err := gce.ensureHttpHealthCheck(hcToCreate.Name, hcToCreate.RequestPath, int32(hcToCreate.Port)); err != nil || hc == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we probably want to add logic to keep higher values for the parameters on the healthcheck if the user has increased the value outside of Kubernetes. This gives the user a way out if their cluster is being impacted by the healthcheck volume. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic added. Unit test also added to guard the logic. |
||
return fmt.Errorf("Failed to ensure health check for %v port %d path %v: %v", loadBalancerName, hcToCreate.Port, hcToCreate.RequestPath, err) | ||
} | ||
} | ||
} else { | ||
// Panic worthy. | ||
glog.Errorf("ensureTargetPoolAndHealthCheck(%s): target pool not exists and doesn't need to be created.", lbRefStr) | ||
} | ||
return nil | ||
} | ||
|
@@ -621,6 +629,37 @@ func makeHttpHealthCheck(name, path string, port int32) *compute.HttpHealthCheck | |
} | ||
} | ||
|
||
// mergeHttpHealthChecks reconciles HttpHealthCheck configures to be no smaller | ||
// than the default values. | ||
// E.g. old health check interval is 2s, new default is 8. | ||
// The HC interval will be reconciled to 8 seconds. | ||
// If the existing health check is larger than the default interval, | ||
// the configuration will be kept. | ||
func mergeHttpHealthChecks(hc, newHC *compute.HttpHealthCheck) *compute.HttpHealthCheck { | ||
if hc.CheckIntervalSec > newHC.CheckIntervalSec { | ||
grayluck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
newHC.CheckIntervalSec = hc.CheckIntervalSec | ||
grayluck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if hc.TimeoutSec > newHC.TimeoutSec { | ||
newHC.TimeoutSec = hc.TimeoutSec | ||
grayluck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if hc.UnhealthyThreshold > newHC.UnhealthyThreshold { | ||
newHC.UnhealthyThreshold = hc.UnhealthyThreshold | ||
grayluck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if hc.HealthyThreshold > newHC.HealthyThreshold { | ||
newHC.HealthyThreshold = hc.HealthyThreshold | ||
} | ||
return newHC | ||
} | ||
|
||
// needToUpdateHttpHealthChecks checks whether the http healthcheck needs to be | ||
// updated. | ||
func needToUpdateHttpHealthChecks(hc, newHC *compute.HttpHealthCheck) bool { | ||
changed := hc.Port != newHC.Port || hc.RequestPath != newHC.RequestPath || hc.Description != newHC.Description | ||
changed = changed || hc.CheckIntervalSec < newHC.CheckIntervalSec || hc.TimeoutSec < newHC.TimeoutSec | ||
changed = changed || hc.UnhealthyThreshold < newHC.UnhealthyThreshold || hc.HealthyThreshold < newHC.HealthyThreshold | ||
return changed | ||
} | ||
|
||
func (gce *GCECloud) ensureHttpHealthCheck(name, path string, port int32) (hc *compute.HttpHealthCheck, err error) { | ||
newHC := makeHttpHealthCheck(name, path, port) | ||
hc, err = gce.GetHttpHealthCheck(name) | ||
|
@@ -639,16 +678,18 @@ func (gce *GCECloud) ensureHttpHealthCheck(name, path string, port int32) (hc *c | |
} | ||
// Validate health check fields | ||
glog.V(4).Infof("Checking http health check params %s", name) | ||
drift := hc.Port != int64(port) || hc.RequestPath != path || hc.Description != makeHealthCheckDescription(name) | ||
drift = drift || hc.CheckIntervalSec != gceHcCheckIntervalSeconds || hc.TimeoutSec != gceHcTimeoutSeconds | ||
drift = drift || hc.UnhealthyThreshold != gceHcUnhealthyThreshold || hc.HealthyThreshold != gceHcHealthyThreshold | ||
if drift { | ||
grayluck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if needToUpdateHttpHealthChecks(hc, newHC) { | ||
glog.Warningf("Health check %v exists but parameters have drifted - updating...", name) | ||
newHC = mergeHttpHealthChecks(hc, newHC) | ||
if err := gce.UpdateHttpHealthCheck(newHC); err != nil { | ||
glog.Warningf("Failed to reconcile http health check %v parameters", name) | ||
return nil, err | ||
} | ||
glog.V(4).Infof("Corrected health check %v parameters successful", name) | ||
hc, err = gce.GetHttpHealthCheck(name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return hc, nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be reducing the gceHcUnhealthyThreshold to 3, otherwise it will be very unresponsive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.