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

PILOT_SEND_UNHEALTHY_ENDPOINTS: exclude terminating endpoints #54711

Merged
merged 3 commits into from
Jan 16, 2025

Conversation

howardjohn
Copy link
Member

The purpose of PILOT_SEND_UNHEALTHY_ENDPOINTS is to let envoy know about
the count of health and unhealth endpoints as a factor into its failover
decisions. For instance, if we have 5/10 pods health, it would failover.

This has problematic behavior during scaling up/down. For instance, if I
just have a single pod and then make a change, I will temporarily have 2
pods (the new one, and the old one terminating). Envoy will now see this
as 50% health and failover. This is bad -- its not actually unhealthy at
all!

Additionally, when pods are scaling down we end up keeping them as
unhealthy. Consider I have 1/2 pods healthy, and shut down the unhealthy
one but it takes a few minutes to fully terminate. During that time,
envoy will consider us 50% healthy. However, because we requested 1 pod
and have 1 pod, I would consider that 100% healthy.


This PR adds a new health mode, "terminating".

  • When the feature flag is false, terminating and unhealthy mean the
    same thing -- do not send the endpoint to envoy. This has no impact.
  • When the feature flag is true, we will not sending terminating
    endpoints. This means a terminating endpoint is not taken into account
    for the health calculations.

This change does not impact whether we send traffic to the terminating
pods or not -- both before and after, we never do this.

Note: there is another status, 'draining', which is a very specialized
mode that is only used when session persistence is enabled on a service
&& the endpoint is terminating && it used to be healthy. Comments in the
code clarify the differences between these two similar states. These
endpoints are sent to envoy and traffic is sent to them, so its
fundamentally different than Terminating.

The purpose of PILOT_SEND_UNHEALTHY_ENDPOINTS is to let envoy know about
the count of health and unhealth endpoints as a factor into its failover
decisions. For instance, if we have 5/10 pods health, it would failover.

This has problematic behavior during scaling up/down. For instance, if I
just have a single pod and then make a change, I will temporarily have 2
pods (the new one, and the old one terminating). Envoy will now see this
as 50% health and failover. This is bad -- its not actually unhealthy at
all!

Additionally, when pods are scaling down we end up keeping them as
unhealthy. Consider I have 1/2 pods healthy, and shut down the unhealthy
one but it takes a few minutes to fully terminate. During that time,
envoy will consider us 50% healthy. However, because we requested 1 pod
and have 1 pod, I would consider that 100% healthy.

----

This PR adds a new health mode, "terminating".
* When the feature flag is false, terminating and unhealthy mean the
  same thing -- do not send the endpoint to envoy. This has no impact.
* When the feature flag is true, we will not sending terminating
  endpoints. This means a terminating endpoint is not taken into account
for the health calculations.

This change does not impact whether we send traffic to the terminating
pods or not -- both before and after, we never do this.

Note: there is another status, 'draining', which is a very specialized
mode that is only used when session persistence is enabled on a service
&& the endpoint is terminating && it used to be healthy. Comments in the
code clarify the differences between these two similar states. These
endpoints *are* sent to envoy and traffic is sent to them, so its
fundamentally different than Terminating.
@howardjohn howardjohn added the release-notes-none Indicates a PR that does not require release notes. label Jan 16, 2025
@howardjohn howardjohn requested review from a team as code owners January 16, 2025 15:49
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 16, 2025
Copy link
Contributor

@bleggett bleggett left a comment

Choose a reason for hiding this comment

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

IIUC the main observable change in behavior here would be that failover happens later? I might not have it right tho.

@howardjohn
Copy link
Member Author

IIUC the main observable change in behavior here would be that failover happens later? I might not have it right tho.

I think the main cases are

New rollout:
before: we would get a blip of "unhealthy" and might send some traffic cross-zone
after: treated as "healthy"

Scaling:
before: we would get a blip of "unhealthy" and might send some traffic cross-zone
after: treated as "healthy"

@howardjohn howardjohn force-pushed the endpoints/terminating-mode branch from 4cc7579 to 4c55534 Compare January 16, 2025 17:41
Copy link
Contributor

@bleggett bleggett left a comment

Choose a reason for hiding this comment

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

Since this is an observable change (even for the better) it feels like it warrants a relnote, but LGTM.

@keithmattix keithmattix added do-not-merge/hold Block automatic merging of a PR. and removed release-notes-none Indicates a PR that does not require release notes. labels Jan 16, 2025
@keithmattix
Copy link
Contributor

This LGTM, but I agree with @bleggett on the release note. Adding a hold until that's done

@howardjohn howardjohn removed the do-not-merge/hold Block automatic merging of a PR. label Jan 16, 2025
@istio-testing istio-testing merged commit 62c6ef2 into istio:master Jan 16, 2025
27 checks passed
fjglira pushed a commit to fjglira/istio that referenced this pull request Feb 10, 2025
* upstream/master:
  make collections implement Syncer (istio#54750)
  Automator: update proxy@master in istio/istio@master (istio#54755)
  istioctl: support SA RBAC rule parsing (istio#54744)
  Automator: update proxy@master in istio/istio@master (istio#54754)
  Automator: update proxy@master in istio/istio@master (istio#54753)
  Automator: update ztunnel@master in istio/istio@master (istio#54749)
  Enable modifying the prow cluster name (istio#54742)
  Automator: update proxy@master in istio/istio@master (istio#54727)
  Fix crash when starting pilot without kubeClient (istio#54730)
  ambient: support `istio.io/ingress-use-waypoint` at the namespace level (istio#54483)
  Automator: update ztunnel@master in istio/istio@master (istio#54733)
  run make gen (istio#54728)
  Be more explicit about how Helm value deprecations should manifest in relnotes (istio#54697)
  PILOT_SEND_UNHEALTHY_ENDPOINTS: exclude terminating endpoints (istio#54711)
  Fix ambient telemetry in ingress gateways (istio#54383)
  Automator: update proxy@master in istio/istio@master (istio#54713)
  Gateway also needs global flattening (istio#54714)
  Automator: update common-files@master in istio/istio@master (istio#54712)
  Automator: update proxy@master in istio/istio@master (istio#54709)
  Do not impersonate empty group (istio#54667)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants