From 6ce6632e1357f29948a30fff7922a3474e326637 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 20 Feb 2023 17:09:52 +0000 Subject: [PATCH 1/3] Fix update of machines/pools in cluster detail Pools tab - 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 --- .../detail/provisioning.cattle.io.cluster.vue | 23 +++++++++++++++++++ shell/plugins/steve/subscribe.js | 9 ++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/shell/detail/provisioning.cattle.io.cluster.vue b/shell/detail/provisioning.cattle.io.cluster.vue index bf332504daf..ae20d3a9c57 100644 --- a/shell/detail/provisioning.cattle.io.cluster.vue +++ b/shell/detail/provisioning.cattle.io.cluster.vue @@ -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(); @@ -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' : ''); + }, } }; @@ -681,6 +702,7 @@ export default { :group-by="value.isCustom ? null : 'poolId'" group-ref="pool" :group-sort="['pool.nameDisplay']" + :sort-generation-fn="machineSortGenerationFn" >