Skip to content

Commit

Permalink
Add FreezeFSForSnapshot support
Browse files Browse the repository at this point in the history
* Add FreezeFSForSnapshot support
* Fix Makefile variable typo
* Change wording from overwrite to override
* Reword file system to filesystem
* Minor improvements based on review

Longhorn 2187

Signed-off-by: Eric Weber <eric.weber@suse.com>
  • Loading branch information
ejweber authored Jun 18, 2024
1 parent ea50c84 commit 1439aa7
Show file tree
Hide file tree
Showing 15 changed files with 336 additions and 4 deletions.
34 changes: 34 additions & 0 deletions src/models/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export default {
bulkUnmapMarkSnapChainRemovedModalVisible: false,
updateSnapshotDataIntegrityModalVisible: false,
updateBulkSnapshotDataIntegrityModalVisible: false,
updateFreezeFilesystemForSnapshotModalVisible: false,
updateBulkFreezeFilesystemForSnapshotModalVisible: false,
isDetachBulk: false,
changeVolumeActivate: '',
defaultPvOrPvcName: '',
Expand Down Expand Up @@ -102,6 +104,8 @@ export default {
updateSnapshotDataIntegrityModalKey: Math.random(),
updateBulkSnapshotDataIntegrityModalKey: Math.random(),
updateReplicaSoftAntiAffinityModalKey: Math.random(),
updateFreezeFilesystemForSnapshotModalKey: Math.random(),
updateBulkFreezeFilesystemForSnapshotModalKey: Math.random(),
socketStatus: 'closed',
sorter: getSorter('volumeList.sorter'),
customColumnList: window.__column__, // eslint-disable-line no-underscore-dangle
Expand Down Expand Up @@ -322,6 +326,24 @@ export default {
yield call(execAction, payload.url, payload.params)
yield put({ type: 'query' })
},
*updateFreezeFilesystemForSnapshot({
payload,
}, { call, put }) {
yield put({ type: 'hideUpdateFreezeFilesystemForSnapshotModal' })
yield call(execAction, payload.url, payload.params)
yield put({ type: 'query' })
},
*updateBulkFreezeFilesystemForSnapshot({
payload,
}, { call, put }) {
yield put({ type: 'hideUpdateBulkFreezeFilesystemForSnapshotModal' })
if (payload?.urls?.length > 0) {
for (let i = 0; i < payload.urls.length; i++) {
yield call(execAction, payload.urls[i], payload.params)
}
}
yield put({ type: 'query' })
},
*accessModeUpdate({
payload,
}, { call, put }) {
Expand Down Expand Up @@ -802,6 +824,18 @@ export default {
showUpdateBulkSnapshotDataIntegrityModal(state, action) {
return { ...state, ...action.payload, updateBulkSnapshotDataIntegrityModalVisible: true, updateBulkSnapshotDataIntegrityModalKey: Math.random() }
},
showUpdateFreezeFilesystemForSnapshotModal(state, action) {
return { ...state, ...action.payload, updateFreezeFilesystemForSnapshotModalVisible: true, updateFreezeFilesystemForSnapshotModalKey: Math.random() }
},
hideUpdateFreezeFilesystemForSnapshotModal(state, action) {
return { ...state, ...action.payload, updateFreezeFilesystemForSnapshotModalVisible: false, updateFreezeFilesystemForSnapshotModalKey: Math.random() }
},
showUpdateBulkFreezeFilesystemForSnapshotModal(state, action) {
return { ...state, ...action.payload, updateBulkFreezeFilesystemForSnapshotModalVisible: true, updateBulkFreezeFilesystemForSnapshotModalKey: Math.random() }
},
hideUpdateBulkFreezeFilesystemForSnapshotModal(state, action) {
return { ...state, ...action.payload, updateBulkFreezeFilesystemForSnapshotModalVisible: false, updateBulkFreezeFilesystemForSnapshotModalKey: Math.random() }
},
showUpdateAccessMode(state, action) {
return { ...state, ...action.payload, updateAccessModeModalVisible: true, updateAccessModeModalKey: Math.random() }
},
Expand Down
9 changes: 9 additions & 0 deletions src/routes/volume/CreateVolume.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ const modal = ({
<Option key={'ignored'} value={'ignored'}>Ignored (Follow the global setting)</Option>
</Select>)}
</FormItem>}
<FormItem label="Freeze Filesystem For Snapshot" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('freezeFilesystemForSnapshot', {
initialValue: 'ignored',
})(<Select>
<Option key={'enabled'} value={'enabled'}>Enabled</Option>
<Option key={'disabled'} value={'disabled'}>Disabled</Option>
<Option key={'ignored'} value={'ignored'}>Ignored (Follow the global setting)</Option>
</Select>)}
</FormItem>
<FormItem label="Disable Revision Counter" {...formItemLayoutForAdvanced}>
{getFieldDecorator('revisionCounterDisabled', {
valuePropName: 'checked',
Expand Down
82 changes: 82 additions & 0 deletions src/routes/volume/UpdateBulkFreezeFilesystemForSnapshotModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Form, Select, Alert } from 'antd'
import { ModalBlur } from '../../components'
const FormItem = Form.Item
const { Option } = Select

const formItemLayout = {
labelCol: {
span: 24,
},
wrapperCol: {
span: 24,
},
}

const modal = ({
items,
option,
visible,
onCancel,
onOk,
form: {
getFieldDecorator,
validateFields,
getFieldsValue,
},
}) => {
function handleOk() {
validateFields((errors) => {
if (errors) {
return
}
const data = {
...getFieldsValue(),
}
const urls = items.map((item) => item?.actions?.updateFreezeFilesystemForSnapshot)

onOk(data, urls)
})
}

const modalOpts = {
title: 'Update Freeze Filesystem For Snapshot',
visible,
onCancel,
width: 600,
onOk: handleOk,
}
if (!items || items?.length === 0) {
return null
}
return (
<ModalBlur {...modalOpts}>
<Form layout="horizontal">
<FormItem label="Option" {...formItemLayout}>
{getFieldDecorator('freezeFilesystemForSnapshot', {
initialValue: 'ignored',
})(<Select>
{ option.map(ele => <Option key={ele.key} value={ele.value}>{ele.key}</Option>) }
</Select>)}
<Alert
style={{ marginTop: 10 }}
message="This action may override the global setting “Freeze Filesystem For Snapshot”"
type="warning"
/>
</FormItem>
</Form>
</ModalBlur>
)
}

modal.propTypes = {
form: PropTypes.object.isRequired,
visible: PropTypes.bool,
option: PropTypes.array,
onCancel: PropTypes.func,
items: PropTypes.array,
onOk: PropTypes.func,
}

export default Form.create()(modal)
2 changes: 1 addition & 1 deletion src/routes/volume/UpdateBulkSnapshotDataIntegrityModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const modal = ({
</Select>)}
<Alert
style={{ marginTop: 10 }}
message="This action may overwrite the global setting “Snapshot Data Integrity”"
message="This action may override the global setting “Snapshot Data Integrity”"
type="warning"
/>
</FormItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const modal = ({
</Select>)}
<Alert
style={{ marginTop: 10 }}
message="This action may overwrite the global setting “Remove Snapshots During Filesystem Trim”"
message="This action may override the global setting “Remove Snapshots During Filesystem Trim”"
type="warning"
/>
</FormItem>
Expand Down
82 changes: 82 additions & 0 deletions src/routes/volume/UpdateFreezeFilesystemForSnapshotModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Form, Select, Alert } from 'antd'
import { ModalBlur } from '../../components'
const FormItem = Form.Item
const { Option } = Select

const formItemLayout = {
labelCol: {
span: 24,
},
wrapperCol: {
span: 24,
},
}

const modal = ({
item,
option,
visible,
onCancel,
onOk,
form: {
getFieldDecorator,
validateFields,
getFieldsValue,
},
}) => {
function handleOk() {
validateFields((errors) => {
if (errors) {
return
}
const data = {
...getFieldsValue(),
}
let url = item?.actions?.updateFreezeFilesystemForSnapshot

onOk(data, url)
})
}

const modalOpts = {
title: 'Update Freeze Filesystem For Snapshot',
visible,
onCancel,
width: 600,
onOk: handleOk,
}
if (!item) {
return null
}
return (
<ModalBlur {...modalOpts}>
<Form layout="horizontal">
<FormItem label="Option" {...formItemLayout}>
{getFieldDecorator('freezeFilesystemForSnapshot', {
initialValue: item?.freezeFilesystemForSnapshot,
})(<Select>
{ option.map(ele => <Option key={ele.key} value={ele.value}>{ele.key}</Option>) }
</Select>)}
<Alert
style={{ marginTop: 10 }}
message="This action may override the global setting “Freeze Filesystem For Snapshot”"
type="warning"
/>
</FormItem>
</Form>
</ModalBlur>
)
}

modal.propTypes = {
form: PropTypes.object.isRequired,
visible: PropTypes.bool,
option: PropTypes.array,
onCancel: PropTypes.func,
item: PropTypes.object,
onOk: PropTypes.func,
}

export default Form.create()(modal)
2 changes: 1 addition & 1 deletion src/routes/volume/UpdateSnapshotDataIntegrityModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const modal = ({
</Select>)}
<Alert
style={{ marginTop: 10 }}
message="This action may overwrite the global setting “Snapshot Data Integrity”"
message="This action may override the global setting “Snapshot Data Integrity”"
type="warning"
/>
</FormItem>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/volume/UpdateUnmapMarkSnapChainRemovedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const modal = ({
</Select>)}
<Alert
style={{ marginTop: 10 }}
message="This action may overwrite the global setting “Remove Snapshots During Filesystem Trim”"
message="This action may override the global setting “Remove Snapshots During Filesystem Trim”"
type="warning"
/>
</FormItem>
Expand Down
6 changes: 6 additions & 0 deletions src/routes/volume/VolumeActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function actions({
showUpdateReplicaZoneSoftAntiAffinityModal,
showUpdateReplicaDiskSoftAntiAffinityModal,
showOfflineReplicaRebuildingModal,
showUpdateFreezeFilesystemForSnapshotModal,
commandKeyDown,
}) {
const deleteWranElement = (record) => {
Expand Down Expand Up @@ -152,6 +153,9 @@ function actions({
case 'updateOfflineReplicaRebuilding':
showOfflineReplicaRebuildingModal(record)
break
case 'updateFreezeFilesystemForSnapshot':
showUpdateFreezeFilesystemForSnapshotModal(record)
break
case 'trimFilesystem':
confirm({
title: 'Are you sure you want to trim the filesystem?',
Expand Down Expand Up @@ -225,6 +229,7 @@ function actions({
{ key: 'updateSnapshotMaxSize', name: 'Update Snapshot Max Size', disabled: false },
{ key: 'updateReplicaDiskSoftAntiAffinity', name: 'Update Replica Disk Soft Anti Affinity', disabled: false },
{ key: 'updateOfflineReplicaRebuilding', name: 'Update Offline Replica Rebuilding', disabled: false || selected.dataEngine !== 'v2' },
{ key: 'updateFreezeFilesystemForSnapshot', name: 'Update Freeze Filesystem For Snapshot', disabled: false },
]
const availableActions = [{ key: 'backups', name: 'Backups', disabled: selected.standby || isRestoring(selected) }, { key: 'delete', name: 'Delete' }]

Expand Down Expand Up @@ -281,6 +286,7 @@ actions.propTypes = {
trimFilesystem: PropTypes.func,
showUpdateSnapshotDataIntegrityModal: PropTypes.func,
engineUpgradePerNodeLimit: PropTypes.object,
showUpdateFreezeFilesystemForSnapshotModal: PropTypes.func,
}

export default actions
6 changes: 6 additions & 0 deletions src/routes/volume/VolumeBulkActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function bulkActions({
showUpdateReplicaZoneSoftAntiAffinityModal,
showUpdateReplicaDiskSoftAntiAffinityModal,
showOfflineReplicaRebuildingModal,
showUpdateBulkFreezeFilesystemForSnapshotModal,
}) {
const deleteWranElement = (rows) => {
let workloadResources = []
Expand Down Expand Up @@ -136,6 +137,9 @@ function bulkActions({
case 'updateOfflineReplicaRebuilding':
showOfflineReplicaRebuildingModal(selectedRows)
break
case 'updateFreezeFilesystemForSnapshot':
showUpdateBulkFreezeFilesystemForSnapshotModal(selectedRows)
break
case 'trimFilesystem':
confirm({
title: `Are you sure you want to trim (${selectedRows.map(item => item.name).join(', ')}) Filesystem ?`,
Expand Down Expand Up @@ -203,6 +207,7 @@ function bulkActions({
{ key: 'updateReplicaDiskSoftAntiAffinity', name: 'Update Replica Disk Soft Anti Affinity', disabled() { return selectedRows.length === 0 } },
{ key: 'updateOfflineReplicaRebuilding', name: 'Update Offline Replica Rebuilding', disabled() { return selectedRows.length === 0 || selectedRows.some((item) => item.dataEngine !== 'v2') } },
{ key: 'trimFilesystem', name: 'Trim Filesystem', disabled() { return selectedRows.length === 0 || notAttached() } },
{ key: 'updateFreezeFilesystemForSnapshot', name: 'Update Freeze Filesystem For Snapshot', disabled() { return selectedRows.length === 0 } },
]

const menu = (<Menu>
Expand Down Expand Up @@ -258,6 +263,7 @@ bulkActions.propTypes = {
commandKeyDown: PropTypes.bool,
showBulkUnmapMarkSnapChainRemovedModal: PropTypes.func,
trimBulkFilesystem: PropTypes.func,
showUpdateBulkFreezeFilesystemForSnapshotModal: PropTypes.func,
}

export default bulkActions
3 changes: 3 additions & 0 deletions src/routes/volume/VolumeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function list({
showUpdateReplicaZoneSoftAntiAffinityModal,
showUpdateReplicaDiskSoftAntiAffinityModal,
showOfflineReplicaRebuildingModal,
showUpdateFreezeFilesystemForSnapshotModal,
onRowClick = f => f,
}) {
const volumeActionsProps = {
Expand Down Expand Up @@ -96,6 +97,7 @@ function list({
showUpdateReplicaZoneSoftAntiAffinityModal,
showUpdateReplicaDiskSoftAntiAffinityModal,
showOfflineReplicaRebuildingModal,
showUpdateFreezeFilesystemForSnapshotModal,
onRowClick,
}
/**
Expand Down Expand Up @@ -587,6 +589,7 @@ list.propTypes = {
showUpdateSnapshotDataIntegrityModal: PropTypes.func,
replicaSoftAntiAffinitySettingValue: PropTypes.bool,
engineUpgradePerNodeLimit: PropTypes.object,
showUpdateFreezeFilesystemForSnapshotModal: PropTypes.func,
}

export default list
4 changes: 4 additions & 0 deletions src/routes/volume/detail/VolumeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ function VolumeInfo({ selectedVolume, snapshotModalState, engineImages, hosts, c
<span className={styles.label}> Replica Disk Soft Anti Affinity:</span>
{selectedVolume?.replicaDiskSoftAntiAffinity}
</div>
<div className={styles.row}>
<span className={styles.label}> Freeze Filesystem For Snapshot:</span>
{addGlobalSettingDescription(selectedVolume?.freezeFilesystemForSnapshot)}
</div>
{ selectedVolume.kubernetesStatus ? <div>
{ selectedVolume.kubernetesStatus.lastPVCRefAt ? <div className={styles.row}>
<span className={styles.label}> Last time bound with PVC:</span>
Expand Down
Loading

0 comments on commit 1439aa7

Please sign in to comment.