Skip to content

Commit

Permalink
fix(console): fix config promethus params error (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-hnny committed Nov 19, 2020
1 parent aa5da78 commit 58bb539
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export function ConfigPromethus({ route, actions }: RootProps) {
const initialConfig: LocalConfigType = {
resources: {
limits: {
cpu: 0,
memory: 0
cpu: 4,
memory: 8096
},
requests: {
cpu: 0,
memory: 0
cpu: 0.1,
memory: 128
}
},
runOnMaster: false,
Expand Down Expand Up @@ -58,34 +58,34 @@ export function ConfigPromethus({ route, actions }: RootProps) {
>
<Form.Item label="Promethus CPU限制">
<Space>
<Form.Item noStyle name={['resources', 'limits', 'cpu']} rules={[{ type: 'number' }]}>
<InputNumber style={inputStyle} />
<Form.Item noStyle name={['resources', 'limits', 'cpu']} rules={[{ type: 'number', min: 0 }]}>
<InputNumber style={inputStyle} min={0} />
</Form.Item>
</Space>
</Form.Item>
<Form.Item label="Promethus CPU预留">
<Space>
<Form.Item noStyle name={['resources', 'requests', 'cpu']} rules={[{ type: 'number' }]}>
<InputNumber style={inputStyle} />
<Form.Item noStyle name={['resources', 'requests', 'cpu']} rules={[{ type: 'number', min: 0 }]}>
<InputNumber style={inputStyle} min={0} />
</Form.Item>
</Space>
</Form.Item>
<Form.Item label="Promethus 内存限制">
<Space>
<Form.Item noStyle name={['resources', 'limits', 'memory']} rules={[{ type: 'number' }]}>
<InputNumber style={inputStyle} />
<Form.Item noStyle name={['resources', 'limits', 'memory']} rules={[{ type: 'number', min: 4 }]}>
<InputNumber style={inputStyle} min={4} />
</Form.Item>
Gi
Mi
</Space>
</Form.Item>
<Form.Item label="Promethus 内存预留">
<Space>
<Form.Item noStyle name={['resources', 'requests', 'memory']} rules={[{ type: 'number' }]}>
<InputNumber style={inputStyle} />
<Form.Item noStyle name={['resources', 'requests', 'memory']} rules={[{ type: 'number', min: 4 }]}>
<InputNumber style={inputStyle} min={4} />
</Form.Item>
Gi
Mi
</Space>
</Form.Item>
<Form.Item label="Master节点上运行">
Expand All @@ -101,8 +101,8 @@ export function ConfigPromethus({ route, actions }: RootProps) {
</Form.Item>
<Form.Item label="重复告警的间隔">
<Space>
<Form.Item noStyle name={['alertRepeatInterval']} rules={[{ type: 'number' }]}>
<InputNumber style={inputStyle} />
<Form.Item noStyle name={['alertRepeatInterval']} rules={[{ type: 'number', min: 0 }]}>
<InputNumber style={inputStyle} min={0} />
</Form.Item>
m
</Space>
Expand Down
12 changes: 11 additions & 1 deletion web/console/src/webApi/promethus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ export const enablePromethus = (params: EnablePromethusParams): Promise<EnablePr
withNPD: false,
...{
...params,
alertRepeatInterval: params.alertRepeatInterval + 'm'
alertRepeatInterval: params.alertRepeatInterval + 'm',
resources: {
limits: {
cpu: params.resources.limits.cpu,
memory: params.resources.limits.memory + 'Mi'
},
requests: {
cpu: params.resources.requests.cpu,
memory: params.resources.requests.memory + 'Mi'
}
}
}
}
});
Expand Down

0 comments on commit 58bb539

Please sign in to comment.