Fix invalid value range for member weight

Octavia supports setting the weight of members from 0 to 256, but
in Horizon the value 0 was not accepted. This fix allows entering
the value 0 as well, which is important for putting a member into
DRAINING state.

Change-Id: I25ce292f962cf6a0d6f017fe7bc47aaed0790efc
Story: 2009804
Task: 44362
This commit is contained in:
Tom Weininger 2022-01-25 12:07:38 +01:00
parent 83267ea0d0
commit b1a86bb6ff
7 changed files with 15 additions and 7 deletions

View File

@ -69,7 +69,7 @@
ctrl.cancel = cancel;
ctrl.save = save;
ctrl.saving = false;
ctrl.weightError = gettext('The weight must be a number between 1 and 256.');
ctrl.weightError = gettext('The weight must be a number between 0 and 256.');
ctrl.monitorAddressError = gettext('The monitor address must be a valid IP address.');
ctrl.monitorPortError = gettext('The monitor port must be a number between 1 and 65535.');

View File

@ -71,7 +71,7 @@
expect(ctrl.weight).toBe(1);
expect(ctrl.ipPattern).toBeDefined();
expect(ctrl.helpUrl).toBeDefined();
expect(ctrl.weightError).toBe('The weight must be a number between 1 and 256.');
expect(ctrl.weightError).toBe('The weight must be a number between 0 and 256.');
expect(ctrl.monitorAddressError).toBe('The monitor address must be a valid IP address.');
expect(ctrl.monitorPortError).toBe('The monitor port must be a number between 1 and 65535.');
});

View File

@ -50,7 +50,7 @@
<span class="hz-icon-required fa fa-asterisk"></span>
</label>
<input name="weight" id="weight" type="number" class="form-control"
ng-model="modal.weight" ng-pattern="/^\d+$/" min="1" max="256"
ng-model="modal.weight" ng-pattern="/^\d+$/" min="0" max="256"
ng-required="true">
<span class="help-block" ng-show="form.weight.$invalid && form.weight.$dirty">
{$ ::modal.weightError $}

View File

@ -47,7 +47,7 @@
// Error text for invalid fields
ctrl.portError = gettext('The port must be a number between 1 and 65535.');
ctrl.weightError = gettext('The weight must be a number between 1 and 256.');
ctrl.weightError = gettext('The weight must be a number between 0 and 256.');
ctrl.ipError = gettext('The IP address is not valid.');
// Instances transer table widget properties

View File

@ -30,8 +30,9 @@
<strong translate>Weight:</strong>
<translate>
The weight of a member determines the portion of requests or connections it services compared
to the other members of the pool. A higher weight means it will receive more traffic. Must be
a number from 1 to 256.
to the other members of the pool. A value of 0 means the member does not receive new connections
but continues to service existing connections. A higher weight means it will receive more
traffic. Must be a number from 0 to 256.
</translate>
</p>
<p>

View File

@ -90,7 +90,7 @@
<div class="form-group member-weight"
ng-class="{ 'has-error': memberDetailsForm['{$ ::row.id $}-weight'].$invalid && memberDetailsForm['{$ ::row.id $}-weight'].$dirty }">
<input name="{$ ::row.id $}-weight" type="number" class="form-control"
ng-model="row.weight" ng-pattern="/^\d+$/" min="1" max="256"
ng-model="row.weight" ng-pattern="/^\d+$/" min="0" max="256"
ng-disabled="row.allocatedMember"
popover-placement="top" popover-append-to-body="true"
popover-trigger="focus"

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Octavia supports setting the weight of members from 0 to 256, but
in Horizon the value 0 was not accepted. This fix allows entering
the value 0 as well, which is important for putting a member into
DRAINING state.