mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-02-12 05:51:45 +01:00
fix nodeList resolver data handling, increase nodestate filter cutoff
- add comment on cutoff
This commit is contained in:
@@ -824,6 +824,7 @@ func (r *queryResolver) NodeMetricsList(ctx context.Context, cluster string, sub
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeRepo := repository.GetNodeRepository()
|
nodeRepo := repository.GetNodeRepository()
|
||||||
|
// nodes -> array hostname
|
||||||
nodes, stateMap, countNodes, hasNextPage, nerr := nodeRepo.GetNodesForList(ctx, cluster, subCluster, stateFilter, nodeFilter, page)
|
nodes, stateMap, countNodes, hasNextPage, nerr := nodeRepo.GetNodesForList(ctx, cluster, subCluster, stateFilter, nodeFilter, page)
|
||||||
if nerr != nil {
|
if nerr != nil {
|
||||||
return nil, errors.New("could not retrieve node list required for resolving NodeMetricsList")
|
return nil, errors.New("could not retrieve node list required for resolving NodeMetricsList")
|
||||||
@@ -835,6 +836,7 @@ func (r *queryResolver) NodeMetricsList(ctx context.Context, cluster string, sub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// data -> map hostname:jobdata
|
||||||
data, err := metricdispatch.LoadNodeListData(cluster, subCluster, nodes, metrics, scopes, *resolution, from, to, ctx)
|
data, err := metricdispatch.LoadNodeListData(cluster, subCluster, nodes, metrics, scopes, *resolution, from, to, ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.Warn("error while loading node data (Resolver.NodeMetricsList")
|
cclog.Warn("error while loading node data (Resolver.NodeMetricsList")
|
||||||
@@ -842,18 +844,18 @@ func (r *queryResolver) NodeMetricsList(ctx context.Context, cluster string, sub
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeMetricsList := make([]*model.NodeMetrics, 0, len(data))
|
nodeMetricsList := make([]*model.NodeMetrics, 0, len(data))
|
||||||
for hostname, metrics := range data {
|
for _, hostname := range nodes {
|
||||||
host := &model.NodeMetrics{
|
host := &model.NodeMetrics{
|
||||||
Host: hostname,
|
Host: hostname,
|
||||||
State: stateMap[hostname],
|
State: stateMap[hostname],
|
||||||
Metrics: make([]*model.JobMetricWithName, 0, len(metrics)*len(scopes)),
|
Metrics: make([]*model.JobMetricWithName, 0),
|
||||||
}
|
}
|
||||||
host.SubCluster, err = archive.GetSubClusterByNode(cluster, hostname)
|
host.SubCluster, err = archive.GetSubClusterByNode(cluster, hostname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.Warnf("error in nodeMetrics resolver: %s", err)
|
cclog.Warnf("error in nodeMetrics resolver: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for metric, scopedMetrics := range metrics {
|
for metric, scopedMetrics := range data[hostname] {
|
||||||
for scope, scopedMetric := range scopedMetrics {
|
for scope, scopedMetric := range scopedMetrics {
|
||||||
host.Metrics = append(host.Metrics, &model.JobMetricWithName{
|
host.Metrics = append(host.Metrics, &model.JobMetricWithName{
|
||||||
Name: metric,
|
Name: metric,
|
||||||
|
|||||||
@@ -263,14 +263,16 @@ func (r *NodeRepository) QueryNodes(
|
|||||||
if f.SchedulerState != nil {
|
if f.SchedulerState != nil {
|
||||||
query = query.Where("node_state = ?", f.SchedulerState)
|
query = query.Where("node_state = ?", f.SchedulerState)
|
||||||
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
||||||
|
// TODO: Hardcoded TimeDiff Suboptimal - Use Config Option?
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
query = query.Where(sq.Gt{"time_stamp": (now - 60)})
|
query = query.Where(sq.Gt{"time_stamp": (now - 300)})
|
||||||
}
|
}
|
||||||
if f.HealthState != nil {
|
if f.HealthState != nil {
|
||||||
query = query.Where("health_state = ?", f.HealthState)
|
query = query.Where("health_state = ?", f.HealthState)
|
||||||
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
||||||
|
// TODO: Hardcoded TimeDiff Suboptimal - Use Config Option?
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
query = query.Where(sq.Gt{"time_stamp": (now - 60)})
|
query = query.Where(sq.Gt{"time_stamp": (now - 300)})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,14 +333,16 @@ func (r *NodeRepository) CountNodes(
|
|||||||
if f.SchedulerState != nil {
|
if f.SchedulerState != nil {
|
||||||
query = query.Where("node_state = ?", f.SchedulerState)
|
query = query.Where("node_state = ?", f.SchedulerState)
|
||||||
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
||||||
|
// TODO: Hardcoded TimeDiff Suboptimal - Use Config Option?
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
query = query.Where(sq.Gt{"time_stamp": (now - 60)})
|
query = query.Where(sq.Gt{"time_stamp": (now - 300)})
|
||||||
}
|
}
|
||||||
if f.HealthState != nil {
|
if f.HealthState != nil {
|
||||||
query = query.Where("health_state = ?", f.HealthState)
|
query = query.Where("health_state = ?", f.HealthState)
|
||||||
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
// Requires Additional time_stamp Filter: Else the last (past!) time_stamp with queried state will be returned
|
||||||
|
// TODO: Hardcoded TimeDiff Suboptimal - Use Config Option?
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
query = query.Where(sq.Gt{"time_stamp": (now - 60)})
|
query = query.Where(sq.Gt{"time_stamp": (now - 300)})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user