Browse Source

Fix vet issues

pull/2827/head
Seth Vargo 8 years ago
parent
commit
79061cdedb
No known key found for this signature in database
GPG Key ID: C921994F9C27E0FF
  1. 2
      consul/flood.go
  2. 5
      consul/fsm.go
  3. 25
      consul/servers/router_test.go
  4. 5
      consul/state/txn.go
  5. 10
      consul/txn_endpoint.go
  6. 10
      consul/txn_endpoint_test.go
  7. 2
      logger/logger.go

2
consul/flood.go

@ -46,7 +46,6 @@ func (s *Server) Flood(portFn servers.FloodPortFn, global *serf.Serf) {
}()
for {
WAIT:
select {
case <-s.serfLAN.ShutdownCh():
return
@ -60,7 +59,6 @@ func (s *Server) Flood(portFn servers.FloodPortFn, global *serf.Serf) {
case <-floodCh:
goto FLOOD
}
goto WAIT
FLOOD:
servers.FloodJoins(s.logger, portFn, s.config.Datacenter, s.serfLAN, global)

5
consul/fsm.go

@ -309,7 +309,10 @@ func (c *consulFSM) applyTxn(buf []byte, index uint64) interface{} {
}
defer metrics.MeasureSince([]string{"consul", "fsm", "txn"}, time.Now())
results, errors := c.state.TxnRW(index, req.Ops)
return structs.TxnResponse{results, errors}
return structs.TxnResponse{
Results: results,
Errors: errors,
}
}
func (c *consulFSM) applyAutopilotUpdate(buf []byte, index uint64) interface{} {

25
consul/servers/router_test.go

@ -405,7 +405,10 @@ func TestRouter_GetDatacenterMaps(t *testing.T) {
Datacenter: "dc0",
AreaID: types.AreaWAN,
Coordinates: structs.Coordinates{
&structs.Coordinate{"node0.dc0", lib.GenerateCoordinate(10 * time.Millisecond)},
&structs.Coordinate{
Node: "node0.dc0",
Coord: lib.GenerateCoordinate(10 * time.Millisecond),
},
},
}) {
t.Fatalf("bad: %#v", entry)
@ -415,9 +418,18 @@ func TestRouter_GetDatacenterMaps(t *testing.T) {
Datacenter: "dc1",
AreaID: types.AreaWAN,
Coordinates: structs.Coordinates{
&structs.Coordinate{"node1.dc1", lib.GenerateCoordinate(3 * time.Millisecond)},
&structs.Coordinate{"node2.dc1", lib.GenerateCoordinate(2 * time.Millisecond)},
&structs.Coordinate{"node3.dc1", lib.GenerateCoordinate(5 * time.Millisecond)},
&structs.Coordinate{
Node: "node1.dc1",
Coord: lib.GenerateCoordinate(3 * time.Millisecond),
},
&structs.Coordinate{
Node: "node2.dc1",
Coord: lib.GenerateCoordinate(2 * time.Millisecond),
},
&structs.Coordinate{
Node: "node3.dc1",
Coord: lib.GenerateCoordinate(5 * time.Millisecond),
},
},
}) {
t.Fatalf("bad: %#v", entry)
@ -427,7 +439,10 @@ func TestRouter_GetDatacenterMaps(t *testing.T) {
Datacenter: "dc2",
AreaID: types.AreaWAN,
Coordinates: structs.Coordinates{
&structs.Coordinate{"node1.dc2", lib.GenerateCoordinate(8 * time.Millisecond)},
&structs.Coordinate{
Node: "node1.dc2",
Coord: lib.GenerateCoordinate(8 * time.Millisecond),
},
},
}) {
t.Fatalf("bad: %#v", entry)

5
consul/state/txn.go

@ -124,7 +124,10 @@ func (s *StateStore) txnDispatch(tx *memdb.Txn, idx uint64, ops structs.TxnOps)
// Capture any error along with the index of the operation that
// failed.
if err != nil {
errors = append(errors, &structs.TxnError{i, err.Error()})
errors = append(errors, &structs.TxnError{
OpIndex: i,
What: err.Error(),
})
}
}

10
consul/txn_endpoint.go

@ -24,10 +24,16 @@ func (t *Txn) preCheck(acl acl.ACL, ops structs.TxnOps) structs.TxnErrors {
if op.KV != nil {
ok, err := kvsPreApply(t.srv, acl, op.KV.Verb, &op.KV.DirEnt)
if err != nil {
errors = append(errors, &structs.TxnError{i, err.Error()})
errors = append(errors, &structs.TxnError{
OpIndex: i,
What: err.Error(),
})
} else if !ok {
err = fmt.Errorf("failed to lock key %q due to lock delay", op.KV.DirEnt.Key)
errors = append(errors, &structs.TxnError{i, err.Error()})
errors = append(errors, &structs.TxnError{
OpIndex: i,
What: err.Error(),
})
}
}
}

10
consul/txn_endpoint_test.go

@ -251,7 +251,10 @@ func TestTxn_Apply_ACLDeny(t *testing.T) {
// These get filtered but won't result in an error.
default:
expected.Errors = append(expected.Errors, &structs.TxnError{i, permissionDeniedErr.Error()})
expected.Errors = append(expected.Errors, &structs.TxnError{
OpIndex: i,
What: permissionDeniedErr.Error(),
})
}
}
if !reflect.DeepEqual(out, expected) {
@ -509,7 +512,10 @@ func TestTxn_Read_ACLDeny(t *testing.T) {
// These get filtered but won't result in an error.
default:
expected.Errors = append(expected.Errors, &structs.TxnError{i, permissionDeniedErr.Error()})
expected.Errors = append(expected.Errors, &structs.TxnError{
OpIndex: i,
What: permissionDeniedErr.Error(),
})
}
}
if !reflect.DeepEqual(out, expected) {

2
logger/logger.go

@ -39,7 +39,7 @@ type Config struct {
func Setup(config *Config, ui cli.Ui) (*logutils.LevelFilter, *GatedWriter, *LogWriter, io.Writer, bool) {
// The gated writer buffers logs at startup and holds until it's flushed.
logGate := &GatedWriter{
Writer: &cli.UiWriter{ui},
Writer: &cli.UiWriter{Ui: ui},
}
// Set up the level filter.

Loading…
Cancel
Save