Repository navigation
Conversation
…on config
The outlier detection load balancer config parser only accepted the
internal object form of a Duration ({seconds, nanos}). The canonical
protobuf JSON representation of a Duration is a string such as "10s",
so a config using the standard representation was rejected with
"expected Duration, got string".
Accept the canonical string form and the DurationMessage form, in
addition to the existing object form, and use the parsed value for
range validation and conversion to milliseconds.
Fixes grpc#2442
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2442.
The outlier detection load balancer config parser only accepted the internal
object form of a Duration (
{seconds, nanos}). The canonical protobuf JSONrepresentation of a Duration is a string such as
"10s", so a config using thestandard representation was rejected with:
This makes the
outlier_detectionLB policy unusable with canonical JSONconfig, while other duration-bearing policies in this repo
(
weighted_round_robin) already accept the string form.Change
packages/grpc-js/src/load-balancer-outlier-detection.tsparseDurationValue(), which accepts the canonical string form(
"10s","1.5s"), theDurationMessageform ({seconds: "10", nanos: 0}),and the existing internal object form (
{seconds: 10, nanos: 0}).validatePositiveDuration()now returns the parsedDuration, and rangevalidation is performed against that parsed value rather than the raw input.
createFromJson()uses the parsed durations when converting to milliseconds,so
interval,base_ejection_timeandmax_ejection_timeall honour thecanonical representation.
The existing object form remains fully supported, so this is backwards
compatible.
Testing
packages/grpc-js/test/test-outlier-detection.tsAdded tests covering the canonical string form (including a fractional value),
the
DurationMessageform, the pre-existing object form, and rejection of anunparseable duration string.
All 26 pre-existing tests in that file still pass.