Latest changes from Harvester master - e6796a6fc0cffe03f47f6081c09469d59b97faf9

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia
2024-11-12 11:50:33 +01:00
parent 78ca1e2f49
commit 9a7ca75b74
10 changed files with 93 additions and 63 deletions
@@ -9,11 +9,13 @@ import { colorForState } from '@shell/plugins/dashboard-store/resource-class';
import { HCI, VOLUME_SNAPSHOT } from '../../types';
import HarvesterResource from '../harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../config/harvester';
import { DATA_ENGINE_V2 } from '../../edit/harvesterhci.io.storage/index.vue';
import { LVM_DRIVER } from './storage.k8s.io.storageclass';
const DEGRADED_ERRORS = ['replica scheduling failed', 'precheck new replica failed'];
export const DATA_ENGINE_V1 = 'v1';
export const DATA_ENGINE_V2 = 'v2';
export default class HciPv extends HarvesterResource {
applyDefaults(_, realMode) {
const accessModes = realMode === _CLONE ? this.spec.accessModes : [];
@@ -34,7 +36,7 @@ export default class HciPv extends HarvesterResource {
let out = super._availableActions;
// Longhorn V2 provisioner do not support volume clone feature yet
if (this.storageClass.longhornVersion === DATA_ENGINE_V2) {
if (this.isLonghornV2) {
out = out.filter((action) => action.action !== 'goToClone');
} else {
const clone = out.find((action) => action.action === 'goToClone');
@@ -44,7 +46,7 @@ export default class HciPv extends HarvesterResource {
}
}
if (this.storageClass.provisioner !== LONGHORN_DRIVER || this.storageClass.longhornVersion !== DATA_ENGINE_V2) {
if (!this.isLonghorn || !this.isLonghornV2) {
out = [
{
action: 'exportImage',
@@ -303,6 +305,26 @@ export default class HciPv extends HarvesterResource {
return this.$rootGetters['harvester/all'](PV).find((pv) => pv.metadata?.name === this.spec?.volumeName);
}
get volumeProvider() {
return this.relatedPV?.spec.csi?.driver;
}
get dataEngine() {
return this.relatedPV?.spec.csi?.volumeAttributes?.dataEngine;
}
get isLvm() {
return this.volumeProvider === LVM_DRIVER;
}
get isLonghorn() {
return this.volumeProvider === LONGHORN_DRIVER;
}
get isLonghornV2() {
return this.dataEngine === DATA_ENGINE_V2;
}
get resourceExternalLink() {
const host = window.location.host;
const { params } = this.currentRoute();
@@ -3,7 +3,7 @@ import StorageClass from '@shell/models/storage.k8s.io.storageclass';
import { HCI } from '../../types';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../config/harvester';
import { LONGHORN_DRIVER } from '@shell/config/types';
import { DATA_ENGINE_V1, DATA_ENGINE_V2 } from '../../edit/harvesterhci.io.storage/index.vue';
import { DATA_ENGINE_V1, DATA_ENGINE_V2 } from '../../models/harvester/persistentvolumeclaim';
export const LVM_DRIVER = 'lvm.driver.harvesterhci.io';
@@ -55,7 +55,7 @@ export default class HciStorageClass extends StorageClass {
key = `harvester.storage.storageClass.lvm.label`;
}
return this.$rootGetters['i18n/t'](key);
return key ? this.$rootGetters['i18n/t'](key) : null;
}
get isLonghornV2() {