Skip to content

fix 45195 - add ignore to sysctl state and module #55719

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

Merged
merged 5 commits into from
Apr 13, 2020

Conversation

mchugh19
Copy link
Contributor

What does this PR do?

Add ignore support for sysctl module and state
Port of #52366 to master

What issues does this PR fix or reference?

#45195

Previous Behavior

If kernel settings were adjusted via grub, sysctl state would throw errors.

sysctl.get

# salt-call sysctl.get net.ipv6.conf.default.disable_ipv6
[ERROR   ] Command '[u'sysctl', u'-n', u'net.ipv6.conf.default.disable_ipv6']' failed with return code: 255
[ERROR   ] stdout: sysctl: cannot stat /proc/sys/net/ipv6/conf/default/disable_ipv6: No such file or directory
[ERROR   ] retcode: 255
[ERROR   ] Command 'sysctl -n net.ipv6.conf.default.disable_ipv6' failed with return code: 255
[ERROR   ] output: sysctl: cannot stat /proc/sys/net/ipv6/conf/default/disable_ipv6: No such file or directory
local:
    sysctl: cannot stat /proc/sys/net/ipv6/conf/default/disable_ipv6: No such file or directory

sysctl.assign

# salt-call sysctl.assign net.ipv6.conf.default.disable_ipv6 1 ignore=False
Error running 'sysctl.assign': sysctl net.ipv6.conf.default.disable_ipv6 does not exist

state sysctl.present

net.ipv6.conf.default.disable_ipv6:
  sysctl.present:
    - value: 1

# salt-call state.sls sysctl
[ERROR   ] Command '[u'sysctl', u'-n', u'net.ipv6.conf.default.disable_ipv6']' failed with return code: 255
[ERROR   ] stdout: sysctl: cannot stat /proc/sys/net/ipv6/conf/default/disable_ipv6: No such file or directory
[ERROR   ] retcode: 255
[ERROR   ] Command 'sysctl -n net.ipv6.conf.default.disable_ipv6' failed with return code: 255
[ERROR   ] output: sysctl: cannot stat /proc/sys/net/ipv6/conf/default/disable_ipv6: No such file or directory
[ERROR   ] Failed to set net.ipv6.conf.default.disable_ipv6 to 1: sysctl net.ipv6.conf.default.disable_ipv6 does not exist
local:
----------
          ID: net.ipv6.conf.default.disable_ipv6
    Function: sysctl.present
      Result: False
     Comment: Failed to set net.ipv6.conf.default.disable_ipv6 to 1: sysctl net.ipv6.conf.default.disable_ipv6 does not exist
     Started: 06:52:51.018918
    Duration: 22.922 ms
     Changes:

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:  22.922 ms

New Behavior

Support ignore=True in order to suppress sysctl errors on disabled settings

sysctl.get

# salt-call sysctl.get net.ipv6.conf.default.disable_ipv6 ignore=True
local:

sysctl.assign

# salt-call sysctl.assign net.ipv6.conf.default.disable_ipv6 1 ignore=True
local:
    ----------
    net.ipv6.conf.default.disable_ipv6:
        ignored

state sysctl.present

net.ipv6.conf.default.disable_ipv6:
  sysctl.present:
    - value: 1
    - ignore: True


# salt-call state.sls sysctl
local:
----------
          ID: net.ipv6.conf.default.disable_ipv6
    Function: sysctl.present
      Result: True
     Comment: Sysctl value net.ipv6.conf.default.disable_ipv6 = 1 was ignored
     Started: 06:54:07.576832
    Duration: 12.76 ms
     Changes:

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:  12.760 ms

Tests written?

Yes

Commits signed with GPG?

No

@mchugh19 mchugh19 requested a review from a team as a code owner December 21, 2019 08:42
@ghost ghost requested a review from Ch3LL December 21, 2019 08:43
@dwoz
Copy link
Contributor

dwoz commented Jan 5, 2020

@mchugh19 This windows test failure needs to be addressed

https://jenkinsci.saltstack.com/job/pr-windows2016-py2/job/PR-55719/2/testReport/junit/integration.modules.test_network/NetworkTest/test_network_ping/

integration.modules.test_network.NetworkTest.test_network_ping

@mchugh19
Copy link
Contributor Author

mchugh19 commented Jan 5, 2020

@dwoz I can't see how the windows test failure could be related to modifications of the linux only sysctl module and state. Is it possible there is an issue with windows test machines?

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

Successfully merging this pull request may close these issues.

3 participants