-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Throttler: return app name in check result, synthesize "why throttled" explanation from result #16416
Throttler: return app name in check result, synthesize "why throttled" explanation from result #16416
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
…shot Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…etricChan -> throttleMetricChan Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…package Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…enable Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16416 +/- ##
==========================================
- Coverage 68.65% 68.63% -0.02%
==========================================
Files 1550 1551 +1
Lines 199412 199515 +103
==========================================
+ Hits 136900 136931 +31
- Misses 62512 62584 +72 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…the Summary(), populate ThrottledReason added in proto, then in turn populate new _vt.vreplication.reason_throttled Signed-off-by: Shlomi Noach <[email protected]>
…n_throttled Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is brilliant!
I will enhance the throttler reporting added to vtadmin in #16308 to display the reason
once this is merged.
Signed-off-by: Shlomi Noach <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This is a nice enhancement. ❤️
@@ -85,14 +91,32 @@ func (c *CheckResult) IsOK() bool { | |||
return c.StatusCode == http.StatusOK | |||
} | |||
|
|||
// Summary returns a human-readable summary of the check result | |||
func (c *CheckResult) Summary() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use String()
so that CheckResult
implements the Stringer interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ambivalent. There can only be one String()
function, and I'm not sure what the expected implementation should be. Summary()
does not capture all of the CheckResult
's fields. Should String()
capture all fields? Should String()
be human readable or machine readable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna keep this with Summary()
. We can always easily change it to String()
later.
func (c *CheckResult) Summary() string { | ||
switch c.StatusCode { | ||
case http.StatusOK: | ||
return fmt.Sprintf("%v is granted access", c.AppName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nitty, but IMO better to use %s with strings like AppName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
var ( | ||
throttleTicks int64 | ||
throttleInit sync.Once | ||
emptyCheckResult = &CheckResult{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this not to be a const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golang
does nto permit this as a const
@@ -418,6 +418,7 @@ func TestApplyThrottlerConfigMetricThresholds(t *testing.T) { | |||
assert.EqualValues(t, 0.3, checkResult.Value) // self lag value | |||
assert.EqualValues(t, http.StatusOK, checkResult.StatusCode) | |||
assert.Len(t, checkResult.Metrics, 1) | |||
assert.Contains(t, checkResult.Summary(), "test is granted access") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the "test" value in all of these asserts is from the const test
app name. Nitty, but better to use the const everywhere it applies. Similar for the other app names which are based on existing consts/vars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
||
// continuing previous test, we had 3 throttled apps. "all" is a new app being throttled. | ||
assert.Equal(t, 4, throttler.throttledApps.ItemCount()) | ||
}) | ||
// | ||
// // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we added an extraneous comment indicator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…" explanation from result (vitessio#16416) Signed-off-by: Shlomi Noach <[email protected]>
Description
Followup to #15988, this PR further enhances
CheckThrottlerResponse
by adding the name of throttled/granted app.Why is this needed? Isn't the app name the same as the app in
CheckThrottlerRequest
?Not necessarily!
vcopier:d666bbfc_169e_11ef_b0b3_0a43f95f28a3:vreplication:online-ddl
. Suppose the request is throttled. Why is it being throttled? There could be many reasons and based on either of the specific identifiers. For example, someone might have issued aalter vitess_migration throttle all
, in which case the throttled app will beonline-ddl
. So this is what we indicate back to the user.all
app is being throttled. Either because someone actually invokedUpdateThrottlerConfig --throttle-app=all ...
, or just becauseall
is assigned specific metrics, one of which crossed its threshold. This way or another, we want to tell the user the"all"
app is at "fault" here.Check result summary
Based on that, we provide a concise summary, something like
app 'online-ddl' is throttled because 'lag' exceeded its threshold of
5``, orvreplication is denied access until ...
.Example actual summaries:
This is in turn injected in
_vt.vreplication
and then in_vt.schema_migrations
as a human readable assist for analyzing production situations.reason_throttled
in_vt.vreplication
@rohit-nayak-ps you will like this.
Looks like this:
The same is copied to
_vt.schema_migrations
.Related Issue(s)
Checklist
Deployment Notes