troubleshoot icon indicating copy to clipboard operation
troubleshoot copied to clipboard

feat: Prompt for privileged user if host collectors present in spec

Open banjoh opened this issue 1 year ago • 0 comments

Description, Motivation and Context

If host collectors are present in a spec when running support-bundle or preflight CLIs, we want to prompt a user to run the binary as an elevated user. This is because some of the tools executed require elevated privileges. Without elevated privileges, the collected data ends up being useless.

Prompt to run as root

support-bundle https://raw.githubusercontent.com/replicatedhq/troubleshoot-specs/main/host/default.yaml

Some host collectors may require elevated privileges to run.
Do you want to exit and rerun the command as a privileged user? (yes/no): yes
Exiting...

When the user declines (no), the process continues as normal

Additional context

We collectively check the presence/absence of host collectors because we cannot confidently tell which collectors require elevated privileges or don't. Both run and copy collectors for example can wrap any command/path that requires root access. Our default host collector spec uses these collectors extensively.

Checklist

  • [ ] New and existing tests pass locally with introduced changes.
  • [x] Tests for the changes have been added (for bug fixes / features)
  • [x] The commit message(s) are informative and highlight any breaking changes
  • [ ] Any documentation required has been added/updated. For changes to https://troubleshoot.sh/ create a PR here

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

banjoh avatar Mar 26 '24 17:03 banjoh