mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-01-28 06:51:45 +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"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -683,6 +684,11 @@ func (r *NodeRepository) GetNodesForList(
|
|||||||
hasNextPage = len(nextNodes) == 1
|
hasNextPage = len(nextNodes) == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback, ignores stateFilter
|
||||||
|
// if countNodes == 0 {
|
||||||
|
// nodes, countNodes, hasNextPage = getNodesFromTopol(cluster, subCluster, nodeFilter, page)
|
||||||
|
// }
|
||||||
|
|
||||||
return nodes, stateMap, countNodes, hasNextPage, nil
|
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")
|
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,
|
scopes []schema.MetricScope,
|
||||||
resolution int64,
|
resolution int64,
|
||||||
) ([]APIQuery, []schema.MetricScope, error) {
|
) ([]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))
|
queries := make([]APIQuery, 0, len(metrics)*len(scopes)*len(nodes))
|
||||||
assignedScope := []schema.MetricScope{}
|
assignedScope := []schema.MetricScope{}
|
||||||
|
|||||||
Reference in New Issue
Block a user