diff --git a/pkg/harvester-manager/l10n/en-us.yaml b/pkg/harvester-manager/l10n/en-us.yaml index adcfae96ed..ae122e1760 100644 --- a/pkg/harvester-manager/l10n/en-us.yaml +++ b/pkg/harvester-manager/l10n/en-us.yaml @@ -33,6 +33,10 @@ harvesterManager: warning: "The Harvester UI Extension repository is missing" prompt: "Please click on Update button to add the Harvester repository and install the latest Harvester UI Extension, if any" prompt-standard-user: Please contact your system administrator to install the latest Harvester UI Extension, if any + missingVersion: + warning: "Could not find a compatible version" + prompt: "Please update Rancher to get the latest compatible version of the Harvester UI extension" + prompt-standard-user: Please contact your system administrator error: warning: "Warning, Harvester UI extension automatic installation failed" prompt: "Please refresh the page and try again or install the Harvester UI extension manually" diff --git a/pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue b/pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue index 05ef49013d..c25490cf9b 100644 --- a/pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue +++ b/pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue @@ -24,7 +24,7 @@ import { waitForUIExtension, waitForUIPackage, } from '@shell/utils/uiplugins'; -import { isRancherPrime } from '@shell/config/version'; +import { isRancherPrime, getVersionData } from '@shell/config/version'; const HARVESTER_REPO = isRancherPrime() ? HARVESTER_RANCHER_REPO : HARVESTER_COMMUNITY_REPO; @@ -78,8 +78,11 @@ export default { realSchema: this.$store.getters['management/schemaFor'](CAPI.RANCHER_CLUSTER), hciClusters: [], mgmtClusters: [], + rancherVersion: getVersionData()?.Version || '', + kubeVersion: this.$store.getters['management/byId'](MANAGEMENT.CLUSTER, 'local')?.kubernetesVersionBase || '', harvesterRepository: null, - harvesterLatestVersion: null, + harvesterInstallVersion: true, + harvesterUpdateVersion: null, harvesterRepositoryError: false, harvesterExtensionInstallError: false, harvesterExtensionUpdateError: false, @@ -104,7 +107,7 @@ export default { await refreshHelmRepository(this.$store, HARVESTER_REPO.spec.gitRepo, HARVESTER_REPO.spec.gitBranch); if (this.harvester.extension) { - await this.setHarvesterLatestVersion(); + await this.setHarvesterUpdateVersion(); } } } @@ -116,7 +119,6 @@ export default { harvester() { const extension = this.uiplugins?.find((c) => c.name === HARVESTER_CHART.name); const missingRepository = !!extension && !this.harvesterRepository; - const isLatestVersionAvailable = !!this.harvesterLatestVersion; const action = async(btnCb) => { const action = `${ !extension ? 'install' : 'update' }HarvesterExtension`; @@ -124,7 +126,8 @@ export default { await this[action](btnCb); }; - const hasErrors = this.harvesterRepositoryError || + const hasErrors = !this.harvesterInstallVersion || + this.harvesterRepositoryError || this.harvesterExtensionInstallError || this.harvesterExtensionUpdateError; @@ -134,11 +137,13 @@ export default { ].reduce((acc, label) => { let action = ''; - if (hasErrors) { + if (!this.harvesterInstallVersion) { + action = 'missingVersion'; + } else if (hasErrors) { action = 'error'; } else if (missingRepository) { action = 'missingRepo'; - } else if (isLatestVersionAvailable) { + } else if (!!this.harvesterUpdateVersion) { action = 'update'; } else if (!extension) { action = 'install'; @@ -159,9 +164,8 @@ export default { return { extension, missingRepository, - isLatestVersionAvailable, toInstall: !extension, - toUpdate: missingRepository || isLatestVersionAvailable, + toUpdate: missingRepository || !!this.harvesterUpdateVersion, action, panelLabel, hasErrors, @@ -214,12 +218,12 @@ export default { } }, - async setHarvesterLatestVersion() { + async setHarvesterUpdateVersion() { try { - const version = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name); + const version = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name, this.rancherVersion, this.kubeVersion); if (semver.gt(version, this.harvester.extension.version)) { - this.harvesterLatestVersion = version; + this.harvesterUpdateVersion = version; } } catch (error) { this.harvesterExtensionUpdateError = true; @@ -238,17 +242,20 @@ export default { */ await refreshHelmRepository(this.$store, HARVESTER_REPO.spec.gitRepo, HARVESTER_REPO.spec.gitBranch); - const version = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name); + this.harvesterInstallVersion = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name, this.rancherVersion, this.kubeVersion); - await installHelmChart(harvesterRepo, { ...HARVESTER_CHART, version }, {}, UI_PLUGIN_NAMESPACE, 'install'); + if (!this.harvesterInstallVersion) { + btnCb(false); + + return; + } + + await installHelmChart(harvesterRepo, { ...HARVESTER_CHART, version: this.harvesterInstallVersion }, {}, UI_PLUGIN_NAMESPACE, 'install'); const extension = await waitForUIExtension(this.$store, HARVESTER_CHART.name); installed = await waitForUIPackage(this.$store, extension); } catch (error) { - this.harvesterExtensionInstallError = true; - - btnCb(false); } this.harvesterExtensionInstallError = !installed; @@ -264,23 +271,24 @@ export default { let updated = false; try { - let harvesterRepository = this.harvesterRepository; - if (this.harvester.missingRepository) { - harvesterRepository = await ensureHelmRepository(this.$store, HARVESTER_REPO.spec.gitRepo, HARVESTER_REPO.metadata.name, HARVESTER_REPO.spec.gitBranch); + this.harvesterRepository = await ensureHelmRepository(this.$store, HARVESTER_REPO.spec.gitRepo, HARVESTER_REPO.metadata.name, HARVESTER_REPO.spec.gitBranch); - await this.setHarvesterLatestVersion(); + await this.setHarvesterUpdateVersion(); } - await installHelmChart(harvesterRepository, { ...HARVESTER_CHART, version: this.harvesterLatestVersion }, {}, UI_PLUGIN_NAMESPACE, 'upgrade'); + if (!this.harvesterUpdateVersion) { + btnCb(true); + + return; + } + + await installHelmChart(this.harvesterRepository, { ...HARVESTER_CHART, version: this.harvesterUpdateVersion }, {}, UI_PLUGIN_NAMESPACE, 'upgrade'); const extension = await waitForUIExtension(this.$store, HARVESTER_CHART.name); - updated = await waitForUIPackage(this.$store, { ...extension, version: this.harvesterLatestVersion }); + updated = await waitForUIPackage(this.$store, { ...extension, version: this.harvesterUpdateVersion }); } catch (error) { - this.harvesterExtensionUpdateError = true; - - btnCb(false); } this.harvesterExtensionUpdateError = !updated; @@ -422,7 +430,7 @@ export default { /> -