mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-01-27 22:41:46 +01:00
remove blocking backend check
- threw errors on expected and correctly handled behavior for nodeList queries
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -683,6 +684,11 @@ func (r *NodeRepository) GetNodesForList(
|
||||
hasNextPage = len(nextNodes) == 1
|
||||
}
|
||||
|
||||
// Fallback, ignores stateFilter
|
||||
// if countNodes == 0 {
|
||||
// nodes, countNodes, hasNextPage = getNodesFromTopol(cluster, subCluster, nodeFilter, page)
|
||||
// }
|
||||
|
||||
return nodes, stateMap, countNodes, hasNextPage, nil
|
||||
}
|
||||
|
||||
@@ -707,3 +713,51 @@ func AccessCheckWithUser(user *schema.User, query sq.SelectBuilder) (sq.SelectBu
|
||||
return qnil, fmt.Errorf("user has no or unknown roles")
|
||||
}
|
||||
}
|
||||
|
||||
func getNodesFromTopol(cluster string, subCluster string, nodeFilter string, page *model.PageRequest) ([]string, int, bool) {
|
||||
// 0) Init additional vars
|
||||
var hasNextPage bool = false
|
||||
var totalNodes int = 0
|
||||
|
||||
// 1) Get list of all nodes
|
||||
var topolNodes []string
|
||||
if subCluster != "" {
|
||||
scNodes := archive.NodeLists[cluster][subCluster]
|
||||
topolNodes = scNodes.PrintList()
|
||||
} else {
|
||||
subClusterNodeLists := archive.NodeLists[cluster]
|
||||
for _, nodeList := range subClusterNodeLists {
|
||||
topolNodes = append(topolNodes, nodeList.PrintList()...)
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Filter nodes
|
||||
if nodeFilter != "" {
|
||||
filteredNodes := []string{}
|
||||
for _, node := range topolNodes {
|
||||
if strings.Contains(node, nodeFilter) {
|
||||
filteredNodes = append(filteredNodes, node)
|
||||
}
|
||||
}
|
||||
topolNodes = filteredNodes
|
||||
}
|
||||
|
||||
// 2.1) Count total nodes && Sort nodes -> Sorting invalidated after ccms return ...
|
||||
totalNodes = len(topolNodes)
|
||||
sort.Strings(topolNodes)
|
||||
|
||||
// 3) Apply paging
|
||||
if len(topolNodes) > page.ItemsPerPage {
|
||||
start := (page.Page - 1) * page.ItemsPerPage
|
||||
end := start + page.ItemsPerPage
|
||||
if end >= len(topolNodes) {
|
||||
end = len(topolNodes)
|
||||
hasNextPage = false
|
||||
} else {
|
||||
hasNextPage = true
|
||||
}
|
||||
topolNodes = topolNodes[start:end]
|
||||
}
|
||||
|
||||
return topolNodes, totalNodes, hasNextPage
|
||||
}
|
||||
|
||||
@@ -912,9 +912,6 @@ func buildNodeQueries(
|
||||
scopes []schema.MetricScope,
|
||||
resolution int64,
|
||||
) ([]APIQuery, []schema.MetricScope, error) {
|
||||
if len(nodes) == 0 {
|
||||
return nil, nil, fmt.Errorf("METRICDATA/CCMS > no nodes specified for query")
|
||||
}
|
||||
|
||||
queries := make([]APIQuery, 0, len(metrics)*len(scopes)*len(nodes))
|
||||
assignedScope := []schema.MetricScope{}
|
||||
|
||||
Reference in New Issue
Block a user