set updateNodeStates timeStamp once per request

-prevents per-host timestamp mismatches due to handler iteration duration
This commit is contained in:
Christoph Kluge
2026-02-02 17:51:41 +01:00
parent 13cca1ee62
commit e9cd6b4225
2 changed files with 5 additions and 2 deletions

View File

@@ -324,11 +324,12 @@ func (api *NatsAPI) processNodestateEvent(msg lp.CCMessage) {
} }
repo := repository.GetNodeRepository() repo := repository.GetNodeRepository()
requestReceived := time.Now().Unix()
for _, node := range req.Nodes { for _, node := range req.Nodes {
state := determineState(node.States) state := determineState(node.States)
nodeState := schema.NodeStateDB{ nodeState := schema.NodeStateDB{
TimeStamp: time.Now().Unix(), TimeStamp: requestReceived,
NodeState: state, NodeState: state,
CpusAllocated: node.CpusAllocated, CpusAllocated: node.CpusAllocated,
MemoryAllocated: node.MemoryAllocated, MemoryAllocated: node.MemoryAllocated,

View File

@@ -63,11 +63,13 @@ func (api *RestAPI) updateNodeStates(rw http.ResponseWriter, r *http.Request) {
return return
} }
repo := repository.GetNodeRepository() repo := repository.GetNodeRepository()
requestReceived := time.Now().Unix()
for _, node := range req.Nodes { for _, node := range req.Nodes {
state := determineState(node.States) state := determineState(node.States)
nodeState := schema.NodeStateDB{ nodeState := schema.NodeStateDB{
TimeStamp: time.Now().Unix(), NodeState: state, TimeStamp: requestReceived,
NodeState: state,
CpusAllocated: node.CpusAllocated, CpusAllocated: node.CpusAllocated,
MemoryAllocated: node.MemoryAllocated, MemoryAllocated: node.MemoryAllocated,
GpusAllocated: node.GpusAllocated, GpusAllocated: node.GpusAllocated,