Skip to content

Commit

Permalink
Fix update of machines/pools in cluster detail Pools tab
Browse files Browse the repository at this point in the history
- fix issue where ..
  - state 1 - X machines + Y fake machines = total
  - state 2 - X+1 machines + Y-1 fake machines = same total
- same total meant sortable table `arrangedRows` value wasn't updating
- fix is to ensure the sort generation changes so `arrangedRows` doesn't return the cached rows
- this is the same method used for the project/namespace list
  • Loading branch information
richard-cox committed Feb 20, 2023
1 parent a4c1caf commit 6ce6632
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
23 changes: 23 additions & 0 deletions shell/detail/provisioning.cattle.io.cluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Socket, {
import { get } from '@shell/utils/object';
import CapiMachineDeployment from '@shell/models/cluster.x-k8s.io.machinedeployment';
import { isAlternate } from '@shell/utils/platform';
import { defaultTableSortGenerationFn } from '@shell/components/ResourceTable.vue';
let lastId = 1;
const ansiup = new AnsiUp();
Expand Down Expand Up @@ -638,6 +639,26 @@ export default {
return day(time).format(this.dateTimeFormatStr);
}
},
machineSortGenerationFn() {
// The sort generation function creates a unique value and is used to create a key including sort details.
// The unique key determines if the list is redrawn or a cached version is shown.
// Because we ensure the 'not in a pool' group is there via a row, and timing issues, the unqiue key doesn't change
// after a machine is added/removed... so the list won't update... so we need to inject a string to ensure the key is fresh
const base = defaultTableSortGenerationFn(this.machineSchema, this.$store);
return base + (!!this.fakeMachines.length ? '-fake' : '');
},
nodeSortGenerationFn() {
// The sort generation function creates a unique value and is used to create a key including sort details.
// The unique key determines if the list is redrawn or a cached version is shown.
// Because we ensure the 'not in a pool' group is there via a row, and timing issues, the unqiue key doesn't change
// after a machine is added/removed... so the list won't update... so we need to inject a string to ensure the key is fresh
const base = defaultTableSortGenerationFn(this.mgmtNodeSchema, this.$store);
return base + (!!this.fakeNodes.length ? '-fake' : '');
},
}
};
</script>
Expand Down Expand Up @@ -681,6 +702,7 @@ export default {
:group-by="value.isCustom ? null : 'poolId'"
group-ref="pool"
:group-sort="['pool.nameDisplay']"
:sort-generation-fn="machineSortGenerationFn"
>
<template #main-row:isFake="{fullColspan}">
<tr class="main-row">
Expand Down Expand Up @@ -765,6 +787,7 @@ export default {
:group-by="value.isCustom ? null : 'spec.nodePoolName'"
group-ref="pool"
:group-sort="['pool.nameDisplay']"
:sort-generation-fn="nodeSortGenerationFn"
>
<template #main-row:isFake="{fullColspan}">
<tr class="main-row">
Expand Down
9 changes: 7 additions & 2 deletions shell/plugins/steve/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,9 @@ const defaultActions = {
* - Steve tells us that the resource is no longer watched
*
*/
'ws.resource.stop'({ getters, commit, dispatch }, msg) {
'ws.resource.stop'({
state, getters, commit, dispatch
}, msg) {
const type = msg.resourceType;
const obj = {
type,
Expand All @@ -714,7 +716,7 @@ const defaultActions = {
selector: msg.selector
};

// console.warn(`Resource stop: [${ getters.storeName }]`, msg); // eslint-disable-line no-console
state.debugSocket && console.info(`Resource Stop [${ getters.storeName }]`, type, msg); // eslint-disable-line no-console

// If we're trying to watch this event, attempt to re-watch
if ( getters['schemaFor'](type) && getters['watchStarted'](obj) ) {
Expand Down Expand Up @@ -759,6 +761,7 @@ const defaultActions = {
},

'ws.resource.create'(ctx, msg) {
ctx.state.debugSocket && console.info(`Resource Create [${ ctx.getters.storeName }]`, msg.resourceType, msg); // eslint-disable-line no-console
queueChange(ctx, msg, true, 'Create');
},

Expand Down Expand Up @@ -809,6 +812,8 @@ const defaultActions = {
const data = msg.data;
const type = data.type;

ctx.state.debugSocket && console.info(`Resource Remove [${ ctx.getters.storeName }]`, type, msg); // eslint-disable-line no-console

if (type === SCHEMA) {
const worker = (this.$workers || {})[ctx.getters.storeName];

Expand Down

0 comments on commit 6ce6632

Please sign in to comment.