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

metalk8s_sysctl.has_precedence incorrectly attempts to interpolate %-prefixed sequences #3223

Closed
gdemonet opened this issue Mar 23, 2021 · 0 comments · Fixed by #3224
Closed
Labels
complexity:easy Something that requires less than a day to fix kind:bug Something isn't working topic:deployment Bugs in or enhancements to deployment stages topic:salt Everything related to SaltStack in our product

Comments

@gdemonet
Copy link
Contributor

Component: salt

What happened:

Some config file in /etc/sysctl.d containing:

kernel.core_pattern=/var/tmp/core-%e-%p-%t

Running bootstrap.sh ends up failing with:

----------
          ID: Set sysctl net.bridge.bridge-nf-call-ip6tables value to 1
    Function: metalk8s_sysctl.present
        Name: net.bridge.bridge-nf-call-ip6tables
      Result: False
     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 "/var/cache/salt/minion/extmods/states/metalk8s_sysctl.py", line 29, in present
                  __salt__["metalk8s_sysctl.has_precedence"](name, value, config, strict)
                File "/var/cache/salt/minion/extmods/modules/metalk8s_sysctl.py", line 99, in has_precedence
                  sysctl = dict(parser.items("global"))
                File "/usr/lib64/python3.6/configparser.py", line 858, in items
                  return [(option, value_getter(option)) for option in d.keys()]
                File "/usr/lib64/python3.6/configparser.py", line 858, in <listcomp>
                  return [(option, value_getter(option)) for option in d.keys()]
                File "/usr/lib64/python3.6/configparser.py", line 855, in <lambda>
                  section, option, d[option], d)
                File "/usr/lib64/python3.6/configparser.py", line 394, in before_get
                  self._interpolate_some(parser, option, L, value, section, defaults, 1)
                File "/usr/lib64/python3.6/configparser.py", line 444, in _interpolate_some
                  "found: %r" % (rest,))
              configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%e-%p-%t'
     Started: 17:47:25.657044
    Duration: 7.262 ms
     Changes:

What was expected: Such config file is accepted by sysctl, we should not fail. Also, if we do, we should wrap the error in a CommandExecutionError.

Resolution proposal (optional): Disable interpolation with ConfigParser(interpolation=None).

@gdemonet gdemonet added kind:bug Something isn't working topic:deployment Bugs in or enhancements to deployment stages complexity:easy Something that requires less than a day to fix topic:salt Everything related to SaltStack in our product labels Mar 23, 2021
@gdemonet gdemonet added this to the MetalK8s 2.8.1 milestone Mar 23, 2021
@bert-e bert-e closed this as completed in 82ee169 Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity:easy Something that requires less than a day to fix kind:bug Something isn't working topic:deployment Bugs in or enhancements to deployment stages topic:salt Everything related to SaltStack in our product
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant