Skip to content

Commit

Permalink
Filter superseded helm secrets and fix firehose to support partial me…
Browse files Browse the repository at this point in the history
…tadata

Backport of openshift#10812
  • Loading branch information
jerolimov committed Jan 24, 2022
1 parent 37de957 commit dd84521
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 13 deletions.
15 changes: 14 additions & 1 deletion frontend/packages/helm-plugin/console-extensions.json
Expand Up @@ -182,7 +182,20 @@
"id": "helm-topology-model-factory",
"priority": 400,
"resources": {
"secrets": { "opts": { "isList": true, "kind": "Secret", "optional": true } }
"secrets": {
"opts": {
"isList": true,
"kind": "Secret",
"optional": true,
"selector": {
"matchLabels": { "owner": "helm" },
"matchExpressions": [
{ "key": "status", "operator": "NotEquals", "values": ["superseded"] }
]
},
"partialMetadata": true
}
}
},
"getDataModel": { "$codeRef": "helmTopology.getHelmTopologyDataModel" },
"isResourceDepicted": { "$codeRef": "helmTopology.isHelmResourceInModel" }
Expand Down
4 changes: 3 additions & 1 deletion frontend/packages/helm-plugin/src/actions/providers.ts
Expand Up @@ -28,10 +28,12 @@ export const useHelmActionProviderForTopology = (element: GraphElement) => {
const scope = React.useMemo(() => {
if (nodeType !== TYPE_HELM_RELEASE) return undefined;
const releaseName = element.getLabel();
const resource = getResource(element);
if (!resource?.metadata) return null;
const {
namespace,
labels: { version },
} = getResource(element).metadata;
} = resource.metadata;
return {
release: {
name: releaseName,
Expand Down
Expand Up @@ -47,7 +47,10 @@ const HelmReleaseList: React.FC<HelmReleaseListProps> = ({ namespace }) => {
kind: SecretModel.kind,
namespaced: true,
optional: true,
selector: { matchLabels: { owner: 'helm' } },
selector: {
matchLabels: { owner: 'helm' },
matchExpressions: [{ key: 'status', operator: 'NotEquals', values: ['superseded'] }],
},
partialMetadata: true,
}),
[namespace],
Expand Down
Expand Up @@ -43,7 +43,6 @@ export const getTopologyHelmReleaseGroupItem = (
const resourceKindName = getHelmReleaseKey(obj);
const helmResources = helmResourcesMap[resourceKindName];
const releaseName = helmResources?.releaseName;
const releaseVersion = helmResources?.releaseVersion;
const releaseNotes = helmResources?.releaseNotes;
const uid = obj?.metadata?.uid ?? null;
const returnData = [];
Expand All @@ -53,8 +52,7 @@ export const getTopologyHelmReleaseGroupItem = (
}

const secret = secrets.find((nextSecret) => {
const { labels } = nextSecret.metadata;
return labels?.name?.includes(releaseName) && labels?.version === releaseVersion.toString();
return nextSecret.metadata.labels?.name === releaseName;
});

if (secret) {
Expand Down
4 changes: 4 additions & 0 deletions frontend/packages/helm-plugin/src/topology/helmResources.ts
Expand Up @@ -5,6 +5,10 @@ export const getHelmWatchedResources = (namespace: string) => {
kind: 'Secret',
namespace,
optional: true,
selector: {
matchLabels: { owner: 'helm' },
matchExpressions: [{ key: 'status', operator: 'NotEquals', values: ['superseded'] }],
},
partialMetadata: true,
},
};
Expand Down
Expand Up @@ -8,7 +8,9 @@ import { TYPE_HELM_RELEASE } from '../../components/const';
const helmReleasePanelResourceLink = (element: GraphElement) => {
if (element.getType() !== TYPE_HELM_RELEASE) return undefined;
const name = element.getLabel();
const { namespace } = getResource(element).metadata;
const resource = getResource(element);
if (!resource?.metadata) return null;
const { namespace } = resource.metadata;
return (
<>
<ResourceIcon className="co-m-resource-icon--lg" kind="HelmRelease" />
Expand Down
Expand Up @@ -36,16 +36,18 @@ export const getHelmReleasePanelDetailsTabSection = (element: GraphElement) => {
export const getHelmReleasePanelResourceTabSection = (element: GraphElement) => {
if (element.getType() !== TYPE_HELM_RELEASE) return undefined;
const { manifestResources } = element.getData().data;
const { namespace } = getResource(element).metadata;
const resource = getResource(element);
if (!manifestResources || !resource?.metadata) return null;
const { namespace } = resource.metadata;

return manifestResources ? (
return (
<div className="overview__sidebar-pane-body">
<TopologyGroupResourcesPanel
manifestResources={manifestResources}
releaseNamespace={namespace}
/>
</div>
) : null;
);
};

export const getHelmReleasePanelReleaseNotesTabSection = (element: GraphElement) => {
Expand Down
7 changes: 4 additions & 3 deletions frontend/public/components/utils/firehose.jsx
Expand Up @@ -222,10 +222,10 @@ export const Firehose = connect(
});
}

firehoses.forEach(({ id, query, k8sKind, isList, name, namespace }) =>
firehoses.forEach(({ id, query, k8sKind, isList, name, namespace, partialMetadata }) =>
isList
? watchK8sList(id, query, k8sKind)
: watchK8sObject(id, name, namespace, query, k8sKind),
? watchK8sList(id, query, k8sKind, null, partialMetadata)
: watchK8sObject(id, name, namespace, query, k8sKind, partialMetadata),
);
this.setState({ firehoses });
}
Expand Down Expand Up @@ -280,6 +280,7 @@ Firehose.propTypes = {
isList: PropTypes.bool,
optional: PropTypes.bool, // do not block children-rendering while resource is still being loaded; do not fail if resource is missing (404)
limit: PropTypes.number,
partialMetadata: PropTypes.bool,
}),
).isRequired,
};

0 comments on commit dd84521

Please sign in to comment.