Skip to content

Commit 700eabf

Browse files
authored
fix(resources): fetch legacy resources by kri (#5105)
We currently try to fetch all resources by their KRI including resources that do not support KRIs, i.e. policies. This fixes the issue by conditionally fetching the "old-style" endpoints. Closes #5086 --------- Signed-off-by: schogges <moritz.fleck@konghq.com>
1 parent 38d9a4b commit 700eabf

3 files changed

Lines changed: 74 additions & 81 deletions

File tree

packages/kuma-gui/features/mesh/services/Item.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Feature: mesh / services / item
149149
Then the "$hostnames:nth-child(1)" element exists
150150

151151
Examples:
152-
| API | URL | SVC |
153-
| /meshes/default/meshservices/my-meshservice/_hostnames | /meshes/default/services/mesh-services/kri_msvc_default___my-meshservice_/overview | svc |
154-
| /meshes/default/meshexternalservices/my-meshservice/_hostnames | /meshes/default/services/mesh-external-services/kri_extsvc_default___my-meshservice_/overview | extsvc |
155-
| /meshes/default/meshmultizoneservices/my-meshservice/_hostnames | /meshes/default/services/mesh-multi-zone-services/kri_mzsvc_default___my-meshservice_/overview | mzsvc |
152+
| API | URL | SVC |
153+
| /meshes/default/meshservices/my-meshservice/_hostnames | /meshes/default/services/mesh-services/kri_msvc_default___my-meshservice_/overview | svc |
154+
| /meshes/default/meshexternalservices/my-meshservice/_hostnames | /meshes/default/services/mesh-external-services/kri_extsvc_default___my-meshservice_/overview | extsvc |
155+
| /meshes/default/meshmultizoneservices/my-meshservice/_hostnames | /meshes/default/services/mesh-multi-zone-services/kri_mzsvc_default___my-meshservice_/overview | mzsvc |

packages/kuma-gui/src/app/resources/views/ResourceListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
>
1414
<DataCollection
1515
:predicate="(resourceType) => typeof resourceType !== 'undefined' && resourceType.path === route.params.resourcePath"
16-
:items="props.resourceTypes?.resources ?? []"
16+
:items="(props.resourceTypes?.resources ?? []).filter((item) => item.shortName.length > 0)"
1717
>
1818
<template #empty>
1919
<XCard>

packages/kuma-gui/src/app/resources/views/ResourceTypeListView.vue

Lines changed: 69 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -69,88 +69,81 @@
6969
:errors="[resourcesError, globalInsightError, meshInsightError]"
7070
v-slot="{ data: [resources, globalInsight, meshInsight] }"
7171
>
72-
<template
73-
v-for="hasLegacyPolicies of [resources.resources.some(resource => !resource.policy?.isTargetRef && (meshInsight.policies[resource.name]?.total ?? 0) > 0)]"
74-
:key="typeof hasLegacyPolicies"
72+
<XLayout
73+
v-for="filtered in [resources.resources.filter((item) =>
74+
(route.params.category === 'all' || item.categories.includes(route.params.category)) && item.shortName.length > 0,
75+
)]"
76+
:key="typeof filtered"
77+
variant="y-stack"
7578
>
76-
<XLayout
77-
v-for="filtered in [resources.resources.filter((item) =>
78-
(route.params.category === 'all' || item.categories.includes(route.params.category)) &&
79-
(!item.policy || item.policy?.isTargetRef || hasLegacyPolicies) &&
80-
(item.name !== 'ExternalService' || meshInsight.services.external > 0)),
81-
]"
82-
:key="typeof filtered"
83-
variant="y-stack"
79+
<template
80+
v-for="([key, group], i) in Object.entries(Object.groupBy(filtered, (resource) => resource.group)).toSorted((a, b) => a[0] > b[0] ? -1 : 1)"
81+
:key="key"
8482
>
85-
<template
86-
v-for="([key, group], i) in Object.entries(Object.groupBy(filtered, (resource) => resource.group)).toSorted((a, b) => a[0] > b[0] ? -1 : 1)"
87-
:key="key"
88-
>
89-
<ul v-if="group?.length">
90-
<li>
91-
<XLayout
92-
variant="y-stack"
83+
<ul v-if="group?.length">
84+
<li>
85+
<XLayout
86+
variant="y-stack"
87+
>
88+
<header>
89+
<h3>{{ t(`resources.routes.items.types.${key}.title`) }}</h3>
90+
</header>
91+
<DataCollection
92+
:items="group"
9393
>
94-
<header>
95-
<h3>{{ t(`resources.routes.items.types.${key}.title`) }}</h3>
96-
</header>
97-
<DataCollection
98-
:items="group"
99-
>
100-
<template #default="{ items }">
101-
<ul>
102-
<li
103-
v-for="(item, j) in items"
104-
:key="item.name"
105-
:class="{
106-
'active': item.path === route.params.resourcePath,
94+
<template #default="{ items }">
95+
<ul>
96+
<li
97+
v-for="(item, j) in items"
98+
:key="item.name"
99+
:class="{
100+
'active': item.path === route.params.resourcePath,
101+
}"
102+
>
103+
<XAction
104+
:to="{
105+
name: 'resource-list-view',
106+
params: {
107+
mesh: route.params.mesh,
108+
resourcePath: item.path,
109+
},
110+
query: {
111+
category: route.params.category,
112+
},
113+
}"
114+
:data-testid="`resource-type-link-${item.name}`"
115+
@vue:mounted="(vNode) => {
116+
if((route.params.resourcePath.length === 0 || !resources.resources.find((resource) => resource.path === route.params.resourcePath)) && i === 0 && j === 0 && vNode.props?.to) {
117+
$nextTick(() => {
118+
route.replace(vNode.props!.to)
119+
})
120+
}
107121
}"
108122
>
109-
<XAction
110-
:to="{
111-
name: 'resource-list-view',
112-
params: {
113-
mesh: route.params.mesh,
114-
resourcePath: item.path,
115-
},
116-
query: {
117-
category: route.params.category,
118-
},
119-
}"
120-
:data-testid="`resource-type-link-${item.name}`"
121-
@vue:mounted="(vNode) => {
122-
if((route.params.resourcePath.length === 0 || !resources.resources.find((resource) => resource.path === route.params.resourcePath)) && i === 0 && j === 0 && vNode.props?.to) {
123-
$nextTick(() => {
124-
route.replace(vNode.props!.to)
125-
})
126-
}
127-
}"
123+
<XLayout
124+
variant="x-stack"
125+
justify="between"
128126
>
129-
<XLayout
130-
variant="x-stack"
131-
justify="between"
132-
>
133-
<span>
134-
{{ item.name }}
135-
</span>
136-
<span v-if="item.group === 'global'">
137-
{{ globalInsight.resources[item.name]?.total ?? 0 }}
138-
</span>
139-
<span v-else>
140-
{{ meshInsight.resources[item.name]?.total ?? 0 }}
141-
</span>
142-
</XLayout>
143-
</XAction>
144-
</li>
145-
</ul>
146-
</template>
147-
</DataCollection>
148-
</XLayout>
149-
</li>
150-
</ul>
151-
</template>
152-
</XLayout>
153-
</template>
127+
<span>
128+
{{ item.name }}
129+
</span>
130+
<span v-if="item.group === 'global'">
131+
{{ globalInsight.resources[item.name]?.total ?? 0 }}
132+
</span>
133+
<span v-else>
134+
{{ meshInsight.resources[item.name]?.total ?? 0 }}
135+
</span>
136+
</XLayout>
137+
</XAction>
138+
</li>
139+
</ul>
140+
</template>
141+
</DataCollection>
142+
</XLayout>
143+
</li>
144+
</ul>
145+
</template>
146+
</XLayout>
154147
</DataLoader>
155148
</XCard>
156149
<div v-if="route.params.resourcePath.length > 0">

0 commit comments

Comments
 (0)