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

osversion/osversion_info/osmajorrelease grains fixes #49946

Merged
merged 12 commits into from Oct 10, 2018

Conversation

Projects
None yet
5 participants
@isbm
Copy link
Contributor

commented Oct 9, 2018

What does this PR do?

Bugfix for osversion, osversion_info and osmajorrelease grains on SUSE systems.

What issues does this PR fix or reference?

As per documentation of /etc/os-release file:

VERSION_ID=
A lower-case string (mostly numeric, no spaces or other characters outside of 0-9, a-z, ".", "_" and "-") identifying the operating system version, excluding any OS name information or release code name, and suitable for processing by scripts or usage in generated filenames. This field is optional.
Example:
"VERSION_ID=17" or "VERSION_ID=11.04".

This in reality this so far always worked, because nobody adds there anything else but numbers and dots. However, it allows symbols. And thus if one is adding something like VERSION_ID=foo.bar which is still allowed, the grain osmajorrelease will disappear, since it is expected to be an integer.

CPE_NAME, in contrary, has a clear definition between version number and its phase (for "beta", "alpha" etc). Unfortunately, CPE_NAME is still optional. But it is provided on the systems where no /etc/lsb-release with DISTRIB_RELEASE like in Debian, for example. Therefore Salt should try look up for CPE_NAME as well and fall-back to VERSION_ID only if nothing else has been found to figure out distribution version. Also, on some distributions CPE_NAME is still broken (only major version specified).

Previous Behavior

# cat /etc/os-release | grep VERSION_ID
VERSION_ID="foo.bar"

$ salt-call --local grains.get osrelease
local:
    foo.bar

$ salt-call --local grains.get osrelease_info
local:
    - foo
    - bar

$ salt-call --local grains.get osmajorrelease
local:

New Behavior

# cat /etc/os-release | grep VERSION_ID
VERSION_ID="foo.bar"

$ salt-call --local grains.get osrelease
local:
    15.0

$ salt-call --local grains.get osrelease_info
local:
    - 15
    - 0

# salt-call --local grains.get osmajorrelease
local:
    15

# salt-call --local grains.get osmajorrelease --out json
{
    "local": 15
}

Tests written?

Yes

Show resolved Hide resolved salt/grains/core.py
Show resolved Hide resolved salt/grains/core.py Outdated

@rallytime rallytime merged commit c912d3a into saltstack:2018.3 Oct 10, 2018

8 of 10 checks passed

jenkins/pr/py2-windows-2016 The py2-windows-2016 job has failed
Details
jenkins/pr/py3-windows-2016 The py3-windows-2016 job has failed
Details
WIP ready for review
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.