diff --git a/pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue b/pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue index d4cc806b741..17d1fd84d3b 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; @@ -62,6 +62,7 @@ export default { this.hciClusters = hash.hciClusters; this.mgmtClusters = hash.mgmtClusters; + this.kubeVersion = hash.mgmtClusters.find((c) => c.id === 'local')?.kubernetesVersionBase || ''; this.harvesterRepository = await this.getHarvesterRepository(); }, @@ -78,6 +79,8 @@ export default { realSchema: this.$store.getters['management/schemaFor'](CAPI.RANCHER_CLUSTER), hciClusters: [], mgmtClusters: [], + rancherVersion: getVersionData()?.Version || '', + kubeVersion: null, harvesterRepository: null, harvesterInstallVersion: true, harvesterUpdateVersion: null, @@ -218,7 +221,7 @@ export default { 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.harvesterUpdateVersion = version; @@ -240,7 +243,7 @@ export default { */ await refreshHelmRepository(this.$store, HARVESTER_REPO.spec.gitRepo, HARVESTER_REPO.spec.gitBranch); - this.harvesterInstallVersion = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name); + this.harvesterInstallVersion = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name, this.rancherVersion, this.kubeVersion); if (!this.harvesterInstallVersion) { btnCb(false); diff --git a/shell/utils/uiplugins.ts b/shell/utils/uiplugins.ts index 3248c1226ba..c748e2260bd 100644 --- a/shell/utils/uiplugins.ts +++ b/shell/utils/uiplugins.ts @@ -1,6 +1,6 @@ import { CATALOG as CATALOG_ANNOTATIONS } from '@shell/config/labels-annotations'; import { CATALOG } from '@shell/config/types'; -import { UI_PLUGIN_BASE_URL } from '@shell/config/uiplugins'; +import { UI_PLUGIN_BASE_URL, isSupportedChartVersion } from '@shell/config/uiplugins'; const MAX_RETRIES = 10; const RETRY_WAIT = 2500; @@ -13,15 +13,29 @@ export type HelmChart = any; * * @param store Vue store * @param chartName The chartName + * @param rancherVersion Rancher version + * @param kubeVersion K8s version * @param opt Store options - * @returns The latest compatible version of the extension + * @returns The latest compatible version of the extension; return null If there are no compatible versions. */ -export async function getLatestExtensionVersion(store: any, chartName: string, opt = { reset: true, force: true }) { +export async function getLatestExtensionVersion( + store: any, + chartName: string, + rancherVersion: string, + kubeVersion: string, + opt = { reset: true, force: true }, +) { await store.dispatch('catalog/load', opt); const chart = store.getters['catalog/chart']({ chartName }); - return chart?.versions?.[0]?.version; + const versions = chart?.versions || []; + + const compatibleVersions = versions.filter((version: any) => isSupportedChartVersion({ + version, rancherVersion, kubeVersion + })); + + return compatibleVersions[0]?.version; } /**