From 26c3bd25f676b67a89a625e13991ab41394f5098 Mon Sep 17 00:00:00 2001 From: Xabier Napal Date: Sat, 1 May 2021 14:19:05 +0200 Subject: [PATCH] influxdb_retention_policy: fix duration parsing to support INF values (#2396) * influxdb_retention_policy: fix duration parsing to support INF values * add changelog --- .../2284-influxdb_retention_policy-fix_duration_parsing.yml | 3 +++ .../modules/database/influxdb/influxdb_retention_policy.py | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/2284-influxdb_retention_policy-fix_duration_parsing.yml diff --git a/changelogs/fragments/2284-influxdb_retention_policy-fix_duration_parsing.yml b/changelogs/fragments/2284-influxdb_retention_policy-fix_duration_parsing.yml new file mode 100644 index 0000000000..04c82480c1 --- /dev/null +++ b/changelogs/fragments/2284-influxdb_retention_policy-fix_duration_parsing.yml @@ -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). diff --git a/plugins/modules/database/influxdb/influxdb_retention_policy.py b/plugins/modules/database/influxdb/influxdb_retention_policy.py index 2c2f9674b7..883adaffa6 100644 --- a/plugins/modules/database/influxdb/influxdb_retention_policy.py +++ b/plugins/modules/database/influxdb/influxdb_retention_policy.py @@ -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