Skip to content

Commit

Permalink
Fix default and minimum value for CPU Shares
Browse files Browse the repository at this point in the history
Minimum value is 2.
The default value is 1024 (or value set up in cgroups).
Let's not assume any value. Also podman reports `0` as default. We still test that if we don't set it up, it is 0, but for that see containers/podman#4822

Fixes: #287
Closes: #289
  • Loading branch information
marusak authored Jan 13, 2020
1 parent c14c670 commit 0185702
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/ImageRunModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class ImageRunModal extends React.Component {
publish: [],
image: props.image,
memory: 512,
cpuShares: 0,
cpuShares: "",
memoryConfigure: false,
cpuSharesConfigure: false,
memoryUnit: 'MiB',
Expand All @@ -230,7 +230,7 @@ export class ImageRunModal extends React.Component {
const memorySize = this.state.memory * (1024 ** units[this.state.memoryUnit].base1024Exponent);
createConfig.memory = memorySize.toString();
}
if (this.state.cpuSharesConfigure) {
if (this.state.cpuSharesConfigure && this.state.cpuShares !== "") {
createConfig.cpuShares = this.state.cpuShares;
}
if (this.state.hasTTY)
Expand Down Expand Up @@ -352,9 +352,9 @@ export class ImageRunModal extends React.Component {
type='number'
value={dialogValues.cpuShares}
step={1}
min={0}
min={2}
disabled={!this.state.cpuSharesConfigure}
onChange={e => this.onValueChanged('cpuShares', parseInt(e.target.value))} />
onChange={e => this.onValueChanged('cpuShares', e.target.value === "" ? "" : parseInt(e.target.value))} />
</div>
</>
}
Expand Down
2 changes: 1 addition & 1 deletion test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ class TestApplication(testlib.MachineCase):
if auth:
b.set_checked("#run-image-dialog-cpu-priority-checkbox", True)
b.wait_present("#run-image-dialog-cpu-priority-checkbox:checked")
b.wait_present('div.modal-body label:contains("CPU Shares") + div.form-inline > input[value="0"]')
b.wait_present('div.modal-body label:contains("CPU Shares") + div.form-inline > input[value=""]')
b.set_input_text("#run-image-dialog-cpu-priority input.form-control", "512")
else:
b.wait_not_present("#run-image-dialog-cpu-priority-checkbox")
Expand Down

0 comments on commit 0185702

Please sign in to comment.