PT-2169 - pt-k8s-debug-collector integration of pg_gather requires croping first line of the output file (#615)

* PT-2169 - pt-k8s-debug-collector integration of pg_gather requires croping first line of the output file

Modified pt-k8s-debug-collector so it redirects only STDOUT to summary.txt
STDERR is stored in the logs and recorded in summary.txt only if summary fails with the error
Modified Makefile, so it does not include closing bracket into the version string
Created test case for the fix

* PT-2169 - pt-k8s-debug-collector integration of pg_gather requires croping first line of the output

Removed else as requested by Ege
This commit is contained in:
Sveta Smirnova
2023-04-20 03:12:52 +03:00
committed by GitHub
parent 85eb1411d1
commit 501e4cd568
3 changed files with 55 additions and 8 deletions

View File

@@ -6,7 +6,6 @@ import (
"compress/gzip"
"encoding/base64"
"encoding/json"
"fmt"
"log"
"os"
"os/exec"
@@ -309,7 +308,7 @@ func (d *Dumper) getResource(name, namespace string, ignoreNotFound bool, tw *ta
}
func (d *Dumper) logError(err string, args ...string) {
d.errors += d.cmd + " " + strings.Join(args, " ") + ": " + err + "\n"
d.errors += d.cmd + " " + strings.Join(args, " ") + "\n" + err + "\n\n"
}
func addToArchive(location string, mode int64, content []byte, tw *tar.Writer) error {
@@ -463,10 +462,9 @@ func (d *Dumper) getPodSummary(resource, podName, crName string, namespace strin
cmd.Stderr = &errb
err := cmd.Run()
if err != nil {
return nil, errors.Errorf("error: %v, stderr: %s, stdout: %s", err, errb.String(), outb.String())
return nil, errors.Errorf("error: %v\nstderr: %sstdout: %s", err, errb.String(), outb.String())
}
return []byte(fmt.Sprintf("stderr: %s, stdout: %s", errb.String(), outb.String())), nil
return outb.Bytes(), nil
}
func (d *Dumper) getCR(crName string, namespace string) (crSecrets, error) {