From f1641b5404d0259c71bec81e89ace762964b7344 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Tue, 13 Mar 2018 18:04:55 -0700 Subject: [PATCH] small cleanup --- api/nodes.go | 10 ++++------ client/client.go | 2 +- nomad/fsm.go | 6 +++--- nomad/state/state_store.go | 3 +-- nomad/structs/structs.go | 1 - 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/api/nodes.go b/api/nodes.go index 3daf2f7a58c0..db7f25ffb39e 100644 --- a/api/nodes.go +++ b/api/nodes.go @@ -127,13 +127,11 @@ const ( // NodeEvent is a single unit representing a node’s state change type NodeEvent struct { - Message string - Subsystem string - Details map[string]string - Timestamp int64 - + Message string + Subsystem string + Details map[string]string + Timestamp int64 CreateIndex uint64 - ModifyIndex uint64 } // HostStats represents resource usage stats of the host running a Nomad client diff --git a/client/client.go b/client/client.go index 1d015e0d019c..1fa8b4dcbeef 100644 --- a/client/client.go +++ b/client/client.go @@ -1153,7 +1153,7 @@ func (c *Client) submitNodeEvents(events []*structs.NodeEvent) error { } var resp structs.EmitNodeEventsResponse if err := c.RPC("Node.EmitEvents", &req, &resp); err != nil { - return fmt.Errorf("Emitting node event failed: %v", err) + return fmt.Errorf("Emitting node events failed: %v", err) } return nil } diff --git a/nomad/fsm.go b/nomad/fsm.go index 31c6e0ecbdbc..e2693f51e10d 100644 --- a/nomad/fsm.go +++ b/nomad/fsm.go @@ -237,7 +237,7 @@ func (n *nomadFSM) Apply(log *raft.Log) interface{} { case structs.AutopilotRequestType: return n.applyAutopilotUpdate(buf[1:], log.Index) case structs.UpsertNodeEventsType: - return n.applyUpsertNodeEventType(buf[1:], log.Index) + return n.applyUpsertNodeEvent(buf[1:], log.Index) } // Check enterprise only message types. @@ -630,8 +630,8 @@ func (n *nomadFSM) applyReconcileSummaries(buf []byte, index uint64) interface{} return n.reconcileQueuedAllocations(index) } -// applyUpsertNodeEventType tracks the given node events. -func (n *nomadFSM) applyUpsertNodeEventType(buf []byte, index uint64) interface{} { +// applyUpsertNodeEvent tracks the given node events. +func (n *nomadFSM) applyUpsertNodeEvent(buf []byte, index uint64) interface{} { defer metrics.MeasureSince([]string{"nomad", "fsm", "upsert_node_events"}, time.Now()) var req structs.EmitNodeEventsRequest if err := structs.Decode(buf, &req); err != nil { diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 6233f4d49f89..4c986e558d0b 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -527,7 +527,7 @@ func (s *StateStore) UpsertNode(index uint64, node *structs.Node) error { node.ModifyIndex = index node.Drain = exist.Drain // Retain the drain mode - // retain node events that have already been set on the node + // Retain node events that have already been set on the node node.Events = exist.Events } else { // Because this is the first time the node is being registered, we should @@ -685,7 +685,6 @@ func (s *StateStore) upsertNodeEvents(index uint64, nodeID string, events []*str // Add the events, updating the indexes for _, e := range events { e.CreateIndex = index - e.ModifyIndex = index copyNode.Events = append(copyNode.Events, e) } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 92c8396b93a0..b125bf715f6a 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -1086,7 +1086,6 @@ type NodeEvent struct { Details map[string]string Timestamp int64 CreateIndex uint64 - ModifyIndex uint64 } func (ne *NodeEvent) String() string {