Skip to content

Commit a28a74f

Browse files
committed
kola/multipath: wait for systemd firstboot target
Although `mpath-var-lib-containers.service` is set to only run on first boot, it sometime runs twice when the system reboots too early. Sometimes, in low load CI environement, the reboot in this test happens before systemd's `first-boot-complete.target` is reached. This make `ConditionFirstBoot` to still be true at the next boot, causing the mpath service to fail, because it already ran during the actual first boot. A previous attempt[1] at fixing this improved the flake but this happened again and i noticed that systemd didn't reach this target before the reboot: `Reached target first-boot-complete.target - First Boot Complete` is only shown after the second boot in the logs. Likely fixes coreos/rhel-coreos-config#66 [1] abd0c18
1 parent c0c9824 commit a28a74f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

mantle/kola/tests/misc/multipath.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
package misc
1616

1717
import (
18+
"fmt"
1819
"strings"
20+
"time"
1921

2022
coreosarch "github.com/coreos/stream-metadata-go/arch"
2123

2224
"github.com/coreos/coreos-assembler/mantle/kola/cluster"
2325
"github.com/coreos/coreos-assembler/mantle/kola/register"
2426
"github.com/coreos/coreos-assembler/mantle/platform"
2527
"github.com/coreos/coreos-assembler/mantle/platform/conf"
28+
"github.com/coreos/coreos-assembler/mantle/util"
2629
)
2730

2831
var (
@@ -168,6 +171,8 @@ func verifyMultipath(c cluster.TestCluster, m platform.Machine, path string) {
168171
func runMultipathDay1(c cluster.TestCluster) {
169172
m := c.Machines()[0]
170173
verifyMultipathBoot(c, m)
174+
// wait until first-boot-complete.target is reached
175+
waitForCompleteFirstboot(c)
171176
if err := m.Reboot(); err != nil {
172177
c.Fatalf("Failed to reboot the machine: %v", err)
173178
}
@@ -188,8 +193,28 @@ func runMultipathDay2(c cluster.TestCluster) {
188193
func runMultipathPartition(c cluster.TestCluster) {
189194
m := c.Machines()[0]
190195
verifyMultipath(c, m, "/var/lib/containers")
196+
// wait until first-boot-complete.target is reached
197+
waitForCompleteFirstboot(c)
191198
if err := m.Reboot(); err != nil {
192199
c.Fatalf("Failed to reboot the machine: %v", err)
193200
}
194201
verifyMultipath(c, m, "/var/lib/containers")
195202
}
203+
204+
func waitForCompleteFirstboot(c cluster.TestCluster) {
205+
m := c.Machines()[0]
206+
err := util.Retry(6, 10*time.Second, func() error {
207+
208+
firstboot_target, err := c.SSH(m, "systemctl is-active first-boot-complete.target")
209+
210+
if err != nil {
211+
return err
212+
} else if string(firstboot_target) == "inactive" {
213+
return fmt.Errorf("first-boot-complete.target is not reached: %s.", string(firstboot_target))
214+
}
215+
return nil
216+
})
217+
if err != nil {
218+
c.Fatalf("Timed out while waiting for first-boot-complete.target to be ready: %v", err)
219+
}
220+
}

0 commit comments

Comments
 (0)