Skip to content

Commit

Permalink
Handle spec.fileSystem.provisioned deprecation in favor of spec.provi…
Browse files Browse the repository at this point in the history
…sion in blockDevice CR

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Sep 23, 2024
1 parent a03ed75 commit bcef064
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
3 changes: 1 addition & 2 deletions pkg/harvester/detail/harvesterhci.io.host/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ export default {
const blockDevices = this.$store.getters[`${ inStore }/all`](HCI.BLOCK_DEVICE);
const provisionedBlockDevices = blockDevices.filter((d) => {
const provisioned = d?.spec?.fileSystem?.provisioned;
const isCurrentNode = d?.spec?.nodeName === this.value.id;
const isLonghornMounted = findBy(this.longhornDisks, 'name', d.metadata.name);
return provisioned && isCurrentNode && !isLonghornMounted;
return d?.isProvisioned && isCurrentNode && !isLonghornMounted;
})
.map((d) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion pkg/harvester/edit/harvesterhci.io.host/HarvesterDisk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default {
},
isProvisioned() {
return this.blockDevice?.spec?.fileSystem?.provisioned;
return this.blockDevice?.isProvisioned;
},
forceFormattedDisabled() {
Expand Down
14 changes: 6 additions & 8 deletions pkg/harvester/edit/harvesterhci.io.host/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ export default {
const blockDevices = this.$store.getters[`${ inStore }/all`](HCI.BLOCK_DEVICE);
const provisionedBlockDevices = blockDevices.filter((d) => {
const provisioned = d?.spec?.fileSystem?.provisioned;
const isCurrentNode = d?.spec?.nodeName === this.value.id;
const isLonghornMounted = findBy(this.longhornDisks, 'name', d.metadata.name);
return provisioned && isCurrentNode && !isLonghornMounted;
return d?.isProvisioned && isCurrentNode && !isLonghornMounted;
})
.map((d) => {
const corrupted = d?.status?.deviceStatus?.fileSystem?.corrupted;
Expand Down Expand Up @@ -356,10 +355,10 @@ export default {
} else if (addDisks.length !== 0 && removeDisks.length === 0) {
const updatedDisks = addDisks.filter((d) => {
const blockDevice = this.$store.getters[`${ inStore }/byId`](HCI.BLOCK_DEVICE, `${ LONGHORN_SYSTEM }/${ d.name }`);
const { provisioned, forceFormatted } = blockDevice.spec.fileSystem;
const { forceFormatted } = blockDevice.spec.fileSystem;
const { provisioner } = blockDevice.spec;
return !(provisioned && forceFormatted === d.forceFormatted && isEqual(provisioner, d.provisioner));
return !(blockDevice.isProvisioned && forceFormatted === d.forceFormatted && isEqual(provisioner, d.provisioner));
});
if (updatedDisks.length === 0) {
Expand All @@ -371,7 +370,7 @@ export default {
await Promise.all(addDisks.map((d) => {
const blockDevice = this.$store.getters[`${ inStore }/byId`](HCI.BLOCK_DEVICE, `${ LONGHORN_SYSTEM }/${ d.name }`);
blockDevice.spec.fileSystem.provisioned = true;
blockDevice.spec.provision = true;
blockDevice.spec.fileSystem.forceFormatted = d.forceFormatted;
switch (d.provisioner) {
Expand All @@ -380,7 +379,6 @@ export default {
break;
case LVM_DRIVER:
blockDevice.spec.provisioner = { lvm: { vgName: d.lvmVolumeGroup } };
blockDevice.spec.provision = true;
break;
}
Expand All @@ -390,7 +388,7 @@ export default {
await Promise.all(removeDisks.map((d) => {
const blockDevice = this.$store.getters[`${ inStore }/byId`](HCI.BLOCK_DEVICE, `${ LONGHORN_SYSTEM }/${ d.name }`);
blockDevice.spec.fileSystem.provisioned = false;
blockDevice.spec.provision = false;
return blockDevice.save();
}));
Expand Down Expand Up @@ -443,7 +441,7 @@ export default {
if ((!findBy(this.disks || [], 'name', d.metadata.name) &&
d?.spec?.nodeName === this.value.id &&
(!addedToNodeCondition || addedToNodeCondition?.status === 'False') &&
!d.spec?.fileSystem?.provisioned &&
!d?.isProvisioned &&
!isAdded) ||
isRemoved
) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/harvester/models/harvester/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ export default class HciNode extends HarvesterResource {
get unProvisionedDisks() {
const blockDevices = this.blockDevices || [];

return blockDevices.filter(d => d?.spec?.fileSystem?.provisioned && d?.status?.provisionPhase !== 'Provisioned');
return blockDevices.filter(d => d?.isProvisioned && d?.status?.provisionPhase !== 'Provisioned');
}

get diskStatusCount() {
Expand Down
7 changes: 6 additions & 1 deletion pkg/harvester/models/harvesterhci.io.blockdevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class HciBlockDevice extends HarvesterResource {
}

get isChildPartProvisioned() {
const parts = this.childParts.filter(p => p.spec?.fileSystem?.provisioned) || [];
const parts = this.childParts.filter(p => p.isProvisioned) || [];

return parts.length > 0;
}
Expand Down Expand Up @@ -59,4 +59,9 @@ export default class HciBlockDevice extends HarvesterResource {

return formatting.status === 'True';
}

get isProvisioned() {
// spec.fileSystem.provisioned is deprecated
return this.spec?.fileSystem?.provisioned || this.spec?.provision;
}
}

0 comments on commit bcef064

Please sign in to comment.