consul
consul copied to clipboard
Backport of Move sidecar port assignment logic to locked stage of add flow into release/1.12.x
Backport
This PR is auto-generated from #14057 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.
Closes #8254
Description
This relocates automatic sidecar port assignment logic to a locked method immediately before registration, thereby preventing collisions when handling simultaneous requests.
Testing & Reproduction steps
Manual verification:
- Submit many simultaneous requests for registration with sidecar proxy and no port specified:
for name in $(shuf -i 1-10000); do curl -d '{"name": "'$name'", "connect": {"sidecar_service": {}}}' -X PUT localhost:8500/v1/agent/service/register &; echo registered $name; done - See how many duplicate ports have been registered:
curl localhost:8500/v1/agent/services | jq -r ' . | to_entries | map(select(.key | match("sidecar";"i"))) | map(.value) | .[] | .Port' | sort | uniq -d - Before this change: there should be several duplicate ports
- After this change: no duplicate ports
Links
GH Issue Pre-req PR 1 Pre-req PR 2
PR Checklist
- [ ] updated test coverage
- [N/A] external facing docs updated
- [N/A] not a security concern
Overview of commits
- 3a8999a98dd812c8eeb0591fbb8b98e143d70931
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.
- [x] skpratt
- [ ] 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.
This pull request has been automatically flagged for inactivity because it has not been acted upon in the last 60 days. It will be closed if no new activity occurs in the next 30 days. Please feel free to re-open to resurrect the change if you feel this has happened by mistake. Thank you for your contributions.