troubleshoot icon indicating copy to clipboard operation
troubleshoot copied to clipboard

Add collected runtime logs to support bundle archives

Open banjoh opened this issue 2 years ago • 1 comments

Describe the rationale for the suggested feature.

Whenever we run the support-bundle CLI commands to collect support bundles, we might at times have errors that occur in the various heterogenous k8s environments. Troubleshoot project itself can also have a bug. Logs instrumented in the code capture what happens when executing troubleshoot commands and we would like to copy these logs in support bundle archives for better troubleshooting.

Describe the feature

Pipe all logs streamed to stderr and stdout by the logging library used. Store the logs to file and add them to the support bundle archive.

We rely on k8s client-go library which uses klog. For us to access these logs to write to a file, we would need to use the same logger and pass in a logr.Logger implementation that intercepts all logs. Logs written to the log file are afterwards packaged in the support bundle for archive. NOTE: Passing in log-file or log-dir options is not what this bullet is about.

Additional context

This was split from #1008 PR which was been blocked by https://github.com/kubernetes/klog/pull/363 klog PR.

banjoh avatar Feb 21 '23 13:02 banjoh

Partially done work https://github.com/banjoh/troubleshoot/tree/em/logging-improvements-backup

banjoh avatar Feb 21 '23 16:02 banjoh