Skip to content

Commit

Permalink
Show Error message in case of Harvester extension is not compatible w…
Browse files Browse the repository at this point in the history
…ith Rancher

Signed-off-by: Francesco Torchia <[email protected]>
  • Loading branch information
torchiaf committed Dec 10, 2024
1 parent 80277df commit 6f10032
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
4 changes: 4 additions & 0 deletions pkg/harvester-manager/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 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"
Expand Down
33 changes: 24 additions & 9 deletions pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default {
hciClusters: [],
mgmtClusters: [],
harvesterRepository: null,
harvesterInstallVersion: true,
harvesterUpdateVersion: null,
harvesterRepositoryError: false,
harvesterExtensionInstallError: false,
Expand Down Expand Up @@ -116,14 +117,15 @@ export default {
harvester() {
const extension = this.uiplugins?.find((c) => c.name === HARVESTER_CHART.name);
const missingRepository = !!extension && !this.harvesterRepository;
const action = async(btnCb) => {
const action = `${ !extension ? 'install' : 'update' }HarvesterExtension`;
await this[action](btnCb);
};
const hasErrors = this.harvesterRepositoryError ||
const hasErrors = !this.harvesterInstallVersion ||
this.harvesterRepositoryError ||
this.harvesterExtensionInstallError ||
this.harvesterExtensionUpdateError;
Expand All @@ -133,7 +135,9 @@ export default {
].reduce((acc, label) => {
let action = '';
if (hasErrors) {
if (!this.harvesterInstallVersion) {
action = 'missingVersion';
} else if (hasErrors) {
action = 'error';
} else if (missingRepository) {
action = 'missingRepo';
Expand All @@ -158,7 +162,7 @@ export default {
return {
extension,
missingRepository,
toInstall: !extension,
toInstall: !extension,
toUpdate: missingRepository || !!this.harvesterUpdateVersion,
action,
panelLabel,
Expand Down Expand Up @@ -236,15 +240,21 @@ 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);
if (!this.harvesterInstallVersion) {
btnCb(false);
return;
}
await installHelmChart(harvesterRepo, { ...HARVESTER_CHART, version }, {}, UI_PLUGIN_NAMESPACE, 'install');
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 = !installed;
Expand All @@ -265,14 +275,19 @@ export default {
await this.setHarvesterUpdateVersion();
}
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.harvesterUpdateVersion });
} catch (error) {
}
}
this.harvesterExtensionUpdateError = !updated;
Expand Down Expand Up @@ -413,7 +428,7 @@ export default {
/>
</div>
</div>
<template v-if="isAdmin">
<template v-if="isAdmin && harvesterInstallVersion">
<div
v-if="harvester.hasErrors"
class="extension-info"
Expand Down

0 comments on commit 6f10032

Please sign in to comment.