Bug 2178714
| Summary: | Creating location constraint passes with wrong date format | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | Tomas Jelinek <tojeline> |
| Component: | pcs | Assignee: | Tomas Jelinek <tojeline> |
| Status: | CLOSED ERRATA | QA Contact: | cluster-qe <cluster-qe> |
| Severity: | low | Docs Contact: | |
| Priority: | medium | ||
| Version: | 9.0 | CC: | cluster-maint, idevat, mlisik, mmazoure, mpospisi, omular, tojeline |
| Target Milestone: | rc | Keywords: | Triaged |
| Target Release: | 9.3 | Flags: | pm-rhel:
mirror+
|
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | pcs-0.11.5-1.el9 | Doc Type: | Bug Fix |
| Doc Text: |
Cause:
User enters a location constraint rule with a date in an unexpected format.
Consequence:
The constraint is stored in cluster configuration and either doesn't work at all or applies at unexpected time.
Fix:
Validate format of date entered in the rule.
Result:
The user is informed in case the entered date is not valid.
|
Story Points: | --- |
| Clone Of: | 2178707 | Environment: | |
| Last Closed: | 2023-11-07 08:23:11 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Tomas Jelinek
2023-03-15 15:56:02 UTC
Already reported and fixed upstream: https://github.com/ClusterLabs/pcs/pull/644 Upstream patch: https://github.com/ClusterLabs/pcs/commit/a346c30c11744c0d3f9126b4456f0d13e51848bc Test: # pcs constraint location dummy rule date lt '01-01-2022' Error: 'date lt 01-01-2022' is not a valid rule expression: '01-01-2022' is not an ISO 8601 date DevTestResults: [root@r09-03-a ~]# rpm -q pcs pcs-0.11.5-1.el9.x86_64 [root@r09-03-a ~]# pcs constraint location r1 rule date lt '01-01-2022' Error: 'date lt 01-01-2022' is not a valid rule expression: '01-01-2022' is not an ISO 8601 date ## BEFORE
[root@virt-248 ~]# rpm -q pcs
pcs-0.11.4-6.el9.x86_64
[root@virt-248 ~]# pcs resource create d1 ocf:heartbeat:Dummy
[root@virt-248 ~]# echo $?
0
[root@virt-248 ~]# pcs resource
* d1 (ocf:heartbeat:Dummy): Started virt-248
A). Entering invalid date format for location rule (not an ISO 8601 date)
[root@virt-248 ~]# pcs constraint location d1 rule date lt 22-06-2023
[root@virt-248 ~]# echo $?
0
[root@virt-248 ~]# pcs constraint location config
Location Constraints:
Resource: d1
Constraint: location-d1
Rule: score=INFINITY
Expression: date lt 22-06-2023
> In the previous version it was possible to specify a constraint rule with a date whose format was not correct (not an ISO8601 date format). This case did not return an error and the return code was 0.
## AFTER
[root@virt-019 ~]# rpm -q pcs
pcs-0.11.5-2.el9.x86_64
[root@virt-019 ~]# pcs resource create d1 ocf:heartbeat:Dummy
[root@virt-019 ~]# echo $?
0
[root@virt-019 ~]# pcs resource
* d1 (ocf:heartbeat:Dummy): Started virt-018
A.) Entering invalid date format(dd-mm-yyyy, not an ISO 8601 date)
[root@virt-019 ~]# pcs constraint location d1 rule date lt 22-06-2023
Error: 'date lt 22-06-2023' is not a valid rule expression: '22-06-2023' is not an ISO 8601 date
[root@virt-019 ~]# echo $?
1
[root@virt-019 ~]# pcs constraint location config
> OK.
B.) Entering another invalid date format (yyyy/month/dd)
[root@virt-019 ~]# pcs constraint location d1 rule date lt 06/22/2023
Error: 'date lt 06/22/2023' is not a valid rule expression: '06/22/2023' is not an ISO 8601 date
[root@virt-019 ~]# echo $?
1
[root@virt-019 ~]# pcs constraint location config
> OK.
C.) Entering US date format (mm/dd/yyyy, not an ISO 8601 date)
[root@virt-019 ~]# pcs constraint location d1 rule date lt 06/22/2023
Error: 'date lt 06/22/2023' is not a valid rule expression: '06/22/2023' is not an ISO 8601 date
[root@virt-019 ~]# echo $?
1
[root@virt-019 ~]# pcs constraint location config
> OK.
D.) Entering invalid date format (yyyy-mm/dd)
[root@virt-019 ~]# pcs constraint location d1 rule date lt 2023-06/23
[root@virt-019 ~]# echo $?
0
[root@virt-019 ~]# pcs constraint location config
> I am not sure about validity of this edge case. The first part of the date is OK and so it is possible that it is evaluated as a valid ISO 8601 date, but in this case the user is not notified that this date is an invalid date format. Also there is no warning/error message and it returns with 0 return code, however no actie location constraint is displayed.
[root@virt-019 ~]# pcs constraint location config --all
Location Constraints:
resource 'd1'
Rules:
Rule (expired): score=INFINITY
Expression: date lt 2023-06/23
[root@virt-019 ~]# date
Wed Jun 21 03:36:08 PM CEST 2023
> This location constraint rule is shown as expired even though it should not be expired yet. We have created a new BZ that addresses this issue (https://bugzilla.redhat.com/show_bug.cgi?id=2216492)
E.) Entering invalid date format (yyyy/mm-dd)
[root@virt-019 ~]# pcs constraint location d1 rule lt 2023/06-23
Error: 'lt 2023/06-23' is not a valid rule expression: unexpected 'lt'
[root@virt-019 ~]# echo $?
1
[root@virt-019 ~]# pcs constraint location config
> OK.
F.) Entering valid ISO8601 basic date format
[root@virt-019 ~]# pcs constraint location d1 rule date lt 2023-06-22
[root@virt-019 ~]# echo $?
0
[root@virt-019 ~]# pcs constraint location config
Location Constraints:
resource 'd1'
Rules:
Rule: score=INFINITY
Expression: date lt 2023-06-22
> OK.
G.) Entering valid ISO8601 week date format
[root@virt-019 ~]# pcs constraint location d1 rule date lt 2023-W25-4
[root@virt-019 ~]# echo $?
0
[root@virt-019 ~]# pcs constraint location config
Location Constraints:
resource 'd1'
Rules:
Rule: score=INFINITY
Expression: date lt 2023-W25-4
> OK.
H.) Entering valid ISO8601 date format
[root@virt-019 ~]# pcs constraint location d1 rule date lt 2023-173
[root@virt-019 ~]# echo $?
0
[root@virt-019 ~]# pcs constraint location config
Location Constraints:
resource 'd1'
Rules:
Rule: score=INFINITY
Expression: date lt 2023-173
> OK.
I.) Entering more complex valid date expression
[root@virt-019 ~]# pcs constraint location d1 rule date in_range 2023-01-01 to 2023-175
[root@virt-019 ~]# echo $?
0
[root@virt-019 ~]# pcs constraint location config
Location Constraints:
resource 'd1'
Rules:
Rule: score=INFINITY
Expression: date in_range 2023-01-01 to 2023-175
> OK.
> Overall, working with dates that are specified in ISO 8601 standard works reliably. However, in my opinion, it would be useful to add an extra check to ensure that only ISO 8601 dates are supported. This is addressed in (https://bugzilla.redhat.com/show_bug.cgi?id=2216492).
> Marking as VERIFIED for pcs-0.11.5-2.el9.x86_64
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Low: pcs security, bug fix, and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2023:6316 |