fix: udevd rules trigger
Fix udevd not triggering rules properly. This also fixes an issue with go-blockdevice not resolving symlinks. Fixes: #7117 Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
parent
9b36bb613b
commit
014008ea25
2
go.mod
2
go.mod
@ -94,7 +94,7 @@ require (
|
||||
github.com/siderolabs/discovery-api v0.1.2
|
||||
github.com/siderolabs/discovery-client v0.1.4
|
||||
github.com/siderolabs/gen v0.4.4
|
||||
github.com/siderolabs/go-blockdevice v0.4.4
|
||||
github.com/siderolabs/go-blockdevice v0.4.5
|
||||
github.com/siderolabs/go-circular v0.1.0
|
||||
github.com/siderolabs/go-cmd v0.1.1
|
||||
github.com/siderolabs/go-debug v0.2.2
|
||||
|
4
go.sum
4
go.sum
@ -1154,8 +1154,8 @@ github.com/siderolabs/gen v0.4.4 h1:iShHEAfb3i9jaeDXjT11TepsjdgGoChBKbUuUz4CqnQ=
|
||||
github.com/siderolabs/gen v0.4.4/go.mod h1:wS8tFq7sn5vqKAuyS30vJUig3tX5v6q79VG4KfUnILM=
|
||||
github.com/siderolabs/go-api-signature v0.2.2 h1:C5tUzuFsJYidpYyVfJGYpgQwETglA8B62ET4obkLDGE=
|
||||
github.com/siderolabs/go-api-signature v0.2.2/go.mod h1:9jSRiJsuKyf6b/hyKcBgCZXvu7xGJ+RiCQQAVraGdN0=
|
||||
github.com/siderolabs/go-blockdevice v0.4.4 h1:iDxX0nx7jtV/bKXHOlh7oiVwhOpAEqwjiyddAaKVIuA=
|
||||
github.com/siderolabs/go-blockdevice v0.4.4/go.mod h1:4PeOuk71pReJj1JQEXDE7kIIQJPVe8a+HZQa+qjxSEA=
|
||||
github.com/siderolabs/go-blockdevice v0.4.5 h1:NgpR9XTl/N7WeL59QHBsseDD0Nb8Y2nel+W3u7xHIvY=
|
||||
github.com/siderolabs/go-blockdevice v0.4.5/go.mod h1:4PeOuk71pReJj1JQEXDE7kIIQJPVe8a+HZQa+qjxSEA=
|
||||
github.com/siderolabs/go-circular v0.1.0 h1:zpBJNUbCZSh0odZxA4Dcj0d3ShLLR2WxKW6hTdAtoiE=
|
||||
github.com/siderolabs/go-circular v0.1.0/go.mod h1:14XnLf/I3J0VjzTgmwWNGjp58/bdIi4zXppAEx8plfw=
|
||||
github.com/siderolabs/go-cmd v0.1.1 h1:nTouZUSxLeiiEe7hFexSVvaTsY/3O8k1s08BxPRrsps=
|
||||
|
@ -767,6 +767,7 @@ func StartContainerd(runtime.Sequence, any) (runtime.TaskExecutionFunc, string)
|
||||
}
|
||||
|
||||
// WriteUdevRules is the task that writes udev rules to a udev rules file.
|
||||
// TODO: frezbo: move this to controller based since writing udev rules doesn't need a restart.
|
||||
func WriteUdevRules(runtime.Sequence, any) (runtime.TaskExecutionFunc, string) {
|
||||
return func(ctx context.Context, logger *log.Logger, r runtime.Runtime) (err error) {
|
||||
rules := r.Config().Machine().Udev().Rules()
|
||||
@ -783,11 +784,24 @@ func WriteUdevRules(runtime.Sequence, any) (runtime.TaskExecutionFunc, string) {
|
||||
}
|
||||
|
||||
if len(rules) > 0 {
|
||||
if err := system.Services(r).Stop(ctx, "udevd"); err != nil {
|
||||
if _, err := cmd.RunContext(ctx, "/sbin/udevadm", "control", "--reload"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return system.Services(r).Start("udevd")
|
||||
if _, err := cmd.RunContext(ctx, "/sbin/udevadm", "trigger", "--type=devices", "--action=add"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := cmd.RunContext(ctx, "/sbin/udevadm", "trigger", "--type=subsystems", "--action=add"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// This ensures that `udevd` finishes processing kernel events, triggered by
|
||||
// `udevd trigger`, to prevent a race condition when a user specifies a path
|
||||
// under `/dev/disk/*` in any disk definitions.
|
||||
_, err := cmd.RunContext(ctx, "/sbin/udevadm", "settle", "--timeout=50")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -43,8 +43,6 @@ func (c *Udevd) PreFunc(ctx context.Context, r runtime.Runtime) error {
|
||||
"--update",
|
||||
)
|
||||
|
||||
c.triggered = false
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@ -102,9 +100,9 @@ func (c *Udevd) HealthFunc(runtime.Runtime) health.Check {
|
||||
}
|
||||
|
||||
// udevadm trigger returns with an exit code of 0 even if udevd is not fully running,
|
||||
// so running `udevadm control --start-exec-queue` to ensure that udevd is fully initialized
|
||||
// so running `udevadm control --reload` to ensure that udevd is fully initialized
|
||||
// which returns an exit code of 2 if udevd is not running. This complementes the previous check
|
||||
if _, err := cmd.RunContext(ctx, "/sbin/udevadm", "control", "--start-exec-queue"); err != nil {
|
||||
if _, err := cmd.RunContext(ctx, "/sbin/udevadm", "control", "--reload"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ require (
|
||||
github.com/siderolabs/crypto v0.4.0
|
||||
github.com/siderolabs/gen v0.4.4
|
||||
github.com/siderolabs/go-api-signature v0.2.2
|
||||
github.com/siderolabs/go-blockdevice v0.4.4
|
||||
github.com/siderolabs/go-blockdevice v0.4.5
|
||||
github.com/siderolabs/go-debug v0.2.2
|
||||
github.com/siderolabs/go-pointer v1.0.0
|
||||
github.com/siderolabs/net v0.4.0
|
||||
|
@ -114,8 +114,8 @@ github.com/siderolabs/gen v0.4.4 h1:iShHEAfb3i9jaeDXjT11TepsjdgGoChBKbUuUz4CqnQ=
|
||||
github.com/siderolabs/gen v0.4.4/go.mod h1:wS8tFq7sn5vqKAuyS30vJUig3tX5v6q79VG4KfUnILM=
|
||||
github.com/siderolabs/go-api-signature v0.2.2 h1:C5tUzuFsJYidpYyVfJGYpgQwETglA8B62ET4obkLDGE=
|
||||
github.com/siderolabs/go-api-signature v0.2.2/go.mod h1:9jSRiJsuKyf6b/hyKcBgCZXvu7xGJ+RiCQQAVraGdN0=
|
||||
github.com/siderolabs/go-blockdevice v0.4.4 h1:iDxX0nx7jtV/bKXHOlh7oiVwhOpAEqwjiyddAaKVIuA=
|
||||
github.com/siderolabs/go-blockdevice v0.4.4/go.mod h1:4PeOuk71pReJj1JQEXDE7kIIQJPVe8a+HZQa+qjxSEA=
|
||||
github.com/siderolabs/go-blockdevice v0.4.5 h1:NgpR9XTl/N7WeL59QHBsseDD0Nb8Y2nel+W3u7xHIvY=
|
||||
github.com/siderolabs/go-blockdevice v0.4.5/go.mod h1:4PeOuk71pReJj1JQEXDE7kIIQJPVe8a+HZQa+qjxSEA=
|
||||
github.com/siderolabs/go-debug v0.2.2 h1:c8styCvp+MO0oPO8q4N1CKSF3fVuAT0qnuUIeZ/BiW0=
|
||||
github.com/siderolabs/go-debug v0.2.2/go.mod h1:c/wMqY6+djxwrwEg1eg3kaTeZIfq6OUlEHAMreo1VV0=
|
||||
github.com/siderolabs/go-pointer v1.0.0 h1:6TshPKep2doDQJAAtHUuHWXbca8ZfyRySjSBT/4GsMU=
|
||||
|
Loading…
x
Reference in New Issue
Block a user