-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
fault: use FractionalPercent for percent #3978
Changes from 1 commit
35dc15a
f105661
4daaac1
4e3a07d
d4a0e76
6652866
f14d3bc
3d56b3f
f197fe2
f98bcc0
c0f9701
ca6fa14
9b1046f
aef3da0
c31bd82
f167d92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,15 +31,25 @@ message FractionalPercent { | |
// **Example**: 1/100 = 1%. | ||
HUNDRED = 0; | ||
|
||
// 1,000. | ||
// | ||
// **Example**: 1/1000 = 0.1%. | ||
THOUSAND = 1; | ||
|
||
// 10,000. | ||
// | ||
// **Example**: 1/10000 = 0.01%. | ||
TEN_THOUSAND = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These can't be changed. You will need to add new ones at the end. Are they really necessary though? Seems unnecessary to me with TEN_THOUSAND and MILLION. I would revert these changes personally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in f105661. |
||
TEN_THOUSAND = 2; | ||
|
||
// 100,000. | ||
// | ||
// **Example**: 1/100000 = 0.001%. | ||
HUNDRED_THOUSAND = 3; | ||
|
||
// 1,000,000. | ||
// | ||
// **Example**: 1/1000000 = 0.0001%. | ||
MILLION = 2; | ||
MILLION = 4; | ||
} | ||
|
||
// Specifies the denominator. If the denominator specified is less than the numerator, the final | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,10 @@ Delay | |
|
||
{ | ||
"type" : "...", | ||
"fixed_delay_percent" : "...", | ||
"fixed_delay_percent" : { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't accept v1 changes anymore. Please revert all changes to v1 code, schema, docs, etc. |
||
"numerator" : "...", | ||
"denominator" : "..." | ||
}, | ||
"fixed_duration_ms" : "..." | ||
} | ||
|
||
|
@@ -86,9 +89,8 @@ type: | |
injected. Currently only *fixed* delay type (step function) is supported. | ||
|
||
fixed_delay_percent: | ||
*(required, integer)* The percentage of requests that will | ||
be delayed for the duration specified by *fixed_duration_ms*. Valid | ||
values range from 0 to 100. | ||
*(required, envoy.type.FractionalPercent)* The percentage of requests that will be delayed for | ||
the duration specified by *fixed_duration_ms*. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip all changes to this file |
||
fixed_duration_ms: | ||
*(required, integer)* The delay duration in milliseconds. Must be greater than 0. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,14 +39,17 @@ incoming data up until the timer event fires will be a part of the delay. | |
|
||
{ | ||
"fixed_delay": { | ||
"percent": "...", | ||
"percent": { | ||
"numerator": "...", | ||
"denominator": "..." | ||
}, | ||
"duration_ms": "..." | ||
} | ||
} | ||
|
||
percent | ||
*(required, integer)* Probability of an eligible MongoDB operation to be affected by the | ||
injected fault when there is no active fault. Valid values are integers in a range of [0, 100]. | ||
*(required, envoy.type.FractionalPercent)* Probability of an eligible MongoDB operation to be | ||
affected by the injected fault when there is no active fault. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this as well |
||
|
||
duration_ms | ||
*(required, integer)* Non-negative delay duration in milliseconds. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,19 @@ class Snapshot { | |
virtual bool featureEnabled(const std::string& key, uint64_t default_value, | ||
uint64_t random_value) const PURE; | ||
|
||
/** | ||
* Test if a feature is enabled using the built in random generator and total number of buckets | ||
* for sampling. | ||
* @param key supplies the feature key to lookup. | ||
* @param default_value supplies the default value that will be used if either the feature key | ||
* does not exist or it is not an integer. | ||
* @param num_buckets control max number of buckets for sampling. Sampled value will be in a range | ||
* of [0, num_buckets). | ||
* @return true if the feature is enabled. | ||
*/ | ||
virtual bool sampleFeatureEnabled(const std::string& key, uint64_t default_value, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I see why you had to change the name here, but IMO "sample" is a bit strange in the sense that the other featureEnabled() functions also do sampling. A few options here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattklein123 thanks for reviewing! I've addressed your other comments in f197fe2, and I'm working on this one now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implemented option 1 in f98bcc0. |
||
uint64_t num_buckets) const PURE; | ||
|
||
/** | ||
* Test if a feature is enabled using a supplied stable random value and total number of buckets | ||
* for sampling. | ||
|
@@ -112,12 +125,12 @@ class Snapshot { | |
* does not exist or it is not an integer. | ||
* @param random_value supplies the stable random value to use for determining whether the feature | ||
* is enabled. | ||
* @param control max number of buckets for sampling. Sampled value will be in a range of | ||
* [0, num_buckets). | ||
* @param num_buckets control max number of buckets for sampling. Sampled value will be in a range | ||
* of [0, num_buckets). | ||
* @return true if the feature is enabled. | ||
*/ | ||
virtual bool featureEnabled(const std::string& key, uint64_t default_value, uint64_t random_value, | ||
uint64_t num_buckets) const PURE; | ||
virtual bool sampleFeatureEnabled(const std::string& key, uint64_t default_value, | ||
uint64_t random_value, uint64_t num_buckets) const PURE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattklein123 how are you guys doing fractional percent with runtimes? IOW, do you need runtime support for fractional percent? If not, all changes to this file can be eliminated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking again, why is this being renamed ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of a signature conflict between the routines highlighted here. |
||
|
||
/** | ||
* Fetch raw runtime data based on key. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,9 +379,20 @@ const std::string Json::Schema::MONGO_PROXY_NETWORK_FILTER_SCHEMA(R"EOF( | |
"type" : "object", | ||
"properties" : { | ||
"percent" : { | ||
"type" : "integer", | ||
"minimum" : 0, | ||
"maximum" : 100 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. skip file |
||
"type" : "object", | ||
"properties" : { | ||
"numerator" : { | ||
"type" : "integer", | ||
"minimum" : 0, | ||
"maximum" : 100 | ||
}, | ||
"denominator" : { | ||
"type" : "string", | ||
"enum" : ["HUNDRED", "THOUSAND", "TEN_THOUSAND", "HUNDRED_THOUSAND", "MILLION"] | ||
} | ||
}, | ||
"required": ["numerator", "denominator"], | ||
"additionalProperties" : false | ||
}, | ||
"duration_ms" : { | ||
"type" : "integer", | ||
|
@@ -1022,9 +1033,20 @@ const std::string Json::Schema::FAULT_HTTP_FILTER_SCHEMA(R"EOF( | |
"enum" : ["fixed"] | ||
}, | ||
"fixed_delay_percent" : { | ||
"type" : "integer", | ||
"minimum" : 0, | ||
"maximum" : 100 | ||
"type" : "object", | ||
"properties" : { | ||
"numerator" : { | ||
"type" : "integer", | ||
"minimum" : 0, | ||
"maximum" : 100 | ||
}, | ||
"denominator" : { | ||
"type" : "string", | ||
"enum" : ["HUNDRED", "THOUSAND", "TEN_THOUSAND", "HUNDRED_THOUSAND", "MILLION"] | ||
} | ||
}, | ||
"required": ["numerator", "denominator"], | ||
"additionalProperties" : false | ||
}, | ||
"fixed_duration_ms" : { | ||
"type" : "integer", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,8 +146,13 @@ std::string RandomGeneratorImpl::uuid() { | |
return std::string(uuid, UUID_LENGTH); | ||
} | ||
|
||
bool SnapshotImpl::featureEnabled(const std::string& key, uint64_t default_value, | ||
uint64_t random_value, uint64_t num_buckets) const { | ||
bool SnapshotImpl::sampleFeatureEnabled(const std::string& key, uint64_t default_value, | ||
uint64_t num_buckets) const { | ||
return sampleFeatureEnabled(key, default_value, generator_.random(), num_buckets); | ||
} | ||
|
||
bool SnapshotImpl::sampleFeatureEnabled(const std::string& key, uint64_t default_value, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip renaming and overload old function name ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore |
||
uint64_t random_value, uint64_t num_buckets) const { | ||
return random_value % num_buckets < std::min(getInteger(key, default_value), num_buckets); | ||
} | ||
|
||
|
@@ -165,7 +170,7 @@ bool SnapshotImpl::featureEnabled(const std::string& key, uint64_t default_value | |
|
||
bool SnapshotImpl::featureEnabled(const std::string& key, uint64_t default_value, | ||
uint64_t random_value) const { | ||
return featureEnabled(key, default_value, random_value, 100); | ||
return sampleFeatureEnabled(key, default_value, random_value, 100); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two functions are not equivalent.. The stable random value is not same as number of buckets above. Am I missing something here>? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const std::string& SnapshotImpl::get(const std::string& key) 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.
We can't just change this. You will need to deprecate the old percent and add a new one.
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.
call the new one as percentage. And i think there is also some protoc validation with it