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

Backport of Avoid blocking child type updates on parent ack into release/1.12.x #15501

Merged
merged 3 commits into from
Nov 22, 2022

Conversation

hc-github-team-consul-core
Copy link
Collaborator

@hc-github-team-consul-core hc-github-team-consul-core commented Nov 21, 2022

Backport

This PR is auto-generated from #15083 to be assessed for backporting due to the inclusion of the label backport/1.12.

WARNING automatic cherry-pick of commits failed. Commits will require human attention.

merge conflict error: POST https://api.github.com/repos/hashicorp/consul/merges: 409 Merge conflict []

The below text is copied from the body of the original PR.


Description

When providing updates to Envoy it is safest to follow the update order of: Clusters, Endpoints, Listeners, Routes. This order is encoded in our delta xDS response generation code.

Another noteworthy attribute of these resources is that there are parent->child relationships between: Cluster->Endpoints and Listener->Routes. Envoy couples the storage of a parent and a child type such that whenever a control plane sends an update for a parent type, it MUST also send fresh data for the child type, even if Envoy previously had the latest data for the child type.

A wrinkle that isn't accounted for currently is that Envoy does not actually ACK parent types until after attempting to receive data for the child types. This behavior also actually differs between Clusters and Listeners:

  • When a cluster is sent, Envoy will wait up to a 15s timeout for endpoints to arrive before sending the cluster ACK.
  • When a listener is sent, and it specifies RDS routes, Envoy will wait until those routes arrive before ACKing the listener. Though it's not clear to me what the timeout is for this, if any, since it exceeds a minute from my tests.

However, a behavior encoded in our xDS update order is that we avoid sending ANY data if we are waiting on ACKs for ANY resource. Meaning that when we first send a cluster to Envoy and it requests endpoints for that cluster, the endpoints do not actually get sent for at least 15s. This is because the endpoint update is paused by Consul until the cluster ACK, which Envoy pauses until it gets endpoints or times out.

This commit changes the xDS order gating such that we only block listener/route updates if there are cluster/endpoin updates pending. This is to avoid routing to an invalid destination.

Testing & Reproduction steps

  • Ran manual tests for various scenarios against a live Envoy to validate assumptions (Envoy v1.21 and v1.23)
  • Updated the unit tests to more accurately reflect Envoy's behavior
  • Anecdotally the integration tests seem to be running ~1min faster than usual with this patch

Links

Likely related to: envoyproxy/envoy#5887

PR Checklist

  • updated test coverage
  • external facing docs updated
  • not a security concern

Overview of commits

@hashicorp-cla
Copy link

hashicorp-cla commented Nov 21, 2022

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


1 out of 2 committers have signed the CLA.

  • analogue
  • temp

temp seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA. If you already have a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

When providing updates to Envoy it is safest to follow the update order
of: Clusters, Endpoints, Listeners, Routes. This order is encoded in our
delta xDS response generation code.

Another noteworthy attribute of these resources is that there are
parent->child relationships between: Cluster->Endpoints and
Listener->Routes. Envoy couples the storage of a parent and a child type
such that whenever a control plane sends an update for a parent type, it
MUST also send fresh data for the child type, even if Envoy previously
had the latest data for the child type.

A wrinkle that isn't accounted for currently is that Envoy does not
actually ACK parent types until after attempting to receive data for the
child types. This behavior also actually differs between Clusters and
Listeners:
- When a cluster is sent, Envoy will wait up to a 15s timeout for
  endpoints to arrive before sending the cluster ACK.
- When a listener is sent, and it specifies RDS routes, Envoy will wait
  until those routes arrive before ACKing the listener. Though it's not
  clear to me what the timeout is for this, it exceeds a minute from my
  tests.

However, a behavior encoded in our xDS update order is that we avoid
sending ANY data if we are waiting on ACKs for ANY resource. Meaning
that when we first send a cluster to Envoy and it requests endpoints for
that cluster, the endpoints do not actually get sent for at least 15.
This is because the endpoint update is paused by Consul until the
cluster ACK, which Envoy pauses until it gets endpoints or times out.

This commit changes the xDS order gating such that we only block
listener/route updates if there are cluster/endpoin updates pending.
This is to avoid routing to an invalid destination.
@analogue analogue marked this pull request as ready for review November 21, 2022 18:56
@analogue analogue requested a review from dhiaayachi November 21, 2022 19:50
@analogue
Copy link
Collaborator

@freddygv Would be open to learning how to test this manually by pairing.

@analogue analogue merged commit d4670b4 into release/1.12.x Nov 22, 2022
@analogue analogue deleted the backport/xds/cds-ack/vastly-unique-kodiak branch November 22, 2022 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants