Skip to content

Commit 0d4e7d8

Browse files
authored
Merge pull request #16914 from richard-cox/workload-health
Re-introduce workload health in Vai workload lists
2 parents ed8c73c + 0e0c5c6 commit 0d4e7d8

10 files changed

Lines changed: 78 additions & 18 deletions

File tree

shell/components/formatter/WorkloadHealthScale.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ export default {
6767
color: `bg-${ value.color }`,
6868
value: value.count || 0,
6969
label: ucFirst(name)
70-
})).filter((x) => x.value > 0);
70+
}))
71+
.filter((x) => x.value > 0)
72+
.sort((a, b) => a.label.localeCompare(b.label));
7173
7274
return 5;
7375
},

shell/config/pagination-table-headers.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
EVENT_LAST_SEEN_TIME,
55
EVENT_TYPE,
66
SECRET_ORIGIN,
7-
EVENT_FIRST_SEEN_TIME
7+
EVENT_FIRST_SEEN_TIME,
8+
WORKLOAD_HEALTH_SCALE
89
} from '@shell/config/table-headers';
910

1011
// This file contains table headers
@@ -95,3 +96,9 @@ export const STEVE_SECRET_ORIGIN = {
9596
// So we sort by the 'UI_PROJECT_SECRET_COPY' annotation (management.cattle.io/project-scoped-secret-copy) which at least groups the copies.
9697
sort: `metadata.annotations[${ UI_PROJECT_SECRET_COPY }]:desc`,
9798
};
99+
100+
export const STEVE_WORKLOAD_HEALTH_SCALE = {
101+
...WORKLOAD_HEALTH_SCALE,
102+
sort: false,
103+
search: false,
104+
};

shell/config/product/explorer.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import {
2727

2828
import { DSL } from '@shell/store/type-map';
2929
import {
30-
STEVE_AGE_COL, STEVE_EVENT_FIRST_SEEN, STEVE_EVENT_LAST_SEEN, STEVE_EVENT_OBJECT, STEVE_EVENT_TYPE, STEVE_LIST_GROUPS, STEVE_NAMESPACE_COL, STEVE_NAME_COL, STEVE_STATE_COL
30+
STEVE_AGE_COL, STEVE_EVENT_FIRST_SEEN, STEVE_EVENT_LAST_SEEN, STEVE_EVENT_OBJECT, STEVE_EVENT_TYPE, STEVE_LIST_GROUPS, STEVE_NAMESPACE_COL, STEVE_NAME_COL, STEVE_STATE_COL,
31+
STEVE_WORKLOAD_HEALTH_SCALE
3132
} from '@shell/config/pagination-table-headers';
3233

3334
import { COLUMN_BREAKPOINTS } from '@shell/types/store/type-map';
@@ -387,19 +388,19 @@ export function init(store) {
387388
headers(WORKLOAD, [STATE, NAME_COL, NAMESPACE_COL, TYPE, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, POD_RESTARTS, AGE, WORKLOAD_HEALTH_SCALE]);
388389
headers(WORKLOAD_TYPES.DEPLOYMENT,
389390
[STATE, NAME_COL, NAMESPACE_COL, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, 'Ready', 'Up-to-date', 'Available', POD_RESTARTS, AGE, WORKLOAD_HEALTH_SCALE],
390-
[STEVE_STATE_COL, STEVE_NAME_COL, STEVE_NAMESPACE_COL, createSteveWorkloadImageCol(6), STEVE_WORKLOAD_ENDPOINTS, 'Ready', 'Up-to-date', 'Available', STEVE_AGE_COL],
391+
[STEVE_STATE_COL, STEVE_NAME_COL, STEVE_NAMESPACE_COL, createSteveWorkloadImageCol(6), STEVE_WORKLOAD_ENDPOINTS, 'Ready', 'Up-to-date', 'Available', STEVE_AGE_COL, STEVE_WORKLOAD_HEALTH_SCALE],
391392
);
392393
headers(WORKLOAD_TYPES.DAEMON_SET,
393394
[STATE, NAME_COL, NAMESPACE_COL, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, 'Ready', 'Current', 'Desired', POD_RESTARTS, AGE, WORKLOAD_HEALTH_SCALE],
394-
[STEVE_STATE_COL, STEVE_NAME_COL, STEVE_NAMESPACE_COL, createSteveWorkloadImageCol(9), STEVE_WORKLOAD_ENDPOINTS, 'Ready', 'Current', 'Desired', STEVE_AGE_COL]
395+
[STEVE_STATE_COL, STEVE_NAME_COL, STEVE_NAMESPACE_COL, createSteveWorkloadImageCol(9), STEVE_WORKLOAD_ENDPOINTS, 'Ready', 'Current', 'Desired', STEVE_AGE_COL, STEVE_WORKLOAD_HEALTH_SCALE]
395396
);
396397
headers(WORKLOAD_TYPES.REPLICA_SET,
397398
[STATE, NAME_COL, NAMESPACE_COL, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, 'Ready', 'Current', 'Desired', POD_RESTARTS, AGE, WORKLOAD_HEALTH_SCALE],
398399
[STEVE_STATE_COL, STEVE_NAME_COL, STEVE_NAMESPACE_COL, createSteveWorkloadImageCol(6), STEVE_WORKLOAD_ENDPOINTS, 'Ready', 'Current', 'Desired', STEVE_AGE_COL],
399400
);
400401
headers(WORKLOAD_TYPES.STATEFUL_SET,
401402
[STATE, NAME_COL, NAMESPACE_COL, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, 'Ready', POD_RESTARTS, AGE, WORKLOAD_HEALTH_SCALE],
402-
[STEVE_STATE_COL, STEVE_NAME_COL, STEVE_NAMESPACE_COL, createSteveWorkloadImageCol(4), STEVE_WORKLOAD_ENDPOINTS, 'Ready', STEVE_AGE_COL],
403+
[STEVE_STATE_COL, STEVE_NAME_COL, STEVE_NAMESPACE_COL, createSteveWorkloadImageCol(4), STEVE_WORKLOAD_ENDPOINTS, 'Ready', STEVE_AGE_COL, STEVE_WORKLOAD_HEALTH_SCALE],
403404
);
404405
headers(WORKLOAD_TYPES.JOB,
405406
[STATE, NAME_COL, NAMESPACE_COL, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, 'Completions', DURATION, POD_RESTARTS, AGE, WORKLOAD_HEALTH_SCALE],
@@ -409,7 +410,7 @@ export function init(store) {
409410
sort: 'metadata.fields.3',
410411
search: 'metadata.fields.3',
411412
formatter: undefined, // Now that sort/search is remote we're not doing weird things with start time (see `duration` in model)
412-
}, STEVE_AGE_COL],
413+
}, STEVE_AGE_COL, STEVE_WORKLOAD_HEALTH_SCALE],
413414
);
414415
headers(WORKLOAD_TYPES.CRON_JOB,
415416
[STATE, NAME_COL, NAMESPACE_COL, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, 'Schedule', 'Last Schedule', POD_RESTARTS, AGE, WORKLOAD_HEALTH_SCALE],

shell/list/workload.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,21 @@ export default {
9999
const schema = type !== workloadSchema.id ? this.$store.getters['cluster/schemaFor'](type) : workloadSchema;
100100
const paginationEnabled = !allTypes && this.$store.getters[`cluster/paginationEnabled`]?.({ id: type });
101101
102+
const workloadIncludeAssociatedData = paginationEnabled && [
103+
WORKLOAD_TYPES.DEPLOYMENT,
104+
WORKLOAD_TYPES.DAEMON_SET,
105+
WORKLOAD_TYPES.STATEFUL_SET,
106+
WORKLOAD_TYPES.JOB,
107+
].includes(type);
108+
102109
return {
103110
allTypes,
104111
schema,
105112
paginationEnabled,
106113
resources: [],
107114
loadResources,
108-
loadIndeterminate
115+
loadIndeterminate,
116+
workloadIncludeAssociatedData
109117
};
110118
},
111119
@@ -143,10 +151,8 @@ export default {
143151
* Fetch resources required to populate POD_RESTARTS and WORKLOAD_HEALTH_SCALE columns
144152
*/
145153
loadHeathResources() {
146-
// See https://github.com/rancher/dashboard/issues/10417, health comes from selectors applied locally to all pods (bad)
147154
if (this.paginationEnabled) {
148-
// Unfortunately with SSP enabled we cannot fetch all pods to then let each row find applicable pods by locally applied selectors (bad for scaling)
149-
// See https://github.com/rancher/dashboard/issues/14211
155+
// When SSP is enabled we efficiently fetch stats for health column imbedded in the original resource type by supplying `includeAssociatedData` param
150156
return;
151157
}
152158
@@ -184,6 +190,7 @@ export default {
184190
v-if="paginationEnabled"
185191
:schema="schema"
186192
:use-query-params-for-simple-filtering="useQueryParamsForSimpleFiltering"
193+
:includeAssociatedData="workloadIncludeAssociatedData"
187194
/>
188195
<ResourceTable
189196
v-else

shell/mixins/resource-fetch.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ export default {
8787
type: Function,
8888
default: null,
8989
},
90+
91+
/**
92+
* When making a supporting HTTP request include associated resource data
93+
*/
94+
includeAssociatedData: {
95+
type: Boolean,
96+
default: false,
97+
},
9098
},
9199

92100
computed: {
@@ -185,9 +193,10 @@ export default {
185193
return;
186194
}
187195
const opt = {
188-
hasManualRefresh: this.hasManualRefresh,
189-
pagination: { ...this.pagination },
190-
force: this.paginating !== null // Fix for manual refresh (before ripped out).
196+
hasManualRefresh: this.hasManualRefresh,
197+
pagination: { ...this.pagination },
198+
force: this.paginating !== null, // Fix for manual refresh (before ripped out).
199+
includeAssociatedData: this.includeAssociatedData,
191200
};
192201

193202
if (this.apiFilter) {

shell/models/workload.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import WorkloadService from '@shell/models/workload.service';
99
import { matching } from '@shell/utils/selector-typed';
1010
import { defineAsyncComponent, markRaw } from 'vue';
1111
import { useResourceCardRow } from '@shell/components/Resource/Detail/Card/StateCard/composables';
12+
import { colorForState as colorForStateFn, stateDisplay as stateDisplayFn } from '@shell/plugins/dashboard-store/resource-class';
1213

1314
export const defaultContainer = {
1415
imagePullPolicy: 'Always',
@@ -622,12 +623,29 @@ export default class Workload extends WorkloadService {
622623

623624
calcPodGauges(pods) {
624625
const out = { };
626+
let refPods = pods;
625627

626-
if (!pods) {
628+
if (this.metadata.associatedData) {
629+
refPods = [];
630+
this.metadata.associatedData.forEach((w) => {
631+
if (w.gvk.kind.toLowerCase() !== POD) {
632+
return;
633+
}
634+
635+
return w.data.forEach((p) => {
636+
refPods.push({
637+
stateColor: colorForStateFn(p.state.name, p.state.error === 'true', p.state.transitioning === 'true'),
638+
stateDisplay: stateDisplayFn(p.state.name),
639+
});
640+
});
641+
});
642+
}
643+
644+
if (!refPods) {
627645
return out;
628646
}
629647

630-
pods.map((pod) => {
648+
refPods.map((pod) => {
631649
const { stateColor, stateDisplay } = pod;
632650

633651
if (out[stateDisplay]) {

shell/plugins/dashboard-store/actions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,9 @@ export default {
494494
// Of type @StorePaginationResult
495495
const pagination = opt.pagination ? {
496496
request: {
497-
namespace: opt.namespaced,
498-
pagination: opt.pagination
497+
namespace: opt.namespaced,
498+
pagination: opt.pagination,
499+
includeAssociatedData: opt.includeAssociatedData,
499500
},
500501
result: {
501502
count: out.count,

shell/plugins/steve/steve-pagination-utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ class StevePaginationUtils extends NamespaceProjectFilters {
517517
}
518518
}
519519

520+
if (opt.includeAssociatedData) {
521+
params.push('includeAssociatedData=true');
522+
}
523+
520524
// Note - There is a `limit` property that is by default 100,000. This can be disabled by using `limit=-1`,
521525
// but we shouldn't be fetching any pages big enough to exceed the default
522526

shell/types/store/dashboard-store.types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ export interface ActionFindPageArgs extends ActionCoreFindArgs {
8383

8484
saveCountAs?: string,
8585

86+
/**
87+
* When making a supporting HTTP request include associated resource data
88+
*/
89+
includeAssociatedData?: boolean,
90+
8691
/**
8792
* The target minimum revision for the resource.
8893
*

shell/types/store/pagination.types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ export interface StorePaginationRequest {
607607
* The single namespace to filter results by (as part of url path, not pagination params)
608608
*/
609609
namespace?: string,
610+
610611
/**
611612
* The set of pagination args used to create the request
612613
*/
@@ -616,6 +617,11 @@ export interface StorePaginationRequest {
616617
* Does this request stem from a list with manual refresh?
617618
*/
618619
hasManualRefresh?: boolean,
620+
621+
/**
622+
* When making a supporting HTTP request include associated resource data
623+
*/
624+
includeAssociatedData?: boolean,
619625
}
620626

621627
/**

0 commit comments

Comments
 (0)