Skip to content

Commit

Permalink
Fix latest harvester version fetch to consider rancher compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Dec 5, 2024
1 parent c3eee77 commit 64c0be7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
20 changes: 10 additions & 10 deletions pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import TypeDescription from '@shell/components/TypeDescription';
import ResourceTable from '@shell/components/ResourceTable';
import Masthead from '@shell/components/ResourceList/Masthead';
import Loading from '@shell/components/Loading';
import { CAPI, HCI, MANAGEMENT, CATALOG } from '@shell/config/types';
import { CAPI, HCI, MANAGEMENT, CATALOG, UI_PLUGIN } from '@shell/config/types';

Check warning on line 11 in pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue

View workflow job for this annotation

GitHub Actions / lint

Expected a line break after this opening brace

Check warning on line 11 in pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue

View workflow job for this annotation

GitHub Actions / lint

'UI_PLUGIN' is defined but never used

Check warning on line 11 in pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue

View workflow job for this annotation

GitHub Actions / lint

Expected a line break before this closing brace
import { isHarvesterCluster } from '@shell/utils/cluster';
import { allHash } from '@shell/utils/promise';
import { NAME as APP_PRODUCT } from '@shell/config/product/apps';
import { BLANK_CLUSTER } from '@shell/store/store-types.js';
import { UI_PLUGIN_NAMESPACE } from '@shell/config/uiplugins';
import { HARVESTER_CHART, HARVESTER_COMMUNITY_REPO, HARVESTER_RANCHER_REPO } from '../types';
import {
getLatestExtensionVersion,
getHelmRepository,
ensureHelmRepository,
refreshHelmRepository,
installHelmChart,
getHelmChart,
waitForUIExtension,
waitForUIPackage,
} from '@shell/utils/ui-plugins';
Expand Down Expand Up @@ -104,7 +104,7 @@ export default {
await refreshHelmRepository(value);
if (this.harvester.extension) {
await this.setHarvesterLatestVersion(value);
await this.setHarvesterLatestVersion();
}
}
}
Expand Down Expand Up @@ -214,12 +214,12 @@ export default {
}
},
async setHarvesterLatestVersion(repository) {
async setHarvesterLatestVersion() {
try {
const chart = await getHelmChart(this.$store, repository, HARVESTER_CHART.name);
const version = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name);
if (semver.gt(chart.version, this.harvester.extension.version)) {
this.harvesterLatestVersion = chart.version;
if (semver.gt(version, this.harvester.extension.version)) {
this.harvesterLatestVersion = version;
}
} catch (error) {
this.harvesterExtensionUpdateError = true;
Expand All @@ -238,9 +238,9 @@ export default {
*/
await refreshHelmRepository(harvesterRepo);
const chart = await getHelmChart(this.$store, harvesterRepo, HARVESTER_CHART.name);
const version = await getLatestExtensionVersion(this.$store, HARVESTER_CHART.name);
await installHelmChart(harvesterRepo, { ...HARVESTER_CHART, version: chart.version }, {}, UI_PLUGIN_NAMESPACE, 'install');
await installHelmChart(harvesterRepo, { ...HARVESTER_CHART, version }, {}, UI_PLUGIN_NAMESPACE, 'install');
const extension = await waitForUIExtension(this.$store, HARVESTER_CHART.name);
Expand All @@ -266,7 +266,7 @@ export default {
if (this.harvester.missingRepository) {
harvesterRepository = await ensureHelmRepository(this.$store, HARVESTER_REPO.spec.gitRepo, HARVESTER_REPO.metadata.name, HARVESTER_REPO.spec.gitBranch);
await this.setHarvesterLatestVersion(harvesterRepository);
await this.setHarvesterLatestVersion();
}
await installHelmChart(harvesterRepository, { ...HARVESTER_CHART, version: this.harvesterLatestVersion }, {}, UI_PLUGIN_NAMESPACE, 'upgrade');
Expand Down
17 changes: 16 additions & 1 deletion shell/utils/ui-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ type Action = 'install' | 'upgrade';
export type HelmRepository = any;
export type HelmChart = any;

/**
*

Check warning on line 13 in shell/utils/ui-plugins.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
* @param store Vue store
* @param chartName The chartName
* @param opt Store options
* @returns The latest compatible version of the extension
*/
export async function getLatestExtensionVersion(store: any, chartName: string, opt = { reset: true, force: true }) {
await store.dispatch('catalog/load', opt);

const chart = store.getters['catalog/chart']({ chartName });

return chart?.versions?.[0]?.version;
}

/**
* Wait for a given UI Extension to be available
*
Expand Down Expand Up @@ -114,7 +129,7 @@ export async function installHelmChart(repo: any, chart: any, values: any = {},
const installRequest = {
charts: [chartInstall],
noHooks: false,
timeout: '600s',
timeout: '1000s',
wait: true,
namespace,
projectId: '',
Expand Down

0 comments on commit 64c0be7

Please sign in to comment.