Skip to content

Commit

Permalink
Limit VolumeBindingMode to WaitForFirstConsumer for LVM StorageClasses
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 Sep 26, 2024
1 parent 17d798f commit 47d3511
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pkg/harvester/edit/harvesterhci.io.storage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const DATA_ENGINE_V2 = 'v2';
export const LVM_TOPOLOGY_LABEL = 'topology.lvm.csi/node';
const VOLUME_BINDING_MODE_IMMEDIATE = 'Immediate';
const VOLUME_BINDING_MODE_WAIT = 'WaitForFirstConsumer';
export default {
name: 'HarvesterStorage',
Expand Down Expand Up @@ -69,26 +72,29 @@ export default {
const volumeBindingModeOptions = [
{
label: this.t('storageClass.customize.volumeBindingMode.now'),
value: 'Immediate'
value: VOLUME_BINDING_MODE_IMMEDIATE
},
{
label: this.t('harvester.storage.customize.volumeBindingMode.later'),
value: 'WaitForFirstConsumer'
value: VOLUME_BINDING_MODE_WAIT
}
];
const allowedTopologies = clone(this.value.allowedTopologies?.[0]?.matchLabelExpressions || []).filter(t => t.key !== LVM_TOPOLOGY_LABEL);
this.$set(this.value, 'parameters', this.value.parameters || {});
this.$set(this.value, 'provisioner', this.value.provisioner || LONGHORN_DRIVER);
this.$set(this.value, 'allowVolumeExpansion', this.value.allowVolumeExpansion || allowVolumeExpansionOptions[0].value);
this.$set(this.value, 'reclaimPolicy', this.value.reclaimPolicy || reclaimPolicyOptions[0].value);
if (this.value.provisioner === LONGHORN_DRIVER) {
this.$set(this.value.parameters, 'dataEngine', this.value.longhornVersion);
this.$set(this.value, 'volumeBindingMode', this.value.volumeBindingMode || VOLUME_BINDING_MODE_IMMEDIATE);
}
this.$set(this.value, 'allowVolumeExpansion', this.value.allowVolumeExpansion || allowVolumeExpansionOptions[0].value);
this.$set(this.value, 'reclaimPolicy', this.value.reclaimPolicy || reclaimPolicyOptions[0].value);
this.$set(this.value, 'volumeBindingMode', this.value.volumeBindingMode || volumeBindingModeOptions[0].value);
if (this.value.provisioner === LVM_DRIVER) {
this.$set(this.value, 'volumeBindingMode', this.value.volumeBindingMode || VOLUME_BINDING_MODE_WAIT);
}
let provisioner = `${ this.value.provisioner || LONGHORN_DRIVER }`;
Expand All @@ -97,6 +103,7 @@ export default {
}
return {
LVM_DRIVER,
reclaimPolicyOptions,
allowVolumeExpansionOptions,
volumeBindingModeOptions,
Expand Down Expand Up @@ -194,14 +201,16 @@ export default {
} else {
delete this.value.allowedTopologies;
}
}
this.$set(this.value, 'provisioner', provisioner);
this.$set(this.value, 'volumeBindingMode', VOLUME_BINDING_MODE_WAIT);
}
if (provisioner === LONGHORN_DRIVER) {
parameters = { dataEngine };
this.$set(this.value, 'volumeBindingMode', VOLUME_BINDING_MODE_IMMEDIATE);
}
this.$set(this.value, 'provisioner', provisioner);
this.$set(this.value, 'allowVolumeExpansion', this.value.provisioner === LONGHORN_DRIVER);
this.$set(this.value, 'parameters', parameters);
}
Expand Down Expand Up @@ -324,6 +333,7 @@ export default {
:label="t('storageClass.customize.volumeBindingMode.label')"
:mode="modeOverride"
:options="volumeBindingModeOptions"
:disabled="provisioner === LVM_DRIVER"
/>
</div>
</div>
Expand Down

0 comments on commit 47d3511

Please sign in to comment.