runtime: Add getDouble functionality to snapshot#8265
runtime: Add getDouble functionality to snapshot#8265mattklein123 merged 11 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Tony Allen <tony@allen.gg>
zuercher
left a comment
There was a problem hiding this comment.
Thanks, this seems useful for non-integer, non-percentage values.
I think we need to think about the interaction between integer and double values, however. It seems to me that the current behavior ignores values like "1.5" (if I understand absl::SimpleAtoi correctly it will treat that as a parsing error). I don't think this PR changes that, as long as code calls Snapshot::getInteger. However, if some code is using Snapshot::getDouble and the input is changed from 1.5 to just 1, getDouble will suddenly start returning 0.0 because "1" is parsed as a uint and SnapshotImpl::parseEntryDoubleValue won't be invoked. Perhaps we should store numeric values as both uint64_t and doubles and allow getDouble and getInteger to be used interchangeably?
|
Editing this comment since I realized the logic was miguided. I'll see about changing this to store both uint and double values. Great catch, I hadn't considered that scenario. |
Signed-off-by: Tony Allen <tallen@lyft.com>
zuercher
left a comment
There was a problem hiding this comment.
Thanks! There's still a potential weirdness where, say "5.0" isn't handled if the code uses getInteger. But I don't know the right way to reconcile numbers with fractional parts and getInteger. For example, I'm not sure it would be good for getInteger to return 5 for an input of "5.9" but that might be better than having it flip to default values because these they didn't realize a config point only accepted integers vs. floats.
Curious if @mattklein123 has an opinion.
FWIW I think we should probably just floor it and always store as both a double and an integer. I think it will be less surprising. If we decide not to do this can we clearly document that case? |
Signed-off-by: Tony Allen <tony@allen.gg>
| // Valid uint values will always be parseable as doubles, so we assign the value to both the | ||
| // uint and double fields. In cases where the value is something like "3.1", we will floor the | ||
| // number by casting it to a uint and assigning the uint value. | ||
| entry.uint_value_ = entry.double_value_; |
There was a problem hiding this comment.
Let's add a test for negative double values and positive double values >= 2^64. I think we'll want to handle those specially. Probably also need a warning on getInteger that values greater than approximately 2^53 will not be accurately converted to integers.
Signed-off-by: Tony Allen <tallen@lyft.com>
|
/wait |
Signed-off-by: Tony Allen <tallen@lyft.com>
|
Cool. |
mattklein123
left a comment
There was a problem hiding this comment.
Thanks, looks great. Can you add a release note about the new behavior for doubles/integers in runtime. Also, would it be worth to actually document this behavior somewhere in the runtime docs?
/wait
mattklein123
left a comment
There was a problem hiding this comment.
LGTM with small nit. Thank you!
/wait
docs/root/intro/version_history.rst
Outdated
| * upstream: added new :ref:`failure-percentage based outlier detection<arch_overview_outlier_detection_failure_percentage>` mode. | ||
| * upstream: use p2c to select hosts for least-requests load balancers if all host weights are the same, even in cases where weights are not equal to 1. | ||
| * upstream: added :ref:`fail_traffic_on_panic <envoy_api_field_Cluster.CommonLbConfig.ZoneAwareLbConfig.fail_traffic_on_panic>` to allow failing all requests to a cluster during panic state. | ||
| * runtime: allow for the ability to parse integers as double values and vice-versa. |
Signed-off-by: Tony Allen <tallen@lyft.com>
|
Sorry needs a master merge. /wait |
Signed-off-by: Tony Allen <tallen@lyft.com>
|
/retest |
|
🔨 rebuilding |
There was a problem hiding this comment.
Sorry needs another merge fix.
/wait
Signed-off-by: Tony Allen <tallen@lyft.com>
|
/retest |
|
🐴 hold your horses - no failures detected, yet. |
Signed-off-by: Tony Allen <tallen@lyft.com>
This patch adds the
getDoublefunction to the runtime snapshot. This allows for parsing of double values in addition to the existing integer and fractions.Risk Level: Low
Testing: New unit tests
Docs Changes: N/A
Release Notes: N/A