1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

influxdb_retention_policy: fix duration parsing to support INF values (#2396)

* influxdb_retention_policy: fix duration parsing to support INF values

* add changelog
This commit is contained in:
Xabier Napal 2021-05-01 14:19:05 +02:00 committed by GitHub
parent 276880aac1
commit 26c3bd25f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- influxdb_retention_policy - fix bug where ``INF`` duration values failed parsing
(https://github.com/ansible-collections/community.general/pull/2385).

View file

@ -129,7 +129,7 @@ from ansible_collections.community.general.plugins.module_utils.influxdb import
from ansible.module_utils._text import to_native
VALID_DURATION_REGEX = re.compile(r'^(\d+(ns|u|µ|ms|s|m|h|d|w))+$')
VALID_DURATION_REGEX = re.compile(r'^(INF|(\d+(ns|u|µ|ms|s|m|h|d|w)))+$')
DURATION_REGEX = re.compile(r'(\d+)(ns|u|µ|ms|s|m|h|d|w)')
EXTENDED_DURATION_REGEX = re.compile(r'(?:(\d+)(ns|u|µ|ms|m|h|d|w)|(\d+(?:\.\d+)?)(s))')
@ -217,7 +217,7 @@ def create_retention_policy(module, client):
influxdb_shard_group_duration_format = parse_duration_literal(shard_group_duration)
if influxdb_shard_group_duration_format < 3600000000000:
module.fail_json(msg="shard_group_duration value must be at least 1h")
module.fail_json(msg="shard_group_duration value must be finite and at least 1h")
if not module.check_mode:
try:
@ -256,7 +256,7 @@ def alter_retention_policy(module, client, retention_policy):
influxdb_shard_group_duration_format = parse_duration_literal(shard_group_duration)
if influxdb_shard_group_duration_format < 3600000000000:
module.fail_json(msg="shard_group_duration value must be at least 1h")
module.fail_json(msg="shard_group_duration value must be finite and at least 1h")
if (retention_policy['duration'] != influxdb_duration_format or
retention_policy['shardGroupDuration'] != influxdb_shard_group_duration_format or