operator debug: fix pprof interval handling #20206
Merged
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.
The
nomad operator debug
command saves a CPU profile for each interval, and names these files based on the interval.The same functions takes a goroutine profile, heap profile, etc. but is missing the logic to interpolate the file name with the interval. This results in the operator debug command making potentially many expensive profile requests, and then overwriting the data. Update the command to save every profile it scrapes, and number them similarly to the existing CPU profile.
Additionally, the command flags for
-pprof-interval
and-pprof-duration
were validated backwards, which meant that we always coerced the-pprof-interval
to be the same as the-pprof-duration
, which always resulted in a single profile being taken at the start of the bundle. Correct the check as well as change the defaults to be more sensible.Fixes: #20151
In addition to fixing up the tests as needed, I've tested this locally as follows.
This results in the following file tree:
file tree