1
0
mirror of https://github.com/kubeshark/kubeshark.git synced 2025-05-07 16:18:40 +00:00

🔊 Log the pod name in SPDYExecutor

This commit is contained in:
M. Mert Yildiran 2023-11-18 03:02:44 +03:00
parent c03de2222d
commit 696fed8345
No known key found for this signature in database
GPG Key ID: DA5D6DCBB758A461

View File

@ -42,7 +42,7 @@ func CopyFromPod(ctx context.Context, provider *Provider, pod v1.Pod, srcPath st
reader, outStream := io.Pipe()
errReader, errStream := io.Pipe()
go logErrors(errReader)
go logErrors(errReader, pod)
go func() {
defer outStream.Close()
err = exec.StreamWithContext(ctx, remotecommand.StreamOptions{
@ -52,7 +52,7 @@ func CopyFromPod(ctx context.Context, provider *Provider, pod v1.Pod, srcPath st
Tty: false,
})
if err != nil {
log.Error().Err(err).Msg("SPDYExecutor:")
log.Error().Err(err).Str("pod", pod.Name).Msg("SPDYExecutor:")
}
}()
@ -90,11 +90,11 @@ func CopyFromPod(ctx context.Context, provider *Provider, pod v1.Pod, srcPath st
// }
// }
func logErrors(reader io.Reader) {
func logErrors(reader io.Reader, pod v1.Pod) {
r := bufio.NewReader(reader)
for {
msg, _, err := r.ReadLine()
log.Warn().Str("msg", string(msg)).Msg("SPDYExecutor:")
log.Warn().Str("pod", pod.Name).Str("msg", string(msg)).Msg("SPDYExecutor:")
if err != nil {
if err != io.EOF {
log.Error().Err(err).Send()