small cleanup

This commit is contained in:
Alex Dadgar
2018-03-13 18:04:55 -07:00
parent eceabb66f8
commit 8ba5ba33de
5 changed files with 9 additions and 13 deletions

View File

@@ -127,13 +127,11 @@ const (
// NodeEvent is a single unit representing a nodes 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

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -1086,7 +1086,6 @@ type NodeEvent struct {
Details map[string]string
Timestamp int64
CreateIndex uint64
ModifyIndex uint64
}
func (ne *NodeEvent) String() string {