Skip to content

Commit c4355da

Browse files
Merge pull request #142 from PeterYurkovich/manual-cherry-pick
COO-981,COO-982: Manual Cherry Pick
2 parents a96eb80 + c49a77f commit c4355da

4 files changed

Lines changed: 22 additions & 20 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/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/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: 15 additions & 15 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,
@@ -77,23 +79,20 @@ export class K8sDomain extends Domain {
7779
throw this.badQuery(query, e.message);
7880
}
7981
const m = query.class.name.match(/^([^.]+)(?:\.([^.]*)(?:\.(.*))?)?$/) ?? [];
80-
if (!m) throw this.badQuery(query);
82+
if (!m) throw this.badQuery(query, "incorrect format");
8183
let model = findGVK(m[3], m[2], m[1]);
82-
if (!model) throw this.badQuery(query);
84+
if (!model) throw this.badQuery(query, "no matching resource");
8385
let namespace = data.namespace;
8486
let name = data.name;
8587
let events = '';
8688
if (isEvent(model)) {
8789
// Special treatment for event objects: focus on the involved object, not the event.
8890
events = '/events';
8991
const about = eventAboutField(model);
90-
model = findGVK(
91-
data.fields[`${about}.apiGroup`],
92-
data.fields[`${about}.apiVersion`],
93-
data.fields[`${about}.kind`],
94-
);
95-
if (!model)
96-
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}`);
9796
namespace = data.fields[`${about}.namespace`] || '';
9897
name = data.fields[`${about}.name`] || '';
9998
}
@@ -128,12 +127,13 @@ export class K8sDomain extends Domain {
128127

129128
// Original k8s Event resource was in the core group, modern Event is in the events.k8s.io group.
130129
// Event.v1 has an 'involvedObject' field, Event.v1.events.k8s.io has a 'regarding' field.
131-
// Handle both variations.
130+
// Need to handle both variations.
132131
const EVENT = {
133132
group: 'events.k8s.io',
134133
version: 'v1',
135134
kind: 'Event',
136135
};
136+
137137
function isEvent(m: Model): boolean {
138138
return (
139139
m.kind == EVENT.kind &&

0 commit comments

Comments
 (0)