From 932ba0d91d0ac5f58e23e913c4d8979bca905431 Mon Sep 17 00:00:00 2001 From: Gabriel Bernal Date: Thu, 18 Dec 2025 13:36:06 +0100 Subject: [PATCH 1/3] fix: request namespaced resources for filter options Signed-off-by: Gabriel Bernal --- web/src/attribute-filters.tsx | 46 +++++++++++++++++-- .../filters/attribute-value-data.tsx | 8 ++-- web/src/components/filters/filter.types.ts | 2 +- web/src/components/filters/search-select.tsx | 2 +- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/web/src/attribute-filters.tsx b/web/src/attribute-filters.tsx index 44f64a934..68a669afb 100644 --- a/web/src/attribute-filters.tsx +++ b/web/src/attribute-filters.tsx @@ -142,12 +142,14 @@ const resourceDataSource = const { request, abort } = cancellableFetch(endpoint); - const abortFunction = resourceAbort[resource]; + const abortKey = namespace ? `${resource}-${namespace}` : resource; + + const abortFunction = resourceAbort[abortKey]; if (abortFunction) { abortFunction(); } - resourceAbort[resource] = abort; + resourceAbort[abortKey] = abort; const response = await request(); @@ -254,14 +256,22 @@ export const availableAttributes = ({ name: 'Pods', label: podLabel, id: 'pod', - options: getPodAttributeOptions(tenant, config, schema), + options: (filters) => { + const selectedNamespaces = filters?.namespace ? Array.from(filters.namespace) : undefined; + + return getPodAttributeOptions(tenant, config, schema, selectedNamespaces)(); + }, valueType: 'checkbox-select', }, { name: 'Containers', label: containerLabel, id: 'container', - options: getContainerAttributeOptions(tenant, config, schema), + options: (filters) => { + const selectedNamespaces = filters?.namespace ? Array.from(filters.namespace) : undefined; + + return getContainerAttributeOptions(tenant, config, schema, selectedNamespaces)(); + }, expandSelection: (selections) => { const podSelections = new Set(); const containerSelections = new Set(); @@ -724,9 +734,17 @@ const getPodAttributeOptions = ( tenant: string, config: Config, schema: Schema, + namespaces?: Array, ): (() => Promise) => { const { podLabel } = getAttributeLabels(schema); + const namespacedPodsResources: Array> = []; + + // get pods in selected namespaces for users that have restricted access + for (const ns of namespaces || []) { + namespacedPodsResources.push(resourceDataSource({ resource: 'pods', namespace: ns })()); + } + return () => Promise.allSettled>([ lokiLabelValuesDataSource({ @@ -735,6 +753,7 @@ const getPodAttributeOptions = ( labelName: podLabel, })(), resourceDataSource({ resource: 'pods' })(), + ...namespacedPodsResources, ]).then((results) => { const podOptions: Set