Skip to content

Commit

Permalink
Merge pull request #1190 from harvester/mergify/bp/release-harvester-…
Browse files Browse the repository at this point in the history
…v1.4/pr-1189

Remove "Take Snapshot" action for Longhorn V2 Storage Classes (backport #1189)
  • Loading branch information
torchiaf authored Oct 8, 2024
2 parents 9da62be + 35bd736 commit 3662364
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 25 deletions.
3 changes: 1 addition & 2 deletions pkg/harvester/edit/harvesterhci.io.volume.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations
import { STATE, NAME, AGE, NAMESPACE } from '@shell/config/table-headers';
import { LVM_DRIVER } from '../models/harvester/storage.k8s.io.storageclass';
import { DATA_ENGINE_V2 } from './harvesterhci.io.storage/index.vue';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
export default {
name: 'HarvesterVolume',
Expand Down Expand Up @@ -225,7 +224,7 @@ export default {
},
isLonghornV2() {
return this.value.storageClass?.provisioner === LONGHORN_DRIVER && this.value.storageClass?.longhornVersion === DATA_ENGINE_V2;
return this.value.storageClass?.isLonghornV2;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { SOURCE_TYPE } from '../../../config/harvester-map';
import { _VIEW, _EDIT, _CREATE } from '@shell/config/query-params';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../config/harvester';
import { PLUGIN_DEVELOPER, DEV } from '@shell/store/prefs';
import { DATA_ENGINE_V2 } from '../../../edit/harvesterhci.io.storage/index.vue';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
export default {
components: {
Expand Down Expand Up @@ -260,7 +258,7 @@ export default {
},
isLonghornV2(volume) {
return volume?.pvc?.storageClass?.provisioner === LONGHORN_DRIVER && volume?.pvc?.storageClass?.longhornVersion === DATA_ENGINE_V2;
return volume?.pvc?.storageClass?.isLonghornV2;
}
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { formatSi, parseSi } from '@shell/utils/units';
import { VOLUME_TYPE, InterfaceOption } from '../../../../config/harvester-map';
import { _VIEW } from '@shell/config/query-params';
import { ucFirst } from '@shell/utils/string';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
import { DATA_ENGINE_V2 } from '../../../harvesterhci.io.storage/index.vue';
export default {
name: 'HarvesterEditVMImage',
Expand Down Expand Up @@ -117,7 +115,7 @@ export default {
},
isLonghornV2() {
return this.value.pvc?.storageClass?.provisioner === LONGHORN_DRIVER && this.value.pvc?.storageClass?.longhornVersion === DATA_ENGINE_V2;
return this.value.pvc?.storageClass?.isLonghornV2;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import LabelValue from '@shell/components/LabelValue';
import { ucFirst } from '@shell/utils/string';
import { LVM_DRIVER } from '../../../../models/harvester/storage.k8s.io.storageclass';
import { DATA_ENGINE_V2 } from '../../../../edit/harvesterhci.io.storage/index.vue';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
export default {
name: 'HarvesterEditVolume',
Expand Down Expand Up @@ -103,7 +102,7 @@ export default {
},
isLonghornV2() {
return this.value.pvc?.storageClass?.provisioner === LONGHORN_DRIVER && this.value.pvc?.storageClass?.longhornVersion === DATA_ENGINE_V2;
return this.value.pvc?.storageClass?.isLonghornV2;
}
},
Expand Down
5 changes: 4 additions & 1 deletion pkg/harvester/list/kubevirt.io.virtualmachine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import ConsoleBar from '../components/VMConsoleBar';
import ResourceTable from '@shell/components/ResourceTable';
import HarvesterVmState from '../formatters/HarvesterVmState';
import { PVC, PV, NODE, POD } from '@shell/config/types';
import {
PVC, PV, NODE, POD, STORAGE_CLASS
} from '@shell/config/types';
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
import { HCI } from '../types';
import { allHash } from '@shell/utils/promise';
Expand Down Expand Up @@ -78,6 +80,7 @@ export default {
images: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.IMAGE }),
restore: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.RESTORE }),
backups: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.BACKUP }),
storage: this.$store.dispatch(`${ inStore }/findAll`, { type: STORAGE_CLASS }),
};
if (this.$store.getters[`${ inStore }/schemaFor`](HCI.RESOURCE_QUOTA)) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/harvester/models/harvester/persistentvolumeclaim.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export default class HciPv extends HarvesterResource {
icon: 'icon icon-copy',
label: this.t('harvester.action.exportImage')
},
{
action: 'snapshot',
enabled: this.hasAction('snapshot'),
icon: 'icon icon-backup',
label: this.t('harvester.action.snapshot'),
},
...out
];
}
Expand All @@ -60,12 +66,6 @@ export default class HciPv extends HarvesterResource {
icon: 'icon icon-backup',
label: this.t('harvester.action.cancelExpand')
},
{
action: 'snapshot',
enabled: this.hasAction('snapshot'),
icon: 'icon icon-backup',
label: this.t('harvester.action.snapshot'),
},
...out
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HCI } from '../../types';
import StorageClass from '@shell/models/storage.k8s.io.storageclass';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../config/harvester';
import { LONGHORN_DRIVER } from '@shell/models/persistentvolume';
import { DATA_ENGINE_V1 } from '../../edit/harvesterhci.io.storage/index.vue';
import { DATA_ENGINE_V1, DATA_ENGINE_V2 } from '../../edit/harvesterhci.io.storage/index.vue';

export const LVM_DRIVER = 'lvm.driver.harvesterhci.io';

Expand Down Expand Up @@ -57,4 +57,8 @@ export default class HciStorageClass extends StorageClass {

return this.$rootGetters['i18n/t'](key);
}

get isLonghornV2() {
return this.provisioner === LONGHORN_DRIVER && this.longhornVersion === DATA_ENGINE_V2;
}
}
20 changes: 13 additions & 7 deletions pkg/harvester/models/kubevirt.io.virtualmachine.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default class VirtVm extends HarvesterResource {
},
{
action: 'takeVMSnapshot',
enabled: !!this.actions?.backup,
enabled: !!this.actions?.backup && !this.longhornV2Volumes.length,
icon: 'icon icon-snapshot',
label: this.t('harvester.action.vmSnapshot')
},
Expand Down Expand Up @@ -595,16 +595,22 @@ export default class VirtVm extends HarvesterResource {
return vmis.find(VMI => VMI.id === this.id);
}

get encryptedVolumeType() {
const inStore = this.productInStore;
const pvcs = this.$rootGetters[`${ inStore }/all`](PVC);
get volumes() {
const pvcs = this.$rootGetters[`${ this.productInStore }/all`](PVC);

const volumeClaimNames = this.spec.template.spec.volumes?.map(v => v.persistentVolumeClaim?.claimName).filter(v => !!v) || [];
const volumes = pvcs.filter(pvc => volumeClaimNames.includes(pvc.metadata.name));

if (volumes.every(vol => vol.isEncrypted)) {
return pvcs.filter(pvc => volumeClaimNames.includes(pvc.metadata.name));
}

get longhornV2Volumes() {
return this.volumes.filter(volume => volume.storageClass.isLonghornV2);
}

get encryptedVolumeType() {
if (this.volumes.every(vol => vol.isEncrypted)) {
return 'all';
} else if (volumes.some(vol => vol.isEncrypted)) {
} else if (this.volumes.some(vol => vol.isEncrypted)) {
return 'partial';
} else {
return 'none';
Expand Down

0 comments on commit 3662364

Please sign in to comment.