Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2039315: Filter superseded helm secrets and fix firehose to support partial metadata #10812

Merged
merged 2 commits into from Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion frontend/packages/helm-plugin/console-extensions.json
Expand Up @@ -193,7 +193,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 @@ -30,10 +30,12 @@ export const useHelmActionProviderForTopology = (element: GraphElement) => {
const nodeType = element.getType();
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 === 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 @@ -223,10 +223,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 @@ -281,6 +281,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,
};