[BUG] 3002.5 influxdb_retention_policy.present state, convert_duration hours
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
If the influxdb_retention_policy.present state is run with the duration specified in hours, and the retention policy already exists, the state will fail. If the retention policy isn't preexisting it will be created, but the state will fail the next run due to it existing as previously mentioned.
Setup
set_autogen_retention_policy:
influxdb_retention_policy.present:
- name: autogen
- database: telegraf
- duration: 2h
- replication: 1
- default: True
Steps to Reproduce the behavior
Create the state above and apply it. If the retention policy doesn't exist, it will be created. If it does exist, the following error will be seen:
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/state.py", line 2154, in call
*cdata["args"], **cdata["kwargs"]
File "/usr/lib/python3.6/site-packages/salt/loader.py", line 2106, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/states/influxdb_retention_policy.py", line 92, in present
if current_policy["duration"] != convert_duration(duration):
File "/usr/lib/python3.6/site-packages/salt/states/influxdb_retention_policy.py", line 38, in convert_duration
hours = int(duration.split("h"))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
The issue can bee seen in the code at line 38 in /usr/lib/python3.6/site-packages/salt/states/influxdb_retention_policy.py:
hours = int(duration.split("h")) should be hours = int(duration.split("h")[0])
Expected behavior
I expect nothing to happen if the retention policy already exists and the duration specified in the state matches the duration in InfluxDB. If the RP exists, but the durations don't match, it should be updated.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3002.5
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.8.1
docker-py: 2.6.1
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.11.1
libgit2: Not Installed
M2Crypto: 0.35.2
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: 1.3.12
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.1.4
System Versions:
dist: centos 7 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-1160.15.2.el7.x86_64
system: Linux
version: CentOS Linux 7 Core
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in salt/states/influxdb_retention_policy.py at convert_duration and the present state path that compares an existing policy's duration. Reproduce the reported failure with a duration such as 2h, then verify that an existing matching retention policy completes successfully and that a differing duration still follows the update behavior described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100