Skip to content
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

allow ELB Healthcheck configuration via Service annotations #56024

Merged

Conversation

dimpavloff
Copy link
Contributor

What this PR does / why we need it:
The default settings which are set on the ELB HC work well but there are cases when it would be better to tweak its parameters -- for example, faster detection of unhealthy backends. This PR makes it possible to override any of the healthcheck's parameters via annotations on the Service, with the exception of the Target setting which continues to be inferred from the Service's spec.

Release note:

It is now possible to override the healthcheck parameters for AWS ELBs via annotations on the corresponding service. The new annotations are `healthy-threshold`, `unhealthy-threshold`, `timeout`, `interval` (all prefixed with `service.beta.kubernetes.io/aws-load-balancer-healthcheck-`)

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 19, 2017
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 19, 2017
@dimpavloff
Copy link
Contributor Author

dimpavloff commented Nov 19, 2017

Hi!
I couldn't find a corresponding GH issue for my PR, hopefully my change makes sense to you. While writing the PR, the following crossed my mind:

  • Azure and GKE also use hard-coded values for their healthchecks. It would be nicer than my current PR to have cloud-agnostic annotations to control the HC. However, I don't know whether the parameters can match exactly and, if they don't, whether it will be acceptable to have each cloud provider implementation interpret these annotations (slightly) differently. So in the interest of smaller change sets I've stuck with with AWS-specific annotations. It should be straightforward to adapt my implementation to handle an addition of cloud-agnostic annotations.

  • I am on the fence whether to add an override for the HC's Target. Having an override can be handy when the Service has multiple ports -- relying on the order in which the ports are declared in the Service is hackier, IMO. OTOH, it is useful for the HC to be derived from the Service's spec because this ensures there's no drift between the HC Target and the ports exposed by the Service, which won't be the case if there's an annotation. Let me know what you think about this, I would be happy to make the addition for Target if you think it would be overall better.

This is my first PR, let me know if I could be reusing some functionality or if my style is inconsistent. Thanks! :)

}
return &i64, nil
}
if i, err := getOrDefault(ServiceAnnotationLoadBalancerHCHealthyThreshold, defaultHCHealthyThreshold); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be easier as:

var err error
healthcheck.HealthyThreshold, err = getOrDefault(ServiceAnnotationLoadBalancerHCHealthyThreshold, defaultHCHealthyThreshold)
if err != nil {
return nil, err
}
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, of course! It looks much nicer now, thanks!

if err != nil {
return fmt.Errorf("cannot update health check for load balancer %q: %q", name, err)
}
if reflect.DeepEqual(expected, actual) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dangerous, because it breaks if another field is added to the struct in future. Safer to use the explicit field-by-field comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've fixed it, please take another look. I've opted for using aws.Int64Value instead of the less verbose orZero because it's docs say it is deprecated.

@justinsb
Copy link
Member

/ok-to-test

This is really great, thank you @dimpavloff . I agree with just allowing the 4 "timing" values to be set - at least initially.

I had a suggestion on a simpler way (maybe) to write the get-or-default calls, but that was only an idea. But that's only a suggestion, your way works great.

If you can fix the use of reflect.DeepEqual though I think this looks good. If you can do it today we can get it into 1.9 I think.

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 21, 2017
@dimpavloff dimpavloff force-pushed the aws-elb-set-hc-params branch 2 times, most recently from 1bbfae0 to b1526be Compare November 21, 2017 14:26
The constants which have been used so far have been set as default in
case the annotations have not been set.
Copy link
Contributor Author

@dimpavloff dimpavloff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing, @justinsb :) I've updated the PR and fixed the bazel test dependency, please take another look.

If you can do it today we can get it into 1.9 I think.

Amazing!

}
return &i64, nil
}
if i, err := getOrDefault(ServiceAnnotationLoadBalancerHCHealthyThreshold, defaultHCHealthyThreshold); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, of course! It looks much nicer now, thanks!

if err != nil {
return fmt.Errorf("cannot update health check for load balancer %q: %q", name, err)
}
if reflect.DeepEqual(expected, actual) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've fixed it, please take another look. I've opted for using aws.Int64Value instead of the less verbose orZero because it's docs say it is deprecated.

@justinsb
Copy link
Member

/lgtm

/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 22, 2017
@justinsb justinsb added this to the v1.9 milestone Nov 22, 2017
@justinsb justinsb added status/approved-for-milestone priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Nov 22, 2017
@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 22, 2017
@dimpavloff
Copy link
Contributor Author

/kind kind/feature

@justinsb
Copy link
Member

/approve no-issue

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 22, 2017
@justinsb justinsb added priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 22, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 22, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dimpavloff, justinsb

Associated issue requirement bypassed by: justinsb

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@justinsb justinsb removed the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Nov 22, 2017
@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Pull Request Needs Attention

@dimpavloff @jsafrane @justinsb @zmerlynn @kubernetes/sig-aws-misc

Action required: During code slush, pull requests in the milestone should be in progress.
If this pull request is not being actively worked on, please remove it from the milestone.
If it is being worked on, please add the status/in-progress label so it can be tracked with other in-flight pull requests.

Note: This pull request is marked as priority/critical-urgent, and must be updated every 3 days during code slush.

Example update:

ACK.  In progress
ETA: DD/MM/YYYY
Risks: Complicated fix required
Pull Request Labels
  • sig/aws: Pull Request will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move pull request out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/feature: New functionality.
Help

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 56211, 56024). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 6b1b6d5 into kubernetes:master Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. milestone/needs-attention priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants