Update raft to get hashicorp/raft#212 fix
This commit is contained in:
parent
39edf23fd5
commit
a1bdc26464
2
vendor/github.com/hashicorp/raft/Makefile
generated
vendored
2
vendor/github.com/hashicorp/raft/Makefile
generated
vendored
|
@ -4,7 +4,7 @@ test:
|
|||
go test -timeout=60s ./...
|
||||
|
||||
integ: test
|
||||
INTEG_TESTS=yes go test -timeout=5s -run=Integ ./...
|
||||
INTEG_TESTS=yes go test -timeout=25s -run=Integ ./...
|
||||
|
||||
deps:
|
||||
go get -d -v ./...
|
||||
|
|
6
vendor/github.com/hashicorp/raft/api.go
generated
vendored
6
vendor/github.com/hashicorp/raft/api.go
generated
vendored
|
@ -979,10 +979,10 @@ func (r *Raft) Stats() map[string]string {
|
|||
}
|
||||
|
||||
last := r.LastContact()
|
||||
if last.IsZero() {
|
||||
s["last_contact"] = "never"
|
||||
} else if r.getState() == Leader {
|
||||
if r.getState() == Leader {
|
||||
s["last_contact"] = "0"
|
||||
} else if last.IsZero() {
|
||||
s["last_contact"] = "never"
|
||||
} else {
|
||||
s["last_contact"] = fmt.Sprintf("%v", time.Now().Sub(last))
|
||||
}
|
||||
|
|
52
vendor/github.com/hashicorp/raft/peersjson.go
generated
vendored
52
vendor/github.com/hashicorp/raft/peersjson.go
generated
vendored
|
@ -44,3 +44,55 @@ func ReadPeersJSON(path string) (Configuration, error) {
|
|||
}
|
||||
return configuration, nil
|
||||
}
|
||||
|
||||
// configEntry is used when decoding a new-style peers.json.
|
||||
type configEntry struct {
|
||||
// ID is the ID of the server (a UUID, usually).
|
||||
ID ServerID `json:"id"`
|
||||
|
||||
// Address is the host:port of the server.
|
||||
Address ServerAddress `json:"address"`
|
||||
|
||||
// NonVoter controls the suffrage. We choose this sense so people
|
||||
// can leave this out and get a Voter by default.
|
||||
NonVoter bool `json:"non_voter"`
|
||||
}
|
||||
|
||||
// ReadConfigJSON reads a new-style peers.json and returns a configuration
|
||||
// structure. This can be used to perform manual recovery when running protocol
|
||||
// versions that use server IDs.
|
||||
func ReadConfigJSON(path string) (Configuration, error) {
|
||||
// Read in the file.
|
||||
buf, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return Configuration{}, err
|
||||
}
|
||||
|
||||
// Parse it as JSON.
|
||||
var peers []configEntry
|
||||
dec := json.NewDecoder(bytes.NewReader(buf))
|
||||
if err := dec.Decode(&peers); err != nil {
|
||||
return Configuration{}, err
|
||||
}
|
||||
|
||||
// Map it into the new-style configuration structure.
|
||||
var configuration Configuration
|
||||
for _, peer := range peers {
|
||||
suffrage := Voter
|
||||
if peer.NonVoter {
|
||||
suffrage = Nonvoter
|
||||
}
|
||||
server := Server{
|
||||
Suffrage: suffrage,
|
||||
ID: peer.ID,
|
||||
Address: peer.Address,
|
||||
}
|
||||
configuration.Servers = append(configuration.Servers, server)
|
||||
}
|
||||
|
||||
// We should only ingest valid configurations.
|
||||
if err := checkConfiguration(configuration); err != nil {
|
||||
return Configuration{}, err
|
||||
}
|
||||
return configuration, nil
|
||||
}
|
||||
|
|
3
vendor/github.com/hashicorp/raft/raft.go
generated
vendored
3
vendor/github.com/hashicorp/raft/raft.go
generated
vendored
|
@ -5,6 +5,7 @@ import (
|
|||
"container/list"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
|
@ -1238,6 +1239,7 @@ func (r *Raft) installSnapshot(rpc RPC, req *InstallSnapshotRequest) {
|
|||
}
|
||||
var rpcErr error
|
||||
defer func() {
|
||||
io.Copy(ioutil.Discard, rpc.Reader) // ensure we always consume all the snapshot data from the stream [see issue #212]
|
||||
rpc.Respond(resp, rpcErr)
|
||||
}()
|
||||
|
||||
|
@ -1250,6 +1252,7 @@ func (r *Raft) installSnapshot(rpc RPC, req *InstallSnapshotRequest) {
|
|||
|
||||
// Ignore an older term
|
||||
if req.Term < r.getCurrentTerm() {
|
||||
r.logger.Printf("[INFO] raft: Ignoring installSnapshot request with older term of %d vs currentTerm %d", req.Term, r.getCurrentTerm())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
|
@ -845,10 +845,10 @@
|
|||
"revision": "a14192a58a694c123d8fe5481d4a4727d6ae82f3"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "wpirHJV/6VEbbD+HyAP2/6Xc0ek=",
|
||||
"checksumSHA1": "bYn+HDmt7YLFvEV6DagMup8mkZE=",
|
||||
"path": "github.com/hashicorp/raft",
|
||||
"revision": "aaad9f10266e089bd401e7a6487651a69275641b",
|
||||
"revisionTime": "2016-11-10T00:52:40Z"
|
||||
"revision": "e5e581e04af7c46974b99195347cc0c380c0d841",
|
||||
"revisionTime": "2017-06-09T23:09:26Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "QAxukkv54/iIvLfsUP6IK4R0m/A=",
|
||||
|
|
Loading…
Reference in a new issue