fix: handle TiKV metrics fetch errors#6897
Conversation
|
Hi @immanuwell. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @immanuwell! It looks like this is your first PR to pingcap/tidb-operator 🎉 |
|
/lgtm |
|
[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 |
[LGTM Timeline notifier]Timeline:
|
|
/cherry-pick release-2.1 |
|
@liubog2008: once the present PR merges, I will cherry-pick it on top of release-2.0/release-2.1 in the new PR and assign it to you. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6897 +/- ##
==========================================
+ Coverage 37.95% 37.97% +0.01%
==========================================
Files 393 393
Lines 22603 22605 +2
==========================================
+ Hits 8579 8584 +5
+ Misses 14024 14021 -3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@liubog2008: new pull request created to branch DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
|
@liubog2008: new pull request created to branch DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What
GetLeaderCountcould say the leader metric was missing when the/metricsfetch itself failed. The fetch runs in a goroutine, but the error was stored in a shared var, so the caller could miss it. Tiny fix, but yeah, kinda sus.This waits for the fetch result through a buffered error channel before returning the fallback "metric not found" error.
Related: #4281 is the same code path, but a different old goroutine-leak issue.
Repro
The added test reproduces it on the old code:
go test ./pkg/tikvapi/v1 -run TestTiKVClient_GetLeaderCountFetchError -count=1It serves
/metricswith HTTP 500. Old code returns "metric not found". New code returns the real fetch error. This can happen IRL when the TiKV metrics endpoint is unavailable, times out, hits TLS/transport errors, or returns non-200; no weird cloud quota edge case needed.Tests