Skip to content

Commit 9ab90bc

Browse files
committed
fix(coo-982): No response when click the K8s Events in some scenes
Fixed bug in apiVersion parsing for events. https://issues.redhat.com/browse/COO-982
1 parent 5458a7a commit 9ab90bc

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

web/src/components/topology/Korrel8rTopology.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,11 @@ export const Korrel8rTopology: React.FC<{
148148
(query: korrel8r.Query) => {
149149
try {
150150
const link = allDomains.queryToLink(query)?.toString();
151+
console.log('korrel8r queryToLink', "\nquery", query, "\nlink", link);
151152
if (link) navigate(link.startsWith('/') ? link : `/${link}`);
152153
} catch (e) {
153154
// eslint-disable-next-line no-console
154-
console.error(`navigateToQuery failed for: ${query.toString()}: `, e);
155+
console.error(`korrel8r navigateToQuery: ${e}`, "\nquery", query);
155156
}
156157
},
157158
[navigate],

web/src/korrel8r/k8s.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,20 @@ export class K8sDomain extends Domain {
7979
throw this.badQuery(query, e.message);
8080
}
8181
const m = query.class.name.match(/^([^.]+)(?:\.([^.]*)(?:\.(.*))?)?$/) ?? [];
82-
if (!m) throw this.badQuery(query);
82+
if (!m) throw this.badQuery(query, "incorrect format");
8383
let model = findGVK(m[3], m[2], m[1]);
84-
if (!model) throw this.badQuery(query);
84+
if (!model) throw this.badQuery(query, "no matching resource");
8585
let namespace = data.namespace;
8686
let name = data.name;
8787
let events = '';
8888
if (isEvent(model)) {
8989
// Special treatment for event objects: focus on the involved object, not the event.
9090
events = '/events';
9191
const about = eventAboutField(model);
92-
model = findGVK(
93-
data.fields[`${about}.apiGroup`],
94-
data.fields[`${about}.apiVersion`],
95-
data.fields[`${about}.kind`],
96-
);
97-
if (!model)
98-
throw this.badQuery(query, `no resource for '${about}' field in ${query.selector}`);
92+
const [group, version] = data.fields[`${about}.apiVersion`]?.split("/") ?? []
93+
const kind = data.fields[`${about}.kind`]
94+
model = findGVK(group, version, kind)
95+
if (!model) throw this.badQuery(query, `no resource for group=${group} version=${version} kind=${kind}`);
9996
namespace = data.fields[`${about}.namespace`] || '';
10097
name = data.fields[`${about}.name`] || '';
10198
}

0 commit comments

Comments
 (0)