Skip to content

Commit c49a77f

Browse files
alanconwayPeterYurkovich
authored andcommitted
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 72f2e04 commit c49a77f

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

web/src/components/topology/Korrel8rTopology.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const Korrel8rTopology: React.FC<{
151151
navigate(link.startsWith('/') ? link : `/${link}`);
152152
} catch (e) {
153153
// eslint-disable-next-line no-console
154-
console.error(`navigateToQuery failed for: ${query.toString()}: `, e);
154+
console.error(`korrel8r navigateToQuery: ${e}`, "\nquery", query);
155155
}
156156
},
157157
[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)