diff --git a/pkg/harvester/config/feature-flags.js b/pkg/harvester/config/feature-flags.js index 7b4aee6a..e20a987a 100644 --- a/pkg/harvester/config/feature-flags.js +++ b/pkg/harvester/config/feature-flags.js @@ -72,6 +72,7 @@ const FEATURE_FLAGS = { 'v1.9.0': [ 'supportFilesystem', 'disableResourcePooling', + 'expandOnlineEncryptedVolume' ], }; diff --git a/pkg/harvester/config/harvester-map.js b/pkg/harvester/config/harvester-map.js index 3813e110..95323b8c 100644 --- a/pkg/harvester/config/harvester-map.js +++ b/pkg/harvester/config/harvester-map.js @@ -88,6 +88,8 @@ export const CSI_SECRETS = { CSI_NODE_PUBLISH_SECRET_NAMESPACE: 'csi.storage.k8s.io/node-publish-secret-namespace', CSI_NODE_STAGE_SECRET_NAME: 'csi.storage.k8s.io/node-stage-secret-name', CSI_NODE_STAGE_SECRET_NAMESPACE: 'csi.storage.k8s.io/node-stage-secret-namespace', + CSI_NODE_EXPAND_SECRET_NAME: 'csi.storage.k8s.io/node-expand-secret-name', + CSI_NODE_EXPAND_SECRET_NAMESPACE: 'csi.storage.k8s.io/node-expand-secret-namespace' }; // Some harvester CRD type is not equal to model file name, define the mapping here diff --git a/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io_v1.vue b/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io_v1.vue index 6ed669ac..1d32f3dc 100644 --- a/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io_v1.vue +++ b/pkg/harvester/edit/harvesterhci.io.storage/provisioners/driver.longhorn.io_v1.vue @@ -3,8 +3,9 @@ import KeyValue from '@shell/components/form/KeyValue'; import LabeledSelect from '@shell/components/form/LabeledSelect'; import { LabeledInput } from '@components/Form/LabeledInput'; import RadioGroup from '@components/Form/Radio/RadioGroup'; +import Checkbox from '@components/Form/Checkbox/Checkbox'; import { SECRET, LONGHORN } from '@shell/config/types'; -import { _CREATE, _VIEW } from '@shell/config/query-params'; +import { _CREATE, _VIEW, _EDIT } from '@shell/config/query-params'; import { CSI_SECRETS } from '@pkg/harvester/config/harvester-map'; import { clone } from '@shell/utils/object'; import { uniq } from '@shell/utils/array'; @@ -16,7 +17,9 @@ const { CSI_NODE_PUBLISH_SECRET_NAME, CSI_NODE_PUBLISH_SECRET_NAMESPACE, CSI_NODE_STAGE_SECRET_NAME, - CSI_NODE_STAGE_SECRET_NAMESPACE + CSI_NODE_STAGE_SECRET_NAMESPACE, + CSI_NODE_EXPAND_SECRET_NAME, + CSI_NODE_EXPAND_SECRET_NAMESPACE } = CSI_SECRETS; export default { @@ -27,6 +30,7 @@ export default { LabeledSelect, LabeledInput, RadioGroup, + Checkbox, }, props: { @@ -57,7 +61,10 @@ export default { }; } - return { }; + const hasExpandSecret = !!(this.value.parameters?.[CSI_NODE_EXPAND_SECRET_NAME] && this.value.parameters?.[CSI_NODE_EXPAND_SECRET_NAMESPACE]); + const volumeExpansionCheckBoxEnabled = this.realMode === _CREATE ? true : hasExpandSecret; + + return { volumeExpansionCheckBoxEnabled }; }, computed: { @@ -98,8 +105,11 @@ export default { }, []); }, + isEdit() { + return this.realMode === _EDIT; + }, isView() { - return this.mode === _VIEW; + return this.realMode === _VIEW; }, migratableOptions() { @@ -152,6 +162,10 @@ export default { } }, + enableOnlineExpansionVolumeEncryption() { + return this.value.expandOnlineEncryptedVolumeFeatureEnabled; + }, + volumeEncryption: { set(neu) { this.value['parameters'] = { @@ -180,6 +194,11 @@ export default { set(selectedSecret) { const [namespace, name] = selectedSecret.split('/'); + const expandSecretParams = (this.enableOnlineExpansionVolumeEncryption && this.volumeExpansionCheckBoxEnabled) ? { + [CSI_NODE_EXPAND_SECRET_NAME]: name, + [CSI_NODE_EXPAND_SECRET_NAMESPACE]: namespace, + } : {}; + this.value['parameters'] = { ...this.value.parameters, [CSI_PROVISIONER_SECRET_NAME]: name, @@ -187,7 +206,8 @@ export default { [CSI_NODE_STAGE_SECRET_NAME]: name, [CSI_PROVISIONER_SECRET_NAMESPACE]: namespace, [CSI_NODE_PUBLISH_SECRET_NAMESPACE]: namespace, - [CSI_NODE_STAGE_SECRET_NAMESPACE]: namespace + [CSI_NODE_STAGE_SECRET_NAMESPACE]: namespace, + ...expandSecretParams, }; } }, @@ -240,6 +260,32 @@ export default { } }, }, + + watch: { + volumeExpansionCheckBoxEnabled(enabled) { + const currentSecret = this.secret; + + if (!currentSecret) { + return; + } + + const [namespace, name] = currentSecret.split('/'); + + if (enabled && this.enableOnlineExpansionVolumeEncryption) { + this.value['parameters'] = { + ...this.value.parameters, + [CSI_NODE_EXPAND_SECRET_NAME]: name, + [CSI_NODE_EXPAND_SECRET_NAMESPACE]: namespace, + }; + } else { + const params = { ...this.value.parameters }; + + delete params[CSI_NODE_EXPAND_SECRET_NAME]; + delete params[CSI_NODE_EXPAND_SECRET_NAMESPACE]; + this.value['parameters'] = params; + } + }, + }, };