mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-03-04 07:07:30 +01:00
differentiate between expected and unexpected cases in external ccms queryBuilder
This commit is contained in:
@@ -126,6 +126,7 @@ func (ccms *CCMetricStore) buildQueries(
|
|||||||
hwthreads = topology.Node
|
hwthreads = topology.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: Expected exceptions will return as empty slices -> Continue
|
||||||
hostQueries, hostScopes := buildScopeQueries(
|
hostQueries, hostScopes := buildScopeQueries(
|
||||||
nativeScope, requestedScope,
|
nativeScope, requestedScope,
|
||||||
remoteName, host.Hostname,
|
remoteName, host.Hostname,
|
||||||
@@ -133,8 +134,9 @@ func (ccms *CCMetricStore) buildQueries(
|
|||||||
resolution,
|
resolution,
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(hostQueries) == 0 && len(hostScopes) == 0 {
|
// Note: Unexpected errors, such as unhandled cases, will return as nils -> Error
|
||||||
return nil, nil, fmt.Errorf("METRICDATA/INTERNAL-CCMS > TODO: unhandled case: native-scope=%s, requested-scope=%s", nativeScope, requestedScope)
|
if hostQueries == nil && hostScopes == nil {
|
||||||
|
return nil, nil, fmt.Errorf("METRICDATA/EXTERNAL-CCMS > TODO: unhandled case: native-scope=%s, requested-scope=%s", nativeScope, requestedScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
queries = append(queries, hostQueries...)
|
queries = append(queries, hostQueries...)
|
||||||
@@ -269,6 +271,7 @@ func buildScopeQueries(
|
|||||||
// Accelerator -> Accelerator (Use "accelerator" scope if requested scope is lower than node)
|
// Accelerator -> Accelerator (Use "accelerator" scope if requested scope is lower than node)
|
||||||
if nativeScope == schema.MetricScopeAccelerator && scope.LT(schema.MetricScopeNode) {
|
if nativeScope == schema.MetricScopeAccelerator && scope.LT(schema.MetricScopeNode) {
|
||||||
if scope != schema.MetricScopeAccelerator {
|
if scope != schema.MetricScopeAccelerator {
|
||||||
|
// Expected Exception -> Continue -> Return Empty Slices
|
||||||
return queries, scopes
|
return queries, scopes
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +290,7 @@ func buildScopeQueries(
|
|||||||
// Accelerator -> Node
|
// Accelerator -> Node
|
||||||
if nativeScope == schema.MetricScopeAccelerator && scope == schema.MetricScopeNode {
|
if nativeScope == schema.MetricScopeAccelerator && scope == schema.MetricScopeNode {
|
||||||
if len(accelerators) == 0 {
|
if len(accelerators) == 0 {
|
||||||
|
// Expected Exception -> Continue -> Return Empty Slices
|
||||||
return queries, scopes
|
return queries, scopes
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,6 +451,7 @@ func buildScopeQueries(
|
|||||||
socketToDomains, err := topology.GetMemoryDomainsBySocket(memDomains)
|
socketToDomains, err := topology.GetMemoryDomainsBySocket(memDomains)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.Errorf("Error mapping memory domains to sockets, return unchanged: %v", err)
|
cclog.Errorf("Error mapping memory domains to sockets, return unchanged: %v", err)
|
||||||
|
// Rare Error Case -> Still Continue -> Return Empty Slices
|
||||||
return queries, scopes
|
return queries, scopes
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,8 +512,8 @@ func buildScopeQueries(
|
|||||||
return queries, scopes
|
return queries, scopes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unhandled case - return empty slices
|
// Unhandled Case -> Error -> Return nils
|
||||||
return queries, scopes
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// intToStringSlice converts a slice of integers to a slice of strings.
|
// intToStringSlice converts a slice of integers to a slice of strings.
|
||||||
|
|||||||
Reference in New Issue
Block a user