tiproxy: add spec field gracefulShutdownDeleteDelaySeconds to gracefully mark unhealthy before deleting the pods (#6829)#6894
Open
ti-chi-bot wants to merge 7 commits into
Conversation
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-2.1 #6894 +/- ##
===============================================
+ Coverage 37.61% 37.95% +0.33%
===============================================
Files 392 393 +1
Lines 22483 22603 +120
===============================================
+ Hits 8458 8579 +121
+ Misses 14025 14024 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Member
|
/lgtm |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liubog2008 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Contributor
[LGTM Timeline notifier]Timeline:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an automated cherry-pick of #6829
Background
I'm designing the graceful restarting of TiProxy in cloud environment.
The intended behavior is:
maxSurge.TiProxyGroupto enable a long graceful shutdown delete delay.This is mainly for cloud load balancers: existing long-lived connections can continue to work on the old TiProxy (with big enough
target_health_state.unhealthy.draining_interval_secondsfor AWS and disableConnectionDrainEnabledfor aliyun), while new connections should be sent to the new TiProxy instances.We cannot rely on changing
terminationGracePeriodSecondsfor existing pods, because that would itself require restarting them. So this PR adds a controller-side graceful delete flow for TiProxy.Design
spec.template.spec.gracefulShutdownDeleteDelaySecondstoTiProxyGroup/TiProxy.TiProxyobject is being deleted and this field is set to a positive value:POST /api/debug/health/unhealthy404), operator falls back to sendingSIGTERMto the TiProxy process bypods/execcore.pingcap.com/tiproxy-graceful-shutdown-begin-timeon the pod and starts the delete-delay timerClusteris deleting, this graceful delay is skipped and the pod is deleted directly.This design keeps the user-facing control in
spec, avoids changingterminationGracePeriodSeconds, and supports both new TiProxy versions (with unhealthy API) and older ones (withSIGTERMfallback).Usage
Patch an existing
TiProxyGroup, so old TiProxy pods will be kept for a while after they are marked unhealthy: