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

Fix macosx grains when swapusage returns comma #48304

Merged
merged 1 commit into from Jul 20, 2018

Conversation

Projects
None yet
4 participants
@Ch3LL
Contributor

Ch3LL commented Jun 25, 2018

What does this PR do?

Apparently macosx can return a comman when running vm.swapusage. This handles those cases and adds tests.

What issues does this PR fix or reference?

#48078

Previous Behavior

salt-minion does not start due to valuerror

New Behavior

salt-minion starts

Tests written?

Yes

Commits signed with GPG?

Yes

@@ -448,7 +448,7 @@ def _osx_memdata():
sysctl = salt.utils.path.which('sysctl')
if sysctl:
mem = __salt__['cmd.run']('{0} -n hw.memsize'.format(sysctl))
swap_total = __salt__['cmd.run']('{0} -n vm.swapusage'.format(sysctl)).split()[2]
swap_total = __salt__['cmd.run']('{0} -n vm.swapusage'.format(sysctl)).split()[2].replace(',', '.')

This comment has been minimized.

@rares-pop

rares-pop Jun 26, 2018

Contributor

Is this due to the locale?

Here you can find a more generic approach:
https://stackoverflow.com/questions/13362121/convert-python-strings-into-floats-explicitly-using-the-comma-or-the-point-as-se

I wonder if there are no better ways to do it though.

This comment has been minimized.

@Ch3LL

Ch3LL Jun 29, 2018

Contributor

yeah looks like you are right that this is related to locale. let me look into a better fix. thanks :)

@cachedout

This comment has been minimized.

Contributor

cachedout commented Jul 18, 2018

@Ch3LL Any updates here?

@Ch3LL

This comment has been minimized.

Contributor

Ch3LL commented Jul 19, 2018

apologies i didn't follow up here. But as you can see in the issue of hte comments here: #48078 (comment)

i'm a bit worried about using the locale module as I read that it changes the program from using the C locale to the user definied LANG environment, and I'm worried this will have other effects on salt later in the stack and in other places. And doing more research we can't even look up what the locale decimal point is as you have to use setlocale which does the same changes defined above.

i'm wondering if the original PR is the best approach but I'm open to other ideas, or maybe my interpretation of the locale module is wrong.

@rares-pop

This comment has been minimized.

Contributor

rares-pop commented Jul 19, 2018

I just read the comments there, and probably is fine to go with the original fix and do something more on the next related open issue. I believe this will significantly reduce the hit-count.

@rallytime rallytime merged commit dfc1582 into saltstack:2018.3 Jul 20, 2018

8 of 11 checks passed

default Build finished.
Details
jenkins/PR/salt-pr-linode-ubuntu14-n Pull Requests » Salt PR - Linode Ubuntu14.04 #23942 — FAILURE
Details
jenkins/PR/salt-pr-linode-ubuntu16-py3 Pull Requests » Salt PR - Linode Ubuntu16.04 - PY3 #10984 — FAILURE
Details
WIP ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/PR/salt-pr-clone Pull Requests » Salt PR - Clone #26218 — SUCCESS
Details
jenkins/PR/salt-pr-docs-n Pull Requests » Salt PR - Docs #18265 — SUCCESS
Details
jenkins/PR/salt-pr-linode-cent7-py3 Pull Requests » Salt PR - Linode CentOS 7 - PY3 #6014 — SUCCESS
Details
jenkins/PR/salt-pr-lint-n Pull Requests » Salt PR - Code Lint #22900 — SUCCESS
Details
jenkins/PR/salt-pr-rs-cent7-n Pull Requests » Salt PR - RS CentOS 7 #20067 — SUCCESS
Details
jenkins/pr/lint The lint job has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment