Skip to content

Commit

Permalink
feat(manila): add minimum is critical feature to the UI (#1448)
Browse files Browse the repository at this point in the history
Co-authored-by: Andreas Pfau <[email protected]>
  • Loading branch information
VoigtS and andypf authored Nov 5, 2024
1 parent 982cb45 commit afc304f
Showing 1 changed file with 28 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,16 @@ const FormBody = ({ close, errors }) => {
const values = useContext(Form.Context).formValues

let validationError = ""
if (
values.low_enabled == "false" &&
values.high_enabled == "false" &&
values.critical_enabled == "false"
) {
validationError =
"To use autoscaling, at least one threshold must be enabled."
if (values.low_enabled == "false" && values.high_enabled == "false" && values.critical_enabled == "false") {
validationError = "To use autoscaling, at least one threshold must be enabled."
}

return (
<>
<Modal.Body>
<Form.Errors errors={errors} />

<Form.ElementHorizontal
label="When usage is low:"
name="low_enabled"
labelWidth={5}
>
<Form.ElementHorizontal label="When usage is low:" name="low_enabled" labelWidth={5}>
<Form.Input elementType="select">
<option value="false">Do nothing</option>
<option value="true">Auto-shrink share</option>
Expand All @@ -39,33 +30,18 @@ const FormBody = ({ close, errors }) => {
labelWidth={5}
labelClass="control-label secondary-label"
>
<Form.Input
elementType="input"
type="number"
min="5"
disabled={values.low_enabled == "false"}
/>
<Form.Input elementType="input" type="number" min="5" disabled={values.low_enabled == "false"} />
</Form.ElementHorizontal>
<Form.ElementHorizontal
label="Usage is low below (%):"
name="low_usage"
labelWidth={5}
labelClass="control-label secondary-label"
>
<Form.Input
elementType="input"
type="number"
min="0"
max="100"
disabled={values.low_enabled == "false"}
/>
<Form.Input elementType="input" type="number" min="0" max="100" disabled={values.low_enabled == "false"} />
</Form.ElementHorizontal>

<Form.ElementHorizontal
label="When usage is high:"
name="high_enabled"
labelWidth={5}
>
<Form.ElementHorizontal label="When usage is high:" name="high_enabled" labelWidth={5}>
<Form.Input elementType="select">
<option value="false">Do nothing</option>
<option value="true">Auto-extend share</option>
Expand All @@ -77,33 +53,18 @@ const FormBody = ({ close, errors }) => {
labelWidth={5}
labelClass="control-label secondary-label"
>
<Form.Input
elementType="input"
type="number"
min="5"
disabled={values.high_enabled == "false"}
/>
<Form.Input elementType="input" type="number" min="5" disabled={values.high_enabled == "false"} />
</Form.ElementHorizontal>
<Form.ElementHorizontal
label="Usage is high above (%):"
name="high_usage"
labelWidth={5}
labelClass="control-label secondary-label"
>
<Form.Input
elementType="input"
type="number"
min="0"
max="100"
disabled={values.high_enabled == "false"}
/>
<Form.Input elementType="input" type="number" min="0" max="100" disabled={values.high_enabled == "false"} />
</Form.ElementHorizontal>

<Form.ElementHorizontal
label="When usage is critical:"
name="critical_enabled"
labelWidth={5}
>
<Form.ElementHorizontal label="When usage is critical:" name="critical_enabled" labelWidth={5}>
<Form.Input elementType="select">
<option value="false">Do nothing</option>
<option value="true">Auto-extend share immediately</option>
Expand All @@ -124,11 +85,7 @@ const FormBody = ({ close, errors }) => {
/>
</Form.ElementHorizontal>

<Form.ElementHorizontal
label="Stepping strategy:"
name="size_step_single"
labelWidth={5}
>
<Form.ElementHorizontal label="Stepping strategy:" name="size_step_single" labelWidth={5}>
<Form.Input elementType="select">
<option value="false">Percentage-step resizing</option>
<option value="true">Single-step resizing</option>
Expand Down Expand Up @@ -162,8 +119,7 @@ const FormBody = ({ close, errors }) => {
/>
<p className="help-block" style={{ marginBottom: 0 }}>
<i className="fa fa-info-circle" />
As an exception, multiple steps can be taken at once to resolve a
critical usage level.
As an exception, multiple steps can be taken at once to resolve a critical usage level.
</p>
</Form.ElementHorizontal>

Expand All @@ -190,6 +146,17 @@ const FormBody = ({ close, errors }) => {
labelClass="control-label secondary-label"
>
<Form.Input elementType="input" type="number" min="0" />
<div className="checkbox">
<label>
<Form.Input
elementType="input"
type="checkbox"
name="minimum_free_is_critical"
disabled={values.free_minimum == ""}
/>
<span>When crossing this threshold, resize without delay</span>
</label>
</div>
</Form.ElementHorizontal>
</Modal.Body>
<Modal.Footer>
Expand Down Expand Up @@ -247,9 +214,7 @@ export default class CastellumConfigurationEditModal extends React.Component {

validate(values) {
return (
(values.low_enabled == "true" ||
values.high_enabled == "true" ||
values.critical_enabled == "true") &&
(values.low_enabled == "true" || values.high_enabled == "true" || values.critical_enabled == "true") &&
(values.size_step_single == "true" || values.size_step_percent != "")
)
}
Expand Down Expand Up @@ -291,6 +256,10 @@ export default class CastellumConfigurationEditModal extends React.Component {
config.size_constraints = config.size_constraints || {}
config.size_constraints.minimum_free = parseInt(values.free_minimum, 10)
}
if (values.free_minimum != "" && values.minimum_free_is_critical) {
config.size_constraints = config.size_constraints || {}
config.size_constraints.minimum_free_is_critical = true
}

this.props
.configureAutoscaling(this.props.projectID, config)
Expand All @@ -317,9 +286,7 @@ export default class CastellumConfigurationEditModal extends React.Component {
className="shared_filesystem_storage"
>
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-lg">
Configure Autoscaling
</Modal.Title>
<Modal.Title id="contained-modal-title-lg">Configure Autoscaling</Modal.Title>
</Modal.Header>

<Form
Expand Down

0 comments on commit afc304f

Please sign in to comment.