-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Adds support for WAN soft fail and join flooding. #2801
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
376fdde
Changes pool's dial address to a string and adds a timeout.
slackpad 78b62ca
Adds an area request type.
slackpad 472f1bd
Adds router into RPC paths with work in progress on coordinates.
slackpad fe2bd89
Cleans up after merge.
slackpad dc1572d
Fixes snapshot endpoint after merge.
slackpad 1091c73
Removes remoteConsuls in favor of the new router.
slackpad a8ee32c
Fixes RTT command to only compare coordinates in the same area.
slackpad 1bdd0f3
Simplifies median calculation.
slackpad b969d92
Makes the raft_vsn optional in Serf tags to support older servers.
slackpad 7c27ca1
Adds missing unit tests and cleans up some router bugs.
slackpad 7525836
Adds offline detection.
slackpad fcbb615
Cleans up some small things based on review feedback.
slackpad f1acda4
Adds a hook for the route lookup function.
slackpad 5626d35
Walks back the changes to change pool address interface into strings.
slackpad 7360e0b
Adds LAN -> WAN join flooding.
slackpad b58faff
Fixes a unit test that needed to account for WAN flooding.
slackpad d556d14
Shuts down flooder when either Serf is shut down.
slackpad 7a451f7
Makes the flood goroutine more reusable.
slackpad 79e192f
Adds public API for the network area endpoints.
slackpad f7c5541
Updates memberlist to get new transport interface.
slackpad 3a0739c
Tweaks the join response to be more useful.
slackpad 90174d3
Lowers log spam from the join flooder.
slackpad 5dd6058
Updates memberlist to get NACK penalty improvements.
slackpad e91377f
Cleans up based on review feedback.
slackpad 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 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 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,158 @@ | ||
// The /v1/operator/area endpoints are available only in Consul Enterprise and | ||
// interact with its network area subsystem. Network areas are used to link | ||
// together Consul servers in different Consul datacenters. With network areas, | ||
// Consul datacenters can be linked together in ways other than a fully-connected | ||
// mesh, as is required for Consul's WAN. | ||
package api | ||
|
||
import ( | ||
"net" | ||
"time" | ||
) | ||
|
||
// Area defines a network area. | ||
type Area struct { | ||
// ID is this identifier for an area (a UUID). This must be left empty | ||
// when creating a new area. | ||
ID string | ||
|
||
// PeerDatacenter is the peer Consul datacenter that will make up the | ||
// other side of this network area. Network areas always involve a pair | ||
// of datacenters: the datacenter where the area was created, and the | ||
// peer datacenter. This is required. | ||
PeerDatacenter string | ||
|
||
// RetryJoin specifies the address of Consul servers to join to, such as | ||
// an IPs or hostnames with an optional port number. This is optional. | ||
RetryJoin []string | ||
} | ||
|
||
// AreaJoinResponse is returned when a join occurs and gives the result for each | ||
// address. | ||
type AreaJoinResponse struct { | ||
// The address that was joined. | ||
Address string | ||
|
||
// Whether or not the join was a success. | ||
Joined bool | ||
|
||
// If we couldn't join, this is the message with information. | ||
Error string | ||
} | ||
|
||
// SerfMember is a generic structure for reporting information about members in | ||
// a Serf cluster. This is only used by the area endpoints right now, but this | ||
// could be expanded to other endpoints in the future. | ||
type SerfMember struct { | ||
// ID is the node identifier (a UUID). | ||
ID string | ||
|
||
// Name is the node name. | ||
Name string | ||
|
||
// Addr has the IP address. | ||
Addr net.IP | ||
|
||
// Port is the RPC port. | ||
Port uint16 | ||
|
||
// Datacenter is the DC name. | ||
Datacenter string | ||
|
||
// Role is "client", "server", or "unknown". | ||
Role string | ||
|
||
// Build has the version of the Consul agent. | ||
Build string | ||
|
||
// Protocol is the protocol of the Consul agent. | ||
Protocol int | ||
|
||
// Status is the Serf health status "none", "alive", "leaving", "left", | ||
// or "failed". | ||
Status string | ||
|
||
// RTT is the estimated round trip time from the server handling the | ||
// request to the this member. This will be negative if no RTT estimate | ||
// is available. | ||
RTT time.Duration | ||
} | ||
|
||
// AreaCreate will create a new network area. The ID in the given structure must | ||
// be empty and a generated ID will be returned on success. | ||
func (op *Operator) AreaCreate(area *Area, q *WriteOptions) (string, *WriteMeta, error) { | ||
r := op.c.newRequest("POST", "/v1/operator/area") | ||
r.setWriteOptions(q) | ||
r.obj = area | ||
rtt, resp, err := requireOK(op.c.doRequest(r)) | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
wm := &WriteMeta{} | ||
wm.RequestTime = rtt | ||
|
||
var out struct{ ID string } | ||
if err := decodeBody(resp, &out); err != nil { | ||
return "", nil, err | ||
} | ||
return out.ID, wm, nil | ||
} | ||
|
||
// AreaList returns all the available network areas. | ||
func (op *Operator) AreaList(q *QueryOptions) ([]*Area, *QueryMeta, error) { | ||
var out []*Area | ||
qm, err := op.c.query("/v1/operator/area", &out, q) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
return out, qm, nil | ||
} | ||
|
||
// AreaDelete deletes the given network area. | ||
func (op *Operator) AreaDelete(areaID string, q *WriteOptions) (*WriteMeta, error) { | ||
r := op.c.newRequest("DELETE", "/v1/operator/area/"+areaID) | ||
r.setWriteOptions(q) | ||
rtt, resp, err := requireOK(op.c.doRequest(r)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
wm := &WriteMeta{} | ||
wm.RequestTime = rtt | ||
return wm, nil | ||
} | ||
|
||
// AreaJoin attempts to join the given set of join addresses to the given | ||
// network area. See the Area structure for details about join addresses. | ||
func (op *Operator) AreaJoin(areaID string, addresses []string, q *WriteOptions) ([]*AreaJoinResponse, *WriteMeta, error) { | ||
r := op.c.newRequest("PUT", "/v1/operator/area/"+areaID+"/join") | ||
r.setWriteOptions(q) | ||
r.obj = addresses | ||
rtt, resp, err := requireOK(op.c.doRequest(r)) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
defer resp.Body.Close() | ||
|
||
wm := &WriteMeta{} | ||
wm.RequestTime = rtt | ||
|
||
var out []*AreaJoinResponse | ||
if err := decodeBody(resp, &out); err != nil { | ||
return nil, nil, err | ||
} | ||
return out, wm, nil | ||
} | ||
|
||
// AreaMembers lists the Serf information about the members in the given area. | ||
func (op *Operator) AreaMembers(areaID string, q *QueryOptions) ([]*SerfMember, *QueryMeta, error) { | ||
var out []*SerfMember | ||
qm, err := op.c.query("/v1/operator/area/"+areaID+"/members", &out, q) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
return out, qm, nil | ||
} |
This file contains 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 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 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 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.
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.
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.
Good catch with this, I wouldn't have realized to do this until testing alongside an older consul binary