Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Mar 14, 2018
1 parent 380e027 commit f1641b5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
10 changes: 4 additions & 6 deletions api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions nomad/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
1 change: 0 additions & 1 deletion nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,6 @@ type NodeEvent struct {
Details map[string]string
Timestamp int64
CreateIndex uint64
ModifyIndex uint64
}

func (ne *NodeEvent) String() string {
Expand Down

0 comments on commit f1641b5

Please sign in to comment.