mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Collect serial output when test fails in node e2e.
This commit is contained in:
parent
a2d5df40af
commit
6d4e457f1f
@ -350,6 +350,19 @@ func getTestArtifacts(host, testDir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteLog is a temporary function to make it possible to write log
|
||||||
|
// in the runner. This is used to collect serial console log.
|
||||||
|
// TODO(random-liu): Use the log-dump script in cluster e2e.
|
||||||
|
func WriteLog(host, filename, content string) error {
|
||||||
|
f, err := os.Create(filepath.Join(*resultsDir, host, filename))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
_, err = f.WriteString(content)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// getSSHCommand handles proper quoting so that multiple commands are executed in the same shell over ssh
|
// getSSHCommand handles proper quoting so that multiple commands are executed in the same shell over ssh
|
||||||
func getSSHCommand(sep string, args ...string) string {
|
func getSSHCommand(sep string, args ...string) string {
|
||||||
return fmt.Sprintf("'%s'", strings.Join(args, sep))
|
return fmt.Sprintf("'%s'", strings.Join(args, sep))
|
||||||
|
@ -449,7 +449,21 @@ func testImage(imageConfig *internalGCEImage, junitFilePrefix string) *TestResul
|
|||||||
// Only delete the files if we are keeping the instance and want it cleaned up.
|
// Only delete the files if we are keeping the instance and want it cleaned up.
|
||||||
// If we are going to delete the instance, don't bother with cleaning up the files
|
// If we are going to delete the instance, don't bother with cleaning up the files
|
||||||
deleteFiles := !*deleteInstances && *cleanup
|
deleteFiles := !*deleteInstances && *cleanup
|
||||||
return testHost(host, deleteFiles, junitFilePrefix, *setupNode, ginkgoFlagsStr)
|
|
||||||
|
result := testHost(host, deleteFiles, junitFilePrefix, *setupNode, ginkgoFlagsStr)
|
||||||
|
// This is a temporary solution to collect serial node serial log. Only port 1 contains useful information.
|
||||||
|
// TODO(random-liu): Extract out and unify log collection logic with cluste e2e.
|
||||||
|
serialPortOutput, err := computeService.Instances.GetSerialPortOutput(*project, *zone, host).Port(1).Do()
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Failed to collect serial output from node %q: %v", host, err)
|
||||||
|
} else {
|
||||||
|
logFilename := "serial-1.log"
|
||||||
|
err := remote.WriteLog(host, logFilename, serialPortOutput.Contents)
|
||||||
|
if err != nil {
|
||||||
|
glog.Errorf("Failed to write serial output from node %q to %q: %v", host, logFilename, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provision a gce instance using image
|
// Provision a gce instance using image
|
||||||
|
Loading…
Reference in New Issue
Block a user