Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean env vars broken in Python > 3.12 #103

Closed
oponomarov-tu opened this issue Oct 16, 2024 · 2 comments
Closed

Boolean env vars broken in Python > 3.12 #103

oponomarov-tu opened this issue Oct 16, 2024 · 2 comments

Comments

@oponomarov-tu
Copy link

oponomarov-tu commented Oct 16, 2024

With the boolean env vars defined as following:

spec:
  containers:
    - args:
        - |
          /app/rundeck_exporter.py
      command:
        - /bin/sh
        - -c
      env:
        - name: RUNDECK_SKIP_SSL
          value: "true"
        - name: RUNDECK_PROJECTS_EXECUTIONS
          value: "true"
        - name: RUNDECK_PROJECTS_EXECUTIONS_CACHE
          value: "true"
        - name: RUNDECK_CPU_STATS
          value: "true"
        - name: RUNDECK_MEMORY_STATS
          value: "true"
        - name: RUNDECK_EXPORTER_DEBUG
          value: "false"

For Python > 3.12, the following exception is thrown:

│ Traceback (most recent call last):
│   File "/app/rundeck_exporter.py", line 52, in <module>
│     class RundeckMetricsCollector(object):
│   File "/app/rundeck_exporter.py", line 72, in RundeckMetricsCollector
│     default=literal_eval(getenv('RUNDECK_EXPORTER_DEBUG', 'False')),
│             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│   File "/usr/local/lib/python3.12/ast.py", line 112, in literal_eval
│     return _convert(node_or_string)
│            ^^^^^^^^^^^^^^^^^^^^^^^^
│   File "/usr/local/lib/python3.12/ast.py", line 111, in _convert
│     return _convert_signed_num(node)
│            ^^^^^^^^^^^^^^^^^^^^^^^^^
│   File "/usr/local/lib/python3.12/ast.py", line 85, in _convert_signed_num
│     return _convert_num(node)
│            ^^^^^^^^^^^^^^^^^^
│   File "/usr/local/lib/python3.12/ast.py", line 76, in _convert_num
│     _raise_malformed_node(node)
│   File "/usr/local/lib/python3.12/ast.py", line 73, in _raise_malformed_node
│     raise ValueError(msg + f': {node!r}')
│ ValueError: malformed node or string on line 1: <ast.Name object at 0x7fe68e948110>
$ python -V 
Python 3.12.6

Related:

@phsmith
Copy link
Owner

phsmith commented Oct 16, 2024

Hi @oponomarov-tu.
Thanks for reporting. I've just released a new version (v2.8.3) that fixes this issue.

@oponomarov-tu
Copy link
Author

Thanks @phsmith for prompt response and fix! Works like a charm 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants