Skip to content
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

runtime: throw exception in debug mode that condition is always true when fractionalPercent numerator > denominator #12068

Merged

Conversation

belyalov
Copy link
Contributor

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

…ent numerator > denominator

Signed-off-by: Konstantin Belyalov <[email protected]>
Signed-off-by: Konstantin Belyalov <[email protected]>
Signed-off-by: Konstantin Belyalov <[email protected]>
"WARNING runtime key '{}': numerator ({}) > denominator ({}), condition always "
"evaluates to true",
key, percent.numerator(), denominator_value);
NOT_REACHED_GCOVR_EXCL_LINE;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok have this as gcov exception or you'd prefer me to add super simple unittest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should have a unit test associated with it. Should be trivial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP, added :)

Comment on lines 129 to 135
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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

Copy link
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I left 2 comments on the patch. The changes should be easy.

@belyalov
Copy link
Contributor Author

Thanks! I left 2 comments on the patch. The changes should be easy.

Thanks for feedback!
Addresses all 2 comments.

@belyalov belyalov marked this pull request as ready for review July 14, 2020 23:57
uint64_t denominator_value =
ProtobufPercentHelper::fractionalPercentDenominatorToInt(percent.denominator());
if (percent.numerator() > denominator_value) {
throw EnvoyException(fmt::format("WARNING runtime key '{}': numerator ({}) > denominator ({}), "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove the WARNING part of this. You're halting the show with that exception, so it's not really a warning :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, sure, makes sense (I've just copy pasted it)

Copy link
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 <[email protected]>
@belyalov belyalov changed the title [runtime] debug log that condition is always true when fractionalPercent numerator > denominator runtime: throw exception in debug mode that condition is always true when fractionalPercent numerator > denominator Jul 15, 2020
tonya11en
tonya11en previously approved these changes Jul 15, 2020
Copy link
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Signed-off-by: Konstantin Belyalov <[email protected]>
Signed-off-by: Konstantin Belyalov <[email protected]>
Signed-off-by: Konstantin Belyalov <[email protected]>
.bazelversion Outdated
@@ -1 +0,0 @@
3.3.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be part of the diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, reverting it :)
Was testing it on several bazel versions

Signed-off-by: Konstantin Belyalov <[email protected]>
Copy link
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like CI is failing. Can you look into that?

Signed-off-by: Konstantin Belyalov <[email protected]>
Signed-off-by: Konstantin Belyalov <[email protected]>
@belyalov belyalov requested a review from tonya11en July 22, 2020 17:10
@belyalov
Copy link
Contributor Author

@tonya11en ping? seems CI is now passing.. :)

Copy link
Member

@tonya11en tonya11en left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last adjustment and we should be good to go after that.

test/common/runtime/runtime_impl_test.cc Show resolved Hide resolved
@ggreenway
Copy link
Contributor

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?

@belyalov
Copy link
Contributor Author

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.
@ggreenway @tonya11en let's finalize what's preferred way? :)

@ggreenway
Copy link
Contributor

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.
@ggreenway @tonya11en let's finalize what's preferred way? :)

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.

@belyalov
Copy link
Contributor Author

@ggreenway ok, thanks for clarification.
Switched back to debug log message.

Signed-off-by: Konstantin Belyalov <[email protected]>
@belyalov belyalov requested a review from tonya11en July 29, 2020 03:37
@ggreenway ggreenway self-assigned this Jul 29, 2020
@ggreenway
Copy link
Contributor

/wait

@stale
Copy link

stale bot commented Aug 8, 2020

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!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Aug 8, 2020
…_for_wrong_runtime_value

Signed-off-by: Konstantin Belyalov <[email protected]>
Signed-off-by: Konstantin Belyalov <[email protected]>
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Aug 12, 2020
Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ggreenway
Copy link
Contributor

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines, to retry CircleCI checks, use /retest-circle.
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #12068 (comment) was created by @ggreenway.

see: more, trace.

@ggreenway
Copy link
Contributor

Windows failure looks like an unrelated test flake.

@belyalov
Copy link
Contributor Author

Windows failure looks like an unrelated test flake.

:(
Do you want me to merge it with latest master or we can just re-start build?

@ggreenway ggreenway merged commit 466245b into envoyproxy:master Aug 13, 2020
@ggreenway
Copy link
Contributor

Windows failure looks like an unrelated test flake.

:(
Do you want me to merge it with latest master or we can just re-start build?

No need; merging as-is since the failure is unrelated.

mpuncel added a commit to mpuncel/envoy that referenced this pull request Aug 14, 2020
* 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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FractionalPercent when using with RouteMatch
3 participants