@@ -31,6 +31,11 @@ import (
3131 "github.com/coreos/coreos-assembler/mantle/platform/conf"
3232 "github.com/coreos/coreos-assembler/mantle/util"
3333 "github.com/coreos/ignition/v2/config/v3_2/types"
34+ "github.com/coreos/pkg/capnslog"
35+ )
36+
37+ var (
38+ plog = capnslog .NewPackageLogger ("github.com/coreos/coreos-assembler/mantle" , "kola/tests/ignition/qemufailure" )
3439)
3540
3641func init () {
@@ -105,23 +110,25 @@ func verifyError(builder *platform.QemuBuilder, searchPattern string) error {
105110
106111 defer cancel ()
107112
113+ checkConsole := func (path string , searchPattern string ) error {
114+ // Expected initramfs failure, checking the console file to ensure
115+ // that it failed the expected way
116+ found , err := fileContainsPattern (path , searchPattern )
117+ if err != nil {
118+ return errors .Wrapf (err , "looking for pattern '%s' in file '%s' failed" , searchPattern , path )
119+ } else if ! found {
120+ return fmt .Errorf ("pattern '%s' in file '%s' not found" , searchPattern , path )
121+ }
122+ return nil
123+ }
124+
108125 errchan := make (chan error )
109126 go func () {
110127 resultingError := inst .WaitAll (ctx )
111128 if resultingError == nil {
112129 resultingError = fmt .Errorf ("ignition unexpectedly succeeded" )
113130 } else if resultingError == platform .ErrInitramfsEmergency {
114- // Expected initramfs failure, checking the console file to ensure
115- // that it failed the expected way
116- found , err := fileContainsPattern (builder .ConsoleFile , searchPattern )
117- if err != nil {
118- resultingError = errors .Wrapf (err , "looking for pattern '%s' in file '%s' failed" , searchPattern , builder .ConsoleFile )
119- } else if ! found {
120- resultingError = fmt .Errorf ("pattern '%s' in file '%s' not found" , searchPattern , builder .ConsoleFile )
121- } else {
122- // The expected case
123- resultingError = nil
124- }
131+ resultingError = checkConsole (builder .ConsoleFile , searchPattern )
125132 } else {
126133 resultingError = errors .Wrapf (resultingError , "expected initramfs emergency.target error" )
127134 }
@@ -133,17 +140,28 @@ func verifyError(builder *platform.QemuBuilder, searchPattern string) error {
133140 if err := inst .Kill (); err != nil {
134141 return errors .Wrapf (err , "failed to kill the vm instance" )
135142 }
136- // If somehow the journal dumping failed let's flag that. We
137- // just ignore errors here. This effort is only trying to help
143+ // The journal dumping can fail if the `com.coreos.ignition.journal`
144+ // device doesn't show up for some reason (race condition) [1].
145+ // Let's try to detect that case and check the console anyway for
146+ // the original failure we were looking for.
147+ //
148+ // We just ignore errors here. This effort is only trying to help
138149 // be more informative about why things failed. This "string"
139150 // we are searching for comes from ignition-virtio-dump-journal
140- searchPattern = "Didn't find virtio port /dev/virtio-ports/com.coreos.ignition.journal"
141- found , _ := fileContainsPattern (builder .ConsoleFile , searchPattern )
151+ // [1] https://github.com/coreos/fedora-coreos-tracker/issues/2019
152+ virtioPortSearchPattern := "Didn't find virtio port /dev/virtio-ports/com.coreos.ignition.journal"
153+ found , _ := fileContainsPattern (builder .ConsoleFile , virtioPortSearchPattern )
142154 if found {
143- return errors .Wrapf (ctx .Err (), "Journal dumping during emergency.target failed" )
144- } else {
145- return errors .Wrapf (ctx .Err (), "timed out waiting for initramfs error" )
155+ plog .Warning ("Journal dumping during emergency.target failed. Continuing best effort." )
156+ // Check the log even though there was a timeout
157+ if err := checkConsole (builder .ConsoleFile , searchPattern ); err == nil {
158+ // Even though there was a timeout we found the string
159+ // we wanted in the console log anyway. Let's just
160+ // take the win.
161+ return nil
162+ }
146163 }
164+ return errors .Wrapf (ctx .Err (), "timed out waiting for initramfs error" )
147165 case err := <- errchan :
148166 if err != nil {
149167 return err
0 commit comments