Skip to content

Commit 2d95b49

Browse files
Hiro TamadaHiro Tamada
authored andcommitted
fix: add device polling for config disk to prevent race condition
The device polling optimization waited only for /dev/vda and /dev/vdb, but /dev/vdc (config disk) was mounted without polling. This could cause mount failures if vdc appeared slightly after vdb. Now readConfig() polls for /dev/vdc before attempting to mount it, consistent with how we handle the other block devices.
1 parent 73a7252 commit 2d95b49

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎lib/system/init/config.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"os/exec"
8+
"time"
89

910
"github.com/kernel/hypeman/lib/vmconfig"
1011
)
@@ -19,6 +20,11 @@ func readConfig(log *Logger) (*vmconfig.Config, error) {
1920
return nil, fmt.Errorf("mkdir config mount: %w", err)
2021
}
2122

23+
// Wait for config disk to be ready (polls every 10ms, 2s timeout)
24+
if err := waitForDevice("/dev/vdc", 2*time.Second); err != nil {
25+
return nil, fmt.Errorf("wait for config device: %w", err)
26+
}
27+
2228
// Mount config disk (/dev/vdc) read-only
2329
cmd := exec.Command("/bin/mount", "-o", "ro", "/dev/vdc", configMount)
2430
if output, err := cmd.CombinedOutput(); err != nil {

0 commit comments

Comments
 (0)