mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-02-11 13:31:45 +01:00
set updateNodeStates timeStamp once per request
-prevents per-host timestamp mismatches due to handler iteration duration
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user