From fa4ee3ea27c732e685afa17961d0fd2a44990dfe Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Mon, 11 Nov 2024 19:53:50 +0100 Subject: [PATCH] Fix isSupportedHarvester Signed-off-by: Francesco Torchia --- .../harvesterhci.io.management.cluster.vue | 36 ++++++---------- .../harvesterhci.io.management.cluster.js | 41 +++++++++++-------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/pkg/harvester/list/harvesterhci.io.management.cluster.vue b/pkg/harvester/list/harvesterhci.io.management.cluster.vue index d090ea34..b73dc9d3 100644 --- a/pkg/harvester/list/harvesterhci.io.management.cluster.vue +++ b/pkg/harvester/list/harvesterhci.io.management.cluster.vue @@ -38,25 +38,6 @@ export default { this.hciClusters = hash.hciClusters; this.mgmtClusters = hash.mgmtClusters; - - for (const cluster of this.mgmtClusters) { - const clusterId = cluster.id; - - if (clusterId === 'local') { - continue; - } - if (clusterId) { - try { - const settingUrl = `/k8s/clusters/${ clusterId }/v1/harvester/${ HCI.SETTING }s?exclude=metadata.managedFields`; - - const r = await this.$store.dispatch('request', { url: settingUrl, method: 'get' }); - - console.log('🚀 ~ fetch ~r = ', r); - } catch (e) { - console.info(`Failed to fetch harvester setting from ${ clusterId }, error=${ e }`); // eslint-disable-line no-console - } - } - } }, data() { @@ -92,11 +73,18 @@ export default { }, rows() { - return this.hciClusters.filter((c) => { - const cluster = this.mgmtClusters.find((cluster) => cluster?.metadata?.name === c?.status?.clusterName); + return this.hciClusters + .filter((c) => { + const cluster = this.mgmtClusters.find((cluster) => cluster?.metadata?.name === c?.status?.clusterName); - return isHarvesterCluster(cluster); - }); + return isHarvesterCluster(cluster); + }) + .map((row) => { + if (row.isReady) { + row.setSupportedHarvesterVersion(); + } + return row; + }); }, typeDisplay() { @@ -164,7 +152,7 @@ export default { = 1.3.0 - */ - get isSupportedHarvesterVersion() { - const version = serverVersion(this.$rootGetters); - - // eslint-disable-next-line no-console - console.log('🚀 ~ HciCluster ~ getisSupportedHarvesterVersion ~ version:', version); - - return semver.gte(version, '1.3.0'); - } - /** * Fetch and cache the response for /ui-info * @@ -209,4 +201,19 @@ export default class HciCluster extends ProvCluster { } }); } + + async setSupportedHarvesterVersion() { + if (this._isSupportedHarvester !== undefined) { + return; + } + + const url = `/k8s/clusters/${ this.status.clusterName }/v1`; + + try { + const setting = await this.$dispatch('request', { url: `${ url }/${ HCI.SETTING }s/server-version` }); + + this._isSupportedHarvester = this.$rootGetters['harvester-common/getFeatureEnabled']('supportHarvesterClusterVersion', setting?.value); + } catch (error) { + } + } }