-
Notifications
You must be signed in to change notification settings - Fork 1
fix: routing overhaul — reconnection guards, owner_id proto, /etc/hosts DNS, deployment subnets #230
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
Merged
Merged
fix: routing overhaul — reconnection guards, owner_id proto, /etc/hosts DNS, deployment subnets #230
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f122ec1
fix: routing overhaul — reconnection guards, owner_id proto, /etc/hos…
jhaynie bcf4381
revert earlier change fixed in main
jhaynie 28297c8
fix: extract TLS SNI hostname from raw URL, not DNS-resolved address
jhaynie 7d81e52
test: add preferredTLSServerName test covering /etc/hosts SNI isolation
jhaynie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package gravity | ||
|
|
||
| import ( | ||
| "context" | ||
| "sync/atomic" | ||
| "testing" | ||
|
|
||
| "github.com/agentuity/go-common/logger" | ||
| ) | ||
|
|
||
| func newReconnectRefreshTestClient(endpoints []*GravityEndpoint, urls []string, discover func() []string) *GravityClient { | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| g := &GravityClient{ | ||
| ctx: ctx, | ||
| cancel: cancel, | ||
| logger: logger.NewTestLogger(), | ||
| defaultServerName: "gravity-usw.agentuity.cloud", | ||
| endpoints: endpoints, | ||
| connectionURLs: urls, | ||
| endpointFailCount: make([]atomic.Int32, len(endpoints)), | ||
| discoveryResolveFunc: discover, | ||
| } | ||
| return g | ||
| } | ||
|
|
||
| func TestGravityClient_ReResolvesAfterFailures(t *testing.T) { | ||
| endpoints := []*GravityEndpoint{{URL: "grpc://10.0.0.1:443"}} | ||
| urls := []string{"grpc://10.0.0.1:443"} | ||
| g := newReconnectRefreshTestClient(endpoints, urls, func() []string { | ||
| return []string{"grpc://10.0.0.1:443", "grpc://10.0.0.99:443"} | ||
| }) | ||
| t.Cleanup(g.cancel) | ||
|
|
||
| current := "grpc://10.0.0.1:443" | ||
| for i := int32(1); i < endpointDiscoveryRefreshFailureThreshold; i++ { | ||
| updated := g.handleEndpointReconnectFailure(0, current) | ||
| if updated != current { | ||
| t.Fatalf("unexpected URL change before threshold at attempt %d: %s", i, updated) | ||
| } | ||
| } | ||
|
|
||
| updated := g.handleEndpointReconnectFailure(0, current) | ||
| if updated != "grpc://10.0.0.99:443" { | ||
| t.Fatalf("expected URL to refresh at threshold, got %s", updated) | ||
| } | ||
| if g.endpoints[0].URL != "grpc://10.0.0.99:443" { | ||
| t.Fatalf("expected endpoint URL updated, got %s", g.endpoints[0].URL) | ||
| } | ||
| if g.connectionURLs[0] != "grpc://10.0.0.99:443" { | ||
| t.Fatalf("expected connection URL updated, got %s", g.connectionURLs[0]) | ||
| } | ||
| } | ||
|
|
||
| func TestGravityClient_MixedEndpoints_OnlyReResolveFailing(t *testing.T) { | ||
| endpoints := []*GravityEndpoint{ | ||
| {URL: "grpc://10.0.0.1:443"}, | ||
| {URL: "grpc://10.0.0.2:443"}, | ||
| } | ||
| urls := []string{"grpc://10.0.0.1:443", "grpc://10.0.0.2:443"} | ||
| g := newReconnectRefreshTestClient(endpoints, urls, func() []string { | ||
| return []string{"grpc://10.0.0.1:443", "grpc://10.0.0.2:443", "grpc://10.0.0.77:443"} | ||
| }) | ||
| t.Cleanup(g.cancel) | ||
|
|
||
| current := "grpc://10.0.0.1:443" | ||
| for i := int32(0); i < endpointDiscoveryRefreshFailureThreshold; i++ { | ||
| current = g.handleEndpointReconnectFailure(0, current) | ||
| } | ||
|
|
||
| if g.endpoints[0].URL != "grpc://10.0.0.77:443" { | ||
| t.Fatalf("expected failing endpoint to refresh, got %s", g.endpoints[0].URL) | ||
| } | ||
| if g.endpoints[1].URL != "grpc://10.0.0.2:443" { | ||
| t.Fatalf("expected healthy endpoint unchanged, got %s", g.endpoints[1].URL) | ||
| } | ||
| if g.connectionURLs[1] != "grpc://10.0.0.2:443" { | ||
| t.Fatalf("expected healthy endpoint connection URL unchanged, got %s", g.connectionURLs[1]) | ||
| } | ||
| if g.endpointFailCount[1].Load() != 0 { | ||
| t.Fatalf("expected non-failing endpoint failure count untouched, got %d", g.endpointFailCount[1].Load()) | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.