Fix PerfSpect failing in containerized environments due to missing sudo #1008
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.
Fix PerfSpect failing in containerized environments due to missing sudo
Problem
When running gProfiler with hardware metrics collection enabled inside a container, PerfSpect was becoming a zombie/defunct process and failing to collect any metrics. Investigation revealed that PerfSpect was attempting to use
sudoto elevate privileges for runningperf statcommands, butsudois typically not available in container environments.Error observed:
{"level":"ERROR","msg":"error from perf","error":"failed to run command (sudo bash /root/perfspect_temp/perfspect.tmp.3437908981/perf_stat.sh): exec: \"sudo\": executable file not found in $PATH"}This caused PerfSpect to terminate immediately, resulting in:
ps auxSolution
Added the
--norootflag to the PerfSpect command invocation inhw_metrics.py. This flag prevents PerfSpect from attempting privilege elevation viasudo, which is unnecessary when:sudoinstalledChanges
gprofiler/hw_metrics.py--norootflag to PerfSpect metrics commandsudoTesting
sudoImpact
--norootflag is available in recent PerfSpect versionsRelated Issues
This fix addresses the zombie process issue discovered during container testing where PerfSpect would fail immediately with "sudo: command not found" errors.