Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions web/src/model/topology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,18 @@ export const generateDataModel = (
// addPossibleGroups adds peer to one or more groups when relevant, and returns the smallest one
const addPossibleGroups = (peer: TopologyMetricPeer): NodeModel | undefined => {
// groups are all possible scopes except last one
const parentScopes = ContextSingleton.getScopes().slice(0, -1).reverse();
const parentScopes = ContextSingleton.getScopes().slice(0, -1);

// build parent tree from biggest to smallest group
let parent: NodeModel | undefined = undefined;
parentScopes.forEach(sc => {
if (options.groupTypes.includes(`${sc.id}s`) && !_.isEmpty(peer[sc.id])) {
parent = addGroup({ [sc.id]: peer[sc.id] }, sc.id, parent, true);
parent = addGroup(
{ [sc.id]: peer[sc.id], namespace: ['namespace', 'owner'].includes(sc.id) ? peer.namespace : undefined },
sc.id,
parent,
true
);
}
});

Expand Down
10 changes: 8 additions & 2 deletions web/src/utils/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,18 @@ const parseTopologyMetric = (
const sourceFields: Partial<TopologyMetricPeer> = {
addr: raw.metric.SrcAddr,
resource: nameAndType(raw.metric.SrcK8S_Name, raw.metric.SrcK8S_Type),
owner: nameAndType(raw.metric.SrcK8S_OwnerName, raw.metric.SrcK8S_OwnerType)
owner:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to avoid setting owner if it's the same as leaf Type? Curious because it used to work like this even before the scopes refactor PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm just worrying about potential side effects even if I don't see any right now...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was tons of hardcoded logic for each case (when owner is set / when resource is set and so on), especially for grouping and displaying topology nodes.
Some of this logic is kept but while debugging, I saw that Pods and Services without owners where duplicating their name / type into the owner field.

That's kind of a nonsence and will avoid mistakes if you check the owner field first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same logic was already hardcoded in the display btw:

if (data.peer.owner && data.peer.owner.type !== data.peer.resource?.type) {

raw.metric.SrcK8S_Type !== raw.metric.SrcK8S_OwnerType
? nameAndType(raw.metric.SrcK8S_OwnerName, raw.metric.SrcK8S_OwnerType)
: undefined
};
const destFields: Partial<TopologyMetricPeer> = {
addr: raw.metric.DstAddr,
resource: nameAndType(raw.metric.DstK8S_Name, raw.metric.DstK8S_Type),
owner: nameAndType(raw.metric.DstK8S_OwnerName, raw.metric.DstK8S_OwnerType)
owner:
raw.metric.DstK8S_Type !== raw.metric.DstK8S_OwnerType
? nameAndType(raw.metric.DstK8S_OwnerName, raw.metric.DstK8S_OwnerType)
: undefined
};
getCustomScopes().forEach(sc => {
if (!sc.labels.length) {
Expand Down
Loading