mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
Copy container logs for easier debugging
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
9516a25ce4
commit
f96d83af66
@ -207,9 +207,11 @@ func getTestArtifacts(host, testDir string) error {
|
||||
if err := os.MkdirAll(logPath, 0755); err != nil {
|
||||
return fmt.Errorf("failed to create log directory %q: %w", logPath, err)
|
||||
}
|
||||
// Copy logs to artifacts/hostname
|
||||
if _, err := runSSHCommand(host, "scp", "-r", fmt.Sprintf("%s:%s/results/*.log", GetHostnameOrIP(host), testDir), logPath); err != nil {
|
||||
return err
|
||||
// Copy logs (if any) to artifacts/hostname
|
||||
if _, err := SSH(host, "ls", fmt.Sprintf("%s:%s/results/*.log", GetHostnameOrIP(host), testDir)); err == nil {
|
||||
if _, err := runSSHCommand(host, "scp", "-r", fmt.Sprintf("%s:%s/results/*.log", GetHostnameOrIP(host), testDir), logPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Copy json files (if any) to artifacts.
|
||||
if _, err := SSH(host, "ls", fmt.Sprintf("%s/results/*.json", testDir)); err == nil {
|
||||
@ -217,12 +219,19 @@ func getTestArtifacts(host, testDir string) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Copy junit results (if any) to artifacts
|
||||
if _, err := SSH(host, "ls", fmt.Sprintf("%s/results/junit*", testDir)); err == nil {
|
||||
// Copy junit (if any) to the top of artifacts
|
||||
if _, err = runSSHCommand(host, "scp", fmt.Sprintf("%s:%s/results/junit*", GetHostnameOrIP(host), testDir), *resultsDir); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Copy container logs to artifacts/hostname
|
||||
if _, err := SSH(host, "chmod", "-R", "a+r", "/var/log/pods"); err == nil {
|
||||
if _, err = runSSHCommand(host, "scp", "-r", fmt.Sprintf("%s:/var/log/pods/", GetHostnameOrIP(host)), logPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user