utils/systemd: stop using capture_output so Python 3.6 targets keep working#68970
Open
SAY-5 wants to merge 1 commit intosaltstack:3007.xfrom
Open
utils/systemd: stop using capture_output so Python 3.6 targets keep working#68970SAY-5 wants to merge 1 commit intosaltstack:3007.xfrom
SAY-5 wants to merge 1 commit intosaltstack:3007.xfrom
Conversation
…orking salt-ssh still advertises 3.6 as a possible target python on older distros (saltstack#68778), but salt.utils.systemd calls subprocess.run with capture_output=True in two places. capture_output was added in 3.7, so those call sites raise TypeError under 3.6 the moment they execute - which breaks systemd status/pid lookup on any minion stuck on 3.6. Replace both with the 3.6-compatible stdout=subprocess.PIPE, stderr=subprocess.PIPE form; behaviour is identical on 3.7+. Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com> Fixes saltstack#68778
Contributor
|
Python 3.6 is a 9 year old release than went EOL in 2021: https://endoflife.date/python Update your python |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Replaces the two
subprocess.run(..., capture_output=True)calls insalt/utils/systemd.pywith the older-compatiblestdout=subprocess.PIPE, stderr=subprocess.PIPEform.capture_outputwas added in Python 3.7. salt-ssh still advertises 3.6 as a possible target python on older distros (see #68778), so the two call sites in_status()and_pid_to_service_systemctlwould raiseTypeErrorthe moment they executed on a 3.6 remote — which is exactly what the reporter hits.Behaviour on 3.7+ is unchanged.
What issues does this PR fix or reference?
Fixes #68778
Previous Behavior
On salt-ssh runs where the remote happens to still be on Python 3.6, any
salt.utils.systemdimport path that touched_statusor_pid_to_service_systemctlraised:New Behavior
Both helpers now build the pipes explicitly:
Merge requirements satisfied?
changelog/68778.fixed.mdsystemctl, which isn't straightforward to unit-test without an extra fixture. Happy to add one if the maintainers prefer before merge.Commits signed with GPG?
DCO-signed off (
Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>).