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

[collector] Saltstack transport remote_exec handle stderr like other transports #3886

Conversation

TrevorBenson
Copy link
Member


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname email@example.com?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?
  • Are all passwords or private data gathered by this PR obfuscated?

Closes #3860

Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-3886
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

1 similar comment
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-3886
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@TrevorBenson TrevorBenson changed the title [collector] Saltstck transport remote_exec handle stderr like other transports [collector] Saltstack transport remote_exec handle stderr like other transports Dec 16, 2024
@TurboTurtle
Copy link
Member

Not knowing saltstack myself, can you give some context as to the implications of this change? At a high level I'm assuming this means we're wrapping everything inside a bash invocation, but what's the significance of the cmd.exec_code bit?

@TrevorBenson
Copy link
Member Author

TrevorBenson commented Dec 17, 2024

Not knowing saltstack myself, can you give some context as to the implications of this change? At a high level I'm assuming this means we're wrapping everything inside a bash invocation, but what's the significance of the cmd.exec_code bit?

Short answer, it returns only the exit code 127 for command not found, but not the string.


The long answer:

The cmd.shell with either /bin/sh, or /bin/bash when use_shell=True, returned the exit code, but includes the stderr in the output the master receives. This in result appears as if it was stdout.

Adding some debug I examined pkg_list and found it containing the stderr (which control persist did not):

[server-1:run_command] Shell requested, command is now /bin/bash -c 'flatpak list --columns=name,version,branch'
[FlatpakPackageManager._parse_pkg_list] pkg_list: /bin/bash: flatpak: command not found

Applicable lines:

def _parse_pkg_list(self, pkg_list):
for line in pkg_list.splitlines():
pkg = line.split("\t")
yield (pkg[0], pkg[1], pkg[2])

Changing the module to cmd.exec_code bash the exit code 127 is still reported, but stderr no longer shows up in the output returned to the master from each minion (only the actual stdout does), and pkg_list is empty when flatpak is not installed.

@TrevorBenson
Copy link
Member Author

TrevorBenson commented Dec 17, 2024

Looking back at run_command and the logic from use_shell this should probably instead be cmd.exec_code sh, which should also fix the issue. Then the behavior should be more consistent with prior functionality and other transports.

if (use_shell is True or
(self._need_shell if use_shell == 'auto' else False)):
cmd = f"/bin/bash -c {quote(cmd)}"
self.log_debug(f"Shell requested, command is now {cmd}")

@TrevorBenson TrevorBenson force-pushed the sos-trevorbenson-collector-transport-saltstack-flatpak branch from c3bfc54 to 1f7e95c Compare December 17, 2024 06:20
Signed-off-by: Trevor Benson <trevor.benson@gmail.com>
@TrevorBenson TrevorBenson force-pushed the sos-trevorbenson-collector-transport-saltstack-flatpak branch from 1f7e95c to f5bc759 Compare December 17, 2024 06:25
Copy link
Member

@TurboTurtle TurboTurtle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! Makes sense to me.

@TurboTurtle TurboTurtle added the Reviewed/Needs 2nd Ack Require a 2nd ack from a maintainer label Dec 17, 2024
@arif-ali arif-ali added Reviewed/Ready for Merge Has been reviewed, ready for merge and removed Reviewed/Needs 2nd Ack Require a 2nd ack from a maintainer labels Dec 18, 2024
@TurboTurtle TurboTurtle merged commit e117fd4 into sosreport:main Dec 18, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed/Ready for Merge Has been reviewed, ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[collect] Saltstack transport fails to collect when from nodes without flatpak installed
3 participants