From 79061cdedb4d76cb5658c79f6520cee3f7a6ba1b Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 23 Mar 2017 19:05:35 -0400 Subject: [PATCH] Fix vet issues --- consul/flood.go | 2 -- consul/fsm.go | 5 ++++- consul/servers/router_test.go | 25 ++++++++++++++++++++----- consul/state/txn.go | 5 ++++- consul/txn_endpoint.go | 10 ++++++++-- consul/txn_endpoint_test.go | 10 ++++++++-- logger/logger.go | 2 +- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/consul/flood.go b/consul/flood.go index 60fe0dfd4d..fb3b09b8f5 100644 --- a/consul/flood.go +++ b/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) diff --git a/consul/fsm.go b/consul/fsm.go index 608f1530ce..8cf4a22e69 100644 --- a/consul/fsm.go +++ b/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{} { diff --git a/consul/servers/router_test.go b/consul/servers/router_test.go index a914371517..f3e3e6d280 100644 --- a/consul/servers/router_test.go +++ b/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) diff --git a/consul/state/txn.go b/consul/state/txn.go index d2b3c6f1f5..158d63407f 100644 --- a/consul/state/txn.go +++ b/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(), + }) } } diff --git a/consul/txn_endpoint.go b/consul/txn_endpoint.go index d5125a7d5f..45b511be39 100644 --- a/consul/txn_endpoint.go +++ b/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(), + }) } } } diff --git a/consul/txn_endpoint_test.go b/consul/txn_endpoint_test.go index e502589a01..f7f375f7f1 100644 --- a/consul/txn_endpoint_test.go +++ b/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) { diff --git a/logger/logger.go b/logger/logger.go index 781ae19c2f..92fa611d50 100644 --- a/logger/logger.go +++ b/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.