Skip to content

Commit 72f2e04

Browse files
alanconwayPeterYurkovich
authored andcommitted
fix(COO-981): Korrel8r Error: field label not supported: involvedObject.apiVersion
Problem: latest korrel8r supports legacy Event.v1 and new Event.v1.events.k8s.io. Support was incomplete, only handled translations query->link. Fix: extend support to link->query translation. https://issues.redhat.com/browse/COO-981
1 parent a96eb80 commit 72f2e04

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

web/src/components/Korrel8rPanel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ export default function Korrel8rPanel() {
5454
persistedSearch?.queryStr
5555
? persistedSearch
5656
: ({
57-
...defaultSearch,
58-
queryStr: locationQuery?.toString(),
59-
constraint: persistedSearch?.constraint,
60-
} as Search),
57+
...defaultSearch,
58+
queryStr: locationQuery?.toString(),
59+
constraint: persistedSearch?.constraint,
60+
} as Search),
6161
);
6262
const [result, setResult] = React.useState<Result | null>(null);
6363
const [showQuery, setShowQuery] = React.useState(false);

web/src/hooks/useLocationQuery.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const useLocationQuery = (): Query | undefined => {
88
try {
99
const link = new URIRef(location.pathname + location.search);
1010
const q = allDomains.linkToQuery(link);
11+
// eslint-disable-next-line no-console
12+
console.log('korrel8r linkToQuery', "\nlink", link, "\nquery", q);
1113
return q;
1214
} catch (e) {
1315
// eslint-disable-next-line no-console

web/src/korrel8r/k8s.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,18 @@ export class K8sDomain extends Domain {
4949
const model = findResource(resource, link.searchParams.get('kind'));
5050
if (!model || !model.kind) throw this.badLink(link, `unknown resource "${resource}"`);
5151
if (events) {
52+
const event = eventModel();
53+
const about = eventAboutField(event);
5254
const apiVersion = `${model.apiGroup ? `${model.apiGroup}/` : ''}${model.apiVersion || 'v1'}`;
5355
const data = {
5456
fields: {
55-
'involvedObject.namespace': namespace,
56-
'involvedObject.name': name,
57-
'involvedObject.apiVersion': apiVersion,
58-
'involvedObject.kind': model.kind,
57+
[`${about}.namespace`]: namespace,
58+
[`${about}.name`]: name,
59+
[`${about}.apiVersion`]: apiVersion,
60+
[`${about}.kind`]: model.kind,
5961
},
6062
};
61-
return this.modelClass(eventModel()).query(JSON.stringify(data));
63+
return this.modelClass(event).query(JSON.stringify(data));
6264
} else {
6365
const data = {
6466
namespace: namespace,
@@ -128,12 +130,13 @@ export class K8sDomain extends Domain {
128130

129131
// Original k8s Event resource was in the core group, modern Event is in the events.k8s.io group.
130132
// Event.v1 has an 'involvedObject' field, Event.v1.events.k8s.io has a 'regarding' field.
131-
// Handle both variations.
133+
// Need to handle both variations.
132134
const EVENT = {
133135
group: 'events.k8s.io',
134136
version: 'v1',
135137
kind: 'Event',
136138
};
139+
137140
function isEvent(m: Model): boolean {
138141
return (
139142
m.kind == EVENT.kind &&

0 commit comments

Comments
 (0)