Merge pull request #4035 from hashicorp/node-events-timestamps
Properly format node event timestamps
This commit is contained in:
commit
92a51471e9
|
@ -212,7 +212,7 @@ type NodeEvent struct {
|
|||
Message string
|
||||
Subsystem string
|
||||
Details map[string]string
|
||||
Timestamp int64
|
||||
Timestamp time.Time
|
||||
CreateIndex uint64
|
||||
}
|
||||
|
||||
|
|
|
@ -1069,7 +1069,7 @@ func (c *Client) updateNodeFromDriver(name string, fingerprint, health *structs.
|
|||
event := &structs.NodeEvent{
|
||||
Subsystem: "Driver",
|
||||
Message: health.HealthDescription,
|
||||
Timestamp: time.Now().Unix(),
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
c.triggerNodeEvent(event)
|
||||
}
|
||||
|
|
|
@ -429,7 +429,7 @@ func (c *NodeStatusCommand) outputNodeEvent(events []*api.NodeEvent) {
|
|||
}
|
||||
|
||||
for i, event := range events {
|
||||
timestamp := formatUnixNanoTime(event.Timestamp)
|
||||
timestamp := formatTime(event.Timestamp)
|
||||
subsystem := event.Subsystem
|
||||
msg := event.Message
|
||||
if c.verbose {
|
||||
|
|
|
@ -91,7 +91,7 @@ func TestFSM_UpsertNodeEvents(t *testing.T) {
|
|||
nodeEvent := &structs.NodeEvent{
|
||||
Message: "Heartbeating failed",
|
||||
Subsystem: "Heartbeat",
|
||||
Timestamp: time.Now().Unix(),
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
|
||||
nodeEvents := []*structs.NodeEvent{nodeEvent}
|
||||
|
|
|
@ -2864,7 +2864,7 @@ func TestClientEndpoint_EmitEvents(t *testing.T) {
|
|||
nodeEvent := &structs.NodeEvent{
|
||||
Message: "Registration failed",
|
||||
Subsystem: "Server",
|
||||
Timestamp: time.Now().Unix(),
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
|
||||
nodeEvents := map[string][]*structs.NodeEvent{node.ID: {nodeEvent}}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"io"
|
||||
"log"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-memdb"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
|
@ -538,7 +539,7 @@ func (s *StateStore) UpsertNode(index uint64, node *structs.Node) error {
|
|||
nodeEvent := &structs.NodeEvent{
|
||||
Message: "Node Registered",
|
||||
Subsystem: "Cluster",
|
||||
Timestamp: node.StatusUpdatedAt,
|
||||
Timestamp: time.Unix(node.StatusUpdatedAt, 0),
|
||||
}
|
||||
node.Events = []*structs.NodeEvent{nodeEvent}
|
||||
node.CreateIndex = index
|
||||
|
|
|
@ -802,7 +802,7 @@ func TestStateStore_AddSingleNodeEvent(t *testing.T) {
|
|||
nodeEvent := &structs.NodeEvent{
|
||||
Message: "failed",
|
||||
Subsystem: "Driver",
|
||||
Timestamp: time.Now().Unix(),
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
nodeEvents := map[string][]*structs.NodeEvent{
|
||||
node.ID: {nodeEvent},
|
||||
|
@ -845,7 +845,7 @@ func TestStateStore_NodeEvents_RetentionWindow(t *testing.T) {
|
|||
nodeEvent := &structs.NodeEvent{
|
||||
Message: fmt.Sprintf("%dith failed", i),
|
||||
Subsystem: "Driver",
|
||||
Timestamp: time.Now().Unix(),
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
|
||||
nodeEvents := map[string][]*structs.NodeEvent{
|
||||
|
|
|
@ -1188,7 +1188,7 @@ type NodeEvent struct {
|
|||
Message string
|
||||
Subsystem string
|
||||
Details map[string]string
|
||||
Timestamp int64
|
||||
Timestamp time.Time
|
||||
CreateIndex uint64
|
||||
}
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ func (ne *NodeEvent) String() string {
|
|||
details = append(details, fmt.Sprintf("%s: %s", k, v))
|
||||
}
|
||||
|
||||
return fmt.Sprintf("Message: %s, Subsystem: %s, Details: %s, Timestamp: %d", ne.Message, ne.Subsystem, strings.Join(details, ","), ne.Timestamp)
|
||||
return fmt.Sprintf("Message: %s, Subsystem: %s, Details: %s, Timestamp: %s", ne.Message, ne.Subsystem, strings.Join(details, ","), ne.Timestamp.String())
|
||||
}
|
||||
|
||||
func (ne *NodeEvent) Copy() *NodeEvent {
|
||||
|
|
Loading…
Reference in a new issue