Skip to content

Commit 0aa90c5

Browse files
authored
Merge pull request #657 from jpinsonneau/1927-fix
NETOBSERV-1927 fix topology issues
2 parents 3cd798e + 79b4a01 commit 0aa90c5

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

web/src/model/topology.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,18 @@ export const generateDataModel = (
531531
// addPossibleGroups adds peer to one or more groups when relevant, and returns the smallest one
532532
const addPossibleGroups = (peer: TopologyMetricPeer): NodeModel | undefined => {
533533
// groups are all possible scopes except last one
534-
const parentScopes = ContextSingleton.getScopes().slice(0, -1).reverse();
534+
const parentScopes = ContextSingleton.getScopes().slice(0, -1);
535535

536536
// build parent tree from biggest to smallest group
537537
let parent: NodeModel | undefined = undefined;
538538
parentScopes.forEach(sc => {
539539
if (options.groupTypes.includes(`${sc.id}s`) && !_.isEmpty(peer[sc.id])) {
540-
parent = addGroup({ [sc.id]: peer[sc.id] }, sc.id, parent, true);
540+
parent = addGroup(
541+
{ [sc.id]: peer[sc.id], namespace: ['namespace', 'owner'].includes(sc.id) ? peer.namespace : undefined },
542+
sc.id,
543+
parent,
544+
true
545+
);
541546
}
542547
});
543548

web/src/utils/metrics.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,18 @@ const parseTopologyMetric = (
170170
const sourceFields: Partial<TopologyMetricPeer> = {
171171
addr: raw.metric.SrcAddr,
172172
resource: nameAndType(raw.metric.SrcK8S_Name, raw.metric.SrcK8S_Type),
173-
owner: nameAndType(raw.metric.SrcK8S_OwnerName, raw.metric.SrcK8S_OwnerType)
173+
owner:
174+
raw.metric.SrcK8S_Type !== raw.metric.SrcK8S_OwnerType
175+
? nameAndType(raw.metric.SrcK8S_OwnerName, raw.metric.SrcK8S_OwnerType)
176+
: undefined
174177
};
175178
const destFields: Partial<TopologyMetricPeer> = {
176179
addr: raw.metric.DstAddr,
177180
resource: nameAndType(raw.metric.DstK8S_Name, raw.metric.DstK8S_Type),
178-
owner: nameAndType(raw.metric.DstK8S_OwnerName, raw.metric.DstK8S_OwnerType)
181+
owner:
182+
raw.metric.DstK8S_Type !== raw.metric.DstK8S_OwnerType
183+
? nameAndType(raw.metric.DstK8S_OwnerName, raw.metric.DstK8S_OwnerType)
184+
: undefined
179185
};
180186
getCustomScopes().forEach(sc => {
181187
if (!sc.labels.length) {

0 commit comments

Comments
 (0)