Skip to content

Commit 53526ee

Browse files
cgwaltersjlebon
authored andcommitted
kolet: Capture error messages from mkfifo
The Go `exec.Command` when used naively like this captures stderr and then it gets lost. It turned out with soft reboot it was this `mkfifo` that was failing but all we got is "Child process exited with code 1" but there are like 5 different processes on two different hosts that could be talking about, and we *really* thought it was talking about the code-under-test, not the framework setting it up.
1 parent 41133ea commit 53526ee

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

mantle/cmd/kolet/kolet.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ func initiateReboot(mark string) error {
259259
return nil
260260
}
261261

262+
func mkfifo(path string) error {
263+
c := exec.Command("mkfifo", path)
264+
c.Stderr = os.Stderr
265+
err := c.Run()
266+
if err != nil {
267+
return fmt.Errorf("creating fifo %s: %w", path, err)
268+
}
269+
return nil
270+
}
271+
262272
func runExtUnit(cmd *cobra.Command, args []string) error {
263273
rebootOff, _ := cmd.Flags().GetBool("deny-reboots")
264274
// Write the autopkgtest wrappers
@@ -276,7 +286,7 @@ func runExtUnit(cmd *cobra.Command, args []string) error {
276286

277287
// We want to prevent certain tests (like non-exclusive tests) from rebooting
278288
if !rebootOff {
279-
err := exec.Command("mkfifo", rebootRequestFifo).Run()
289+
err := mkfifo(rebootRequestFifo)
280290
if err != nil {
281291
return err
282292
}
@@ -366,7 +376,7 @@ func runReboot(cmd *cobra.Command, args []string) error {
366376

367377
mark := args[0]
368378
systemdjournal.Print(systemdjournal.PriInfo, "Requesting reboot with mark: %s", mark)
369-
err := exec.Command("mkfifo", kola.KoletRebootAckFifo).Run()
379+
err := mkfifo(kola.KoletRebootAckFifo)
370380
if err != nil {
371381
return err
372382
}

0 commit comments

Comments
 (0)