Add pythonrelease and pythonrelease_info grains - #70070
Conversation
dd2dea6 to
832d9f6
Compare
|
We'll run these test once the nightlies master branch tests are green. Otherwise they have no hope of passing. Or you could rebase this on the 3008.x branch. |
The pythonversion grain is a list, which breaks the <foo>release / <foo>release_info convention used by the other version grains such as osrelease / osrelease_info. Add pythonrelease (the dotted version string, e.g. 3.11.0) and pythonrelease_info (the equivalent list) alongside it. The change is purely additive: pythonversion keeps its existing value and type, so nothing that reads it today is affected. Fixes saltstack#59594
832d9f6 to
ffad2b9
Compare
|
Thanks @twangboy — the master nightlies still aren't green, so I've taken the second option: this is now rebased onto For reference, every
The rebase was clean — this is a single, purely additive commit and Happy to move it back to |
What does this PR do?
Adds
pythonreleaseandpythonrelease_infograins.What issues does this PR fix or reference?
Fixes #59594
Background
pythonversionis a list rather than a dotted string:which breaks the
<foo>release/<foo>release_infoconvention the other version grains follow (osreleaseis7.9.2009withosrelease_infocarrying the tuple; likewisekernelrelease).The issue suggested adding
pythonrelease/pythonrelease_infoand deprecatingpythonversionat some documented future point. This PR does only the additive half — it deliberately does not touch or deprecatepythonversion, so it carries no backwards-compatibility risk. The deprecation is a separate decision for the maintainers.Result
pythonreleaseusesplatform.python_version(), which is defined asmajor.minor.microand so matches the shape ofosrelease.Tests written?
Yes — added
test_pythonreleasetotests/pytests/unit/grains/test_core.py, asserting the dotted form matches bothplatform.python_version()andmajor.minor.micro, thatpythonrelease_infomatchessys.version_info, and that it stays in sync with the pre-existingpythonversiongrain.Verified locally:
test_pythonversion(pre-existing, confirming the old grain is untouched) and the newtest_pythonreleasepass against the realsalt.grains.coremodule.tests/pytests/integration/modules/grains/test_module.pyandtests/pytests/pkg/integration/test_salt_grains.py— both assert membership (assert grain in ret.data) rather than an exact grain set, so adding grains does not affect them.black==24.2.0(the version pinned in.pre-commit-config.yaml) reports both changed files unchanged.I was not able to run the full
tests/pytests/unit/grains/test_core.pysuite locally — thesalt-factoriesconftest setup didn't complete in this environment — so CI is the real check on the rest of that file.Commits signed with GPG?
No