-
Notifications
You must be signed in to change notification settings - Fork 4.5k
storage/raft: Advertise the configured cluster address #9008
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1c42963
storage/raft: Advertise the configured cluster address
695d120
Don't allow raft to start with unspecified IP
7f66e86
Fix concurrent map write panic
c7fbbba
Add test file
5a6d469
Merge branch 'master' into raft-addr-fix
3a693b6
changelog++
briankassouf c4691b6
changelog++
briankassouf 8334893
changelog++
briankassouf 1a305b6
Update tcp_layer.go
briankassouf 6233474
Update tcp_layer.go
briankassouf e48fe48
Only set the adverise addr if set
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
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,70 @@ | ||
| package raft | ||
|
|
||
| import ( | ||
| "context" | ||
| "crypto/rand" | ||
| "crypto/tls" | ||
| "net" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/hashicorp/vault/vault/cluster" | ||
| ) | ||
|
|
||
| type mockClusterHook struct { | ||
| address net.Addr | ||
| } | ||
|
|
||
| func (*mockClusterHook) AddClient(alpn string, client cluster.Client) {} | ||
| func (*mockClusterHook) RemoveClient(alpn string) {} | ||
| func (*mockClusterHook) AddHandler(alpn string, handler cluster.Handler) {} | ||
| func (*mockClusterHook) StopHandler(alpn string) {} | ||
| func (*mockClusterHook) TLSConfig(ctx context.Context) (*tls.Config, error) { return nil, nil } | ||
| func (m *mockClusterHook) Addr() net.Addr { return m.address } | ||
| func (*mockClusterHook) GetDialerFunc(ctx context.Context, alpnProto string) func(string, time.Duration) (net.Conn, error) { | ||
| return func(string, time.Duration) (net.Conn, error) { | ||
| return nil, nil | ||
| } | ||
| } | ||
|
|
||
| func TestStreamLayer_UnspecifiedIP(t *testing.T) { | ||
| m := &mockClusterHook{ | ||
| address: &cluster.NetAddr{ | ||
| Host: "0.0.0.0:8200", | ||
| }, | ||
| } | ||
|
|
||
| raftTLSKey, err := GenerateTLSKey(rand.Reader) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| raftTLS := &TLSKeyring{ | ||
| Keys: []*TLSKey{raftTLSKey}, | ||
| ActiveKeyID: raftTLSKey.ID, | ||
| } | ||
|
|
||
| layer, err := NewRaftLayer(nil, raftTLS, m) | ||
| if err == nil { | ||
| t.Fatal("expected error") | ||
| } | ||
|
|
||
| if err.Error() != "cannot use unspecified IP with raft storage: 0.0.0.0:8200" { | ||
| t.Fatalf("unexpected error: %s", err.Error()) | ||
| } | ||
|
|
||
| if layer != nil { | ||
| t.Fatal("expected nil layer") | ||
| } | ||
|
|
||
| m.address.(*cluster.NetAddr).Host = "10.0.0.1:8200" | ||
|
|
||
| layer, err = NewRaftLayer(nil, raftTLS, m) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| if layer == nil { | ||
| t.Fatal("nil layer") | ||
| } | ||
| } |
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
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
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.
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.
Could this result in raft using a bad listener address if the
cluster_addris, say127.0.0.1:0(a valid address with an unspecified port), and the address in the listener is0.0.0.0:8201since we'd be overwritingc.clusterAddrwith one that raft is unhappy about?