Skip to content

Commit

Permalink
fix: Fix service session affinity settings
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Jul 20, 2020
1 parent d038073 commit fd9e19c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 74 deletions.
4 changes: 3 additions & 1 deletion src/components/Base/Form/Group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,16 @@ export default class Group extends React.Component {
}

handleCheck = (e, check) => {
const { keepDataWhenUnCheck } = this.props
const { keepDataWhenUnCheck, onChange } = this.props
this.setState({ isCheck: check }, () => {
if (!keepDataWhenUnCheck && !check) {
const { formData } = this.context
if (formData && this.items.size > 0) {
this.items.forEach(item => unset(formData, item))
}
}

onChange && onChange(check)
})
}

Expand Down

This file was deleted.

39 changes: 26 additions & 13 deletions src/components/Forms/Service/AdvanceSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
*/

import React from 'react'
import { get, set } from 'lodash'
import { get, set, unset } from 'lodash'
import { MODULE_KIND_MAP } from 'utils/constants'

import { Form } from 'components/Base'
import { NumberInput } from 'components/Inputs'

import Metadata from './Metadata'
import NodeSchedule from './NodeSchedule'
import InternetAccess from './InternetAccess'
import SessionAffinity from './SessionAffinity'

export default class AdvancedSettings extends React.Component {
get namespace() {
Expand All @@ -51,13 +51,16 @@ export default class AdvancedSettings extends React.Component {
}

handleSessionAffinityChange = value => {
const { formTemplate, noWorkload } = this.props
if (!noWorkload) {
set(
formTemplate,
`Service.${this.fedPrefix}spec.sessionAffinity`,
value ? 'clusterIP' : 'None'
)
const { formTemplate } = this.props

set(
formTemplate,
`Service.${this.fedPrefix}spec.sessionAffinity`,
value ? 'ClientIP' : 'None'
)

if (!value) {
unset(formTemplate, `Service.${this.fedPrefix}spec.sessionAffinityConfig`)
}
}

Expand Down Expand Up @@ -88,12 +91,22 @@ export default class AdvancedSettings extends React.Component {
<Form.Group
label={t('Enable Sticky Session')}
desc={t('The maximum session sticky time is 10800s (3 hours).')}
onChange={this.handleSessionAffinityChange}
checkable
>
<SessionAffinity
formTemplate={formTemplate}
isFederated={isFederated}
/>
<Form.Item
label={t('Maximum Session Sticky Time (s)')}
desc={'SERVICE_SESSION_STICKY_DESC'}
>
<NumberInput
name={`Service.${
this.fedPrefix
}spec.sessionAffinityConfig.clientIP.timeoutSeconds`}
defaultValue={10800}
min={0}
max={86400}
/>
</Form.Item>
</Form.Group>
{!noWorkload && (
<Form.Group
Expand Down
4 changes: 2 additions & 2 deletions src/components/Forms/Volume/VolumeSettings/FormTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>.
*/

import { get, isNaN } from 'lodash'
import { get, isNaN, unset } from 'lodash'
import React from 'react'
import { toJS } from 'mobx'

Expand Down Expand Up @@ -146,7 +146,7 @@ export default class VolumeSettings extends React.Component {
const newStorageClass =
storageClasses.find(item => item.name === value) || {}

this.context.formData[ACCESSMODE_KEY] = undefined
unset(this.context.formData, ACCESSMODE_KEY)

this.setState({
storageClass: newStorageClass,
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,6 @@ export default {
'Specify a workload that needs to be associated with the service.',

EIP_POOL_DESC: 'Access method within the cluster (DNS)',

SERVICE_SESSION_STICKY_DESC: 'must be greater than 0 and less than 86400',
}
2 changes: 2 additions & 0 deletions src/locales/tc/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@ export default {
SERVICE_PORTS_DESC: '设置容器镜像暴露的端口以及服务端口',

EIP_POOL_DESC: '集群内部访问方式(DNS)',

SERVICE_SESSION_STICKY_DESC: '最小为 0,最大为 86400',
}
2 changes: 2 additions & 0 deletions src/locales/zh/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@ export default {
SERVICE_PORTS_DESC: '设置容器镜像暴露的端口以及服务端口',

EIP_POOL_DESC: '集群内部访问方式(DNS)',

SERVICE_SESSION_STICKY_DESC: '最小为 0,最大为 86400',
}

0 comments on commit fd9e19c

Please sign in to comment.