Skip to content

Commit e9cd6b4

Browse files
set updateNodeStates timeStamp once per request
-prevents per-host timestamp mismatches due to handler iteration duration
1 parent 13cca1e commit e9cd6b4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

internal/api/nats.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,12 @@ func (api *NatsAPI) processNodestateEvent(msg lp.CCMessage) {
324324
}
325325

326326
repo := repository.GetNodeRepository()
327+
requestReceived := time.Now().Unix()
327328

328329
for _, node := range req.Nodes {
329330
state := determineState(node.States)
330331
nodeState := schema.NodeStateDB{
331-
TimeStamp: time.Now().Unix(),
332+
TimeStamp: requestReceived,
332333
NodeState: state,
333334
CpusAllocated: node.CpusAllocated,
334335
MemoryAllocated: node.MemoryAllocated,

internal/api/node.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ func (api *RestAPI) updateNodeStates(rw http.ResponseWriter, r *http.Request) {
6363
return
6464
}
6565
repo := repository.GetNodeRepository()
66+
requestReceived := time.Now().Unix()
6667

6768
for _, node := range req.Nodes {
6869
state := determineState(node.States)
6970
nodeState := schema.NodeStateDB{
70-
TimeStamp: time.Now().Unix(), NodeState: state,
71+
TimeStamp: requestReceived,
72+
NodeState: state,
7173
CpusAllocated: node.CpusAllocated,
7274
MemoryAllocated: node.MemoryAllocated,
7375
GpusAllocated: node.GpusAllocated,

0 commit comments

Comments
 (0)