Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
object store: more options
Browse files Browse the repository at this point in the history
- Add more options to object store creation dialogue
- Organize advanced options in "data locality" and other "advanced
  configuration" to make the dialogue easier to understand
- Propagate default number of replicas from settings

Signed-off-by: Moritz Röhrich <[email protected]>
  • Loading branch information
m-ildefons committed Sep 12, 2023
1 parent 67138b8 commit 28b824a
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 14 deletions.
85 changes: 75 additions & 10 deletions src/routes/objectStorage/CreateObjectStore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Form, Input, InputNumber, Collapse, Select, Spin } from 'antd'
import { Form, Input, InputNumber, Collapse, Select, Spin, Checkbox } from 'antd'
import { ModalBlur, SizeInput } from '../../components'

const FormItem = Form.Item
Expand Down Expand Up @@ -34,8 +34,6 @@ const modal = ({
},
item,
visible,
diskTags,
nodeTags,
tagsLoading,
onCancel,
onOk,
Expand Down Expand Up @@ -133,7 +131,7 @@ const modal = ({
</FormItem>

<Collapse>
<Panel header="Advanced Configurations" key="1">
<Panel header="Data Placement" key="1">
<FormItem label="Number of Replicas" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('numberOfReplicas', {
initialValue: item.numberOfReplicas,
Expand Down Expand Up @@ -164,19 +162,19 @@ const modal = ({
<Spin spinning={tagsLoading}>
<FormItem label="Node Tag" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('nodeSelector', {
initialValue: [],
initialValue: item.nodeTags,
})(<Select mode="tags">
{ nodeTags.map(opt => <Option key={opt.id} value={opt.id}>{opt.name}</Option>) }
{ item.nodeTags.map(opt => <Option key={opt.id} value={opt.id}>{opt.name}</Option>) }
</Select>)}
</FormItem>
</Spin>

<Spin spinning={tagsLoading}>
<FormItem label="Disk Tag" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('diskSelector', {
initialValue: [],
initialValue: item.diskTags,
})(<Select mode="tags">
{ diskTags.map(opt => <Option key={opt.id} value={opt.id}>{opt.name}</Option>) }
{ item.diskTags.map(opt => <Option key={opt.id} value={opt.id}>{opt.name}</Option>) }
</Select>)}
</FormItem>
</Spin>
Expand All @@ -200,6 +198,75 @@ const modal = ({
<Option key={'ignored'} value={'ignored'}>Ignored (Follow the global setting)</Option>
</Select>)}
</FormItem>

<FormItem label="Replica Disk Soft Anti Affinity" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('replicaDiskSoftAntiAffinity', {
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="Data Locality" hasFeedback {...formItemLayout}>
{getFieldDecorator('dataLocality', {
initialValue: item.defaultDataLocalityValue,
})(<Select>
{ item.defaultDataLocalityOption.map(value => <Option key={value} value={value}>{value}</Option>) }
</Select>)}
</FormItem>
</Panel>
</Collapse>

<Collapse>
<Panel header="Advanced Configurations" key="2">
<FormItem label="Backend Data Engine" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('backendStoreDriver', {
initialValue: 'v1',
rules: [
{
validator: (rule, value, callback) => {
if (value === 'v2' && !item.enableSPDKDataEngineValue) {
callback('SPDK data engine is not enabled')
}
callback()
},
},
],
})(<Select>
<Option key={'v1'} value={'v1'}>v1</Option>
<Option key={'v2'} value={'v2'}>v2</Option>
</Select>)}
</FormItem>

<FormItem label="Disable Revision Counter" {...formItemLayoutForAdvanced}>
{getFieldDecorator('revisionCounterDisabled', {
valuePropName: 'checked',
initialValue: item.defaultRevisionCounterValue,
})(<Checkbox></Checkbox>)}
</FormItem>

<FormItem label="Replicas Auto Balance" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('replicaAutoBalance', {
initialValue: 'ignored',
})(<Select>
<Option key={'ignored'} value={'ignored'}>Ignored (Follow the global setting)</Option>
<Option key={'disabled'} value={'disabled'}>Disabled</Option>
<Option key={'least-effort'} value={'least-effort'}>Least-Effort</Option>
<Option key={'best-effort'} value={'best-effort'}>Best-Effort</Option>
</Select>)}
</FormItem>

<FormItem label="Allow Snapshot Removal During Trim" hasFeedback {...formItemLayoutForAdvanced}>
{getFieldDecorator('unmapMarkSnapChainRemoved', {
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>
</Panel>
</Collapse>
</Form>
Expand All @@ -210,8 +277,6 @@ const modal = ({
modal.propTypes = {
form: PropTypes.object.isRequired,
item: PropTypes.object,
diskTags: PropTypes.array,
nodeTags: PropTypes.array,
visible: PropTypes.bool,
tagsLoading: PropTypes.bool,
onCancel: PropTypes.func,
Expand Down
25 changes: 21 additions & 4 deletions src/routes/objectStorage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ class ObjectStore extends React.Component {
const { data } = this.props.objectstorage
const { field, value } = queryString.parse(this.props.location.search)

const settings = this.props.setting.data
const defaultReplicaCountSetting = settings.find(s => s.id === 'default-replica-count')
const defaultDataLocalitySetting = settings.find(s => s.id === 'default-data-locality')
const defaultRevisionCounterSetting = settings.find(s => s.id === 'disable-revision-counter')
const enableSPDKDataEngineSetting = settings.find(s => s.id === 'v2-data-engine')

const defaultNumberOfReplicas = defaultReplicaCountSetting !== undefined ? parseInt(defaultReplicaCountSetting.value, 10) : 3
const defaultDataLocalityOption = defaultDataLocalitySetting?.definition?.options ? defaultDataLocalitySetting.definition.options : []
const defaultDataLocalityValue = defaultDataLocalitySetting?.value ? defaultDataLocalitySetting.value : 'disabled'
const defaultRevisionCounterValue = defaultRevisionCounterSetting?.value === 'true'
const enableSPDKDataEngineValue = enableSPDKDataEngineSetting?.value === 'true'

let objectStores = data.filter((item) => {
if (field === 'name') {
return item[field] && item[field].indexOf(value.trim()) > -1
Expand All @@ -66,11 +78,15 @@ class ObjectStore extends React.Component {
item: {
accesskey: generateRandomKey(),
secretkey: generateRandomKey(),
numberOfReplicas: 3,
numberOfReplicas: defaultNumberOfReplicas,
diskTags: [],
nodeTags: [],
defaultDataLocalityOption,
defaultDataLocalityValue,
defaultRevisionCounterValue,
enableSPDKDataEngineValue,
},
visible: this.state.createModalVisible,
diskTags: [],
nodeTags: [],
tagsLoading: false,
onCancel() {
me.setState({
Expand Down Expand Up @@ -195,8 +211,9 @@ ObjectStore.propTypes = {
loading: PropTypes.bool,
location: PropTypes.object,
dispatch: PropTypes.func,
setting: PropTypes.object,
}

export default connect(
({ objectstorage, loading }) => ({ objectstorage, loading: loading.models.objectStore })
({ objectstorage, loading, setting }) => ({ objectstorage, loading: loading.models.objectStore, setting })
)(ObjectStore)

0 comments on commit 28b824a

Please sign in to comment.