Conversation
Since v0.386.0, gorouter fails to unmarshal `router.register` NATS messages for any route configured with hash-based load balancing (`loadbalancing: hash`) that includes a `hash_balance` factor. The message is rejected as a validation error and dropped, so the endpoint is never registered. The route becomes unreachable (404 / stale until TTL expiry) even though the app and the registration message are healthy. This restores the old parsing.
a18e
force-pushed
the
fix-gorouter-hash-balance-as-string
branch
from
September 11, 2026 12:09
ba1bc65 to
3ab1fce
Compare
hoffmaen
previously approved these changes
Sep 11, 2026
a18e
marked this pull request as ready for review
September 11, 2026 14:10
b1tamara
reviewed
Sep 14, 2026
| type RegistryMessageOpts struct { | ||
| LoadBalancingAlgorithm string `json:"loadbalancing"` | ||
| HashHeaderName string `json:"hash_header"` | ||
| HashBalance float64 `json:"hash_balance"` |
Contributor
There was a problem hiding this comment.
Could you please implement a new unit test in subscriber_test.go to ensure this regression is avoided during NATS message registration.
Something like:
It("parses hash_balance from the incoming JSON string", func() {
data := []byte(`{"host":"host","app":"app","protocol":"http2","uris":["test.example.com"],"options":{"loadbalancing":"hash","hash_header":"X-Header","hash_balance":"1.5"}}`)
err := natsClient.Publish("router.register", data)
Expect(err).ToNot(HaveOccurred())
Eventually(registry.RegisterCallCount).Should(Equal(1))
_, originalEndpoint := registry.RegisterArgsForCall(0)
expectedEndpoint := route.NewEndpoint(&route.EndpointOpts{
Host: "host",
AppId: "app",
Protocol: "http2",
LoadBalancingAlgorithm: "hash",
HashHeaderName: "X-Header",
HashBalanceFactor: 1.5,
})
Expect(originalEndpoint).To(Equal(expectedEndpoint))
})
1 task
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.
Summary
This PR restores the original parsing of
hash_balance.The
,stringsuffix was removed as part of https://github.com/cloudfoundry/routing-release/pull/535/changes#diff-a3cb8cde907ca8ef9a573547cc9464f3bfa9348ce3beedcb838e768d40a99c85L46, which broke hash-based routing.Backward Compatibility
Breaking Change? No, fixes (unintended?) breaking change.
See #585