Skip to content

Commit b7801df

Browse files
committed
fix: wait for udevd to be running before activating LVM
Fixes #9505 Signed-off-by: Andrey Smirnov <[email protected]>
1 parent d4cb478 commit b7801df

File tree

1 file changed

+26
-0
lines changed
  • internal/app/machined/pkg/controllers/block

1 file changed

+26
-0
lines changed

internal/app/machined/pkg/controllers/block/lvm.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import (
1111

1212
"github.com/cosi-project/runtime/pkg/controller"
1313
"github.com/cosi-project/runtime/pkg/safe"
14+
"github.com/cosi-project/runtime/pkg/state"
1415
"github.com/hashicorp/go-multierror"
16+
"github.com/siderolabs/gen/optional"
1517
"github.com/siderolabs/go-cmd/pkg/cmd"
1618
"go.uber.org/zap"
1719

1820
"github.com/siderolabs/talos/pkg/machinery/resources/block"
21+
"github.com/siderolabs/talos/pkg/machinery/resources/v1alpha1"
1922
)
2023

2124
// LVMActivationController activates LVM volumes when they are discovered by the block.DiscoveryController.
@@ -37,6 +40,12 @@ func (ctrl *LVMActivationController) Inputs() []controller.Input {
3740
Type: block.DiscoveredVolumeType,
3841
Kind: controller.InputWeak,
3942
},
43+
{
44+
Namespace: v1alpha1.NamespaceName,
45+
Type: v1alpha1.ServiceType,
46+
ID: optional.Some("udevd"),
47+
Kind: controller.InputWeak,
48+
},
4049
}
4150
}
4251

@@ -64,6 +73,23 @@ func (ctrl *LVMActivationController) Run(ctx context.Context, r controller.Runti
6473
case <-r.EventCh():
6574
}
6675

76+
udevdService, err := safe.ReaderGetByID[*v1alpha1.Service](ctx, r, "udevd")
77+
if err != nil && !state.IsNotFoundError(err) {
78+
return fmt.Errorf("failed to get udevd service: %w", err)
79+
}
80+
81+
if udevdService == nil {
82+
logger.Debug("udevd service not registered yet")
83+
84+
continue
85+
}
86+
87+
if !(udevdService.TypedSpec().Running && udevdService.TypedSpec().Healthy) {
88+
logger.Debug("waiting for udevd service to be running and healthy")
89+
90+
continue
91+
}
92+
6793
discoveredVolumes, err := safe.ReaderListAll[*block.DiscoveredVolume](ctx, r)
6894
if err != nil {
6995
return fmt.Errorf("failed to list discovered volumes: %w", err)

0 commit comments

Comments
 (0)