runtime: throw exception in debug mode that condition is always true when fractionalPercent numerator > denominator#12068
Conversation
…ent numerator > denominator Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
| "WARNING runtime key '{}': numerator ({}) > denominator ({}), condition always " | ||
| "evaluates to true", | ||
| key, percent.numerator(), denominator_value); | ||
| NOT_REACHED_GCOVR_EXCL_LINE; |
There was a problem hiding this comment.
Is it ok have this as gcov exception or you'd prefer me to add super simple unittest?
There was a problem hiding this comment.
This change should have a unit test associated with it. Should be trivial.
| if (percent.numerator() > denominator_value) { | ||
| ENVOY_LOG(debug, | ||
| "WARNING runtime key '{}': numerator ({}) > denominator ({}), condition always " | ||
| "evaluates to true", | ||
| key, percent.numerator(), denominator_value); | ||
| NOT_REACHED_GCOVR_EXCL_LINE; | ||
| } |
There was a problem hiding this comment.
I think this check should only occur in debug builds and just throw an exception. Something like:
#ifndef NDEBUG
if (percent.numerator() > denominator_value) {
throw EnvoyException(.....);
}
#endif
tonya11en
left a comment
There was a problem hiding this comment.
Thanks! I left 2 comments on the patch. The changes should be easy.
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Thanks for feedback! |
| uint64_t denominator_value = | ||
| ProtobufPercentHelper::fractionalPercentDenominatorToInt(percent.denominator()); | ||
| if (percent.numerator() > denominator_value) { | ||
| throw EnvoyException(fmt::format("WARNING runtime key '{}': numerator ({}) > denominator ({}), " |
There was a problem hiding this comment.
I'd remove the WARNING part of this. You're halting the show with that exception, so it's not really a warning :)
There was a problem hiding this comment.
Oh yeah, sure, makes sense (I've just copy pasted it)
tonya11en
left a comment
There was a problem hiding this comment.
Just a nit regarding the error message. I'll approve once that's fixed and then a maintainer can take a look for official approval.
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
.bazelversion
Outdated
| @@ -1 +0,0 @@ | |||
| 3.3.1 | |||
There was a problem hiding this comment.
Should this be part of the diff?
There was a problem hiding this comment.
oops, reverting it :)
Was testing it on several bazel versions
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
tonya11en
left a comment
There was a problem hiding this comment.
Looks like CI is failing. Can you look into that?
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
|
@tonya11en ping? seems CI is now passing.. :) |
tonya11en
left a comment
There was a problem hiding this comment.
One last adjustment and we should be good to go after that.
|
I don't think having different error handling in debug vs release is a good idea. Can it just log instead, and do it regardless of compilation mode? |
This is what originally has been done. |
Sorry about that; I didn't look at all the history when I reviewed it. I talked to @tonya11en and we agreed it makes most sense to log at debug level, in both debug and release builds. Again, sorry for the back-and-forth on this. |
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
…_for_wrong_runtime_value Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
|
@ggreenway ok, thanks for clarification. |
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
|
/wait |
|
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
…_for_wrong_runtime_value Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
Signed-off-by: Konstantin Belyalov <arsenicus@mail.ru>
|
/retest |
|
Retrying Azure Pipelines, to retry CircleCI checks, use |
|
Windows failure looks like an unrelated test flake. |
:( |
No need; merging as-is since the failure is unrelated. |
* master: (67 commits) logger: support log control in admin interface and command line option for Fancy Logger (envoyproxy#12369) test: fix http_timeout_integration_test flake (envoyproxy#12654) [fuzz]added an input check in writefilter fuzzer and added test cases (envoyproxy#12628) add 'explicit' restriction. (envoyproxy#12643) scoped_rds_integration_test migrate from api v2 to api v3. (envoyproxy#12633) fuzz: added fuzz test for listener filter tls_inspector (envoyproxy#12617) testing: fix multiple race conditions in simulated time tests (envoyproxy#12527) [tls] Move handshaking behavior into SslSocketInfo. (envoyproxy#12571) header: getting rid of exception-throwing behaviors in header files [the rest] (envoyproxy#12611) router: add new ratelimited retry backoff strategy (envoyproxy#12202) [redis_proxy] added a constraint for route.prefix().size() (envoyproxy#12637) network: add tcp listener backlog config (envoyproxy#12625) runtime: debug log that condition is always true when fractionalPercent numerator > denominator (envoyproxy#12068) WatchDog Extension hook (envoyproxy#12416) router: add dynamic metadata header formatter (envoyproxy#11858) statsd: revert visibility to public (envoyproxy#12621) Fix regression of /build_* in gitignore (envoyproxy#12630) Added a missing extension point to documentation. (envoyproxy#12620) Reverts proxy protocol test on windows (envoyproxy#12619) caching: Improved the tests and coverage of the CacheFilter tree (envoyproxy#12544) ... Signed-off-by: Michael Puncel <mpuncel@squareup.com>
Commit Message: Add debug log message when numerator > denominator
Additional Description:
Risk Level: No Risk
Testing: No new tests added, was tested as part of troubleshooting of real issue
Docs Changes: Not Changed
Release Notes: Not added, maybe need to add?
Fixes #11874