Skip to content

Commit

Permalink
fix: wait for udevd to be running before activating LVM
Browse files Browse the repository at this point in the history
Fixes #9505

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Oct 25, 2024
1 parent d4cb478 commit b7801df
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/app/machined/pkg/controllers/block/lvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import (

"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/gen/optional"
"github.com/siderolabs/go-cmd/pkg/cmd"
"go.uber.org/zap"

"github.com/siderolabs/talos/pkg/machinery/resources/block"
"github.com/siderolabs/talos/pkg/machinery/resources/v1alpha1"
)

// LVMActivationController activates LVM volumes when they are discovered by the block.DiscoveryController.
Expand All @@ -37,6 +40,12 @@ func (ctrl *LVMActivationController) Inputs() []controller.Input {
Type: block.DiscoveredVolumeType,
Kind: controller.InputWeak,
},
{
Namespace: v1alpha1.NamespaceName,
Type: v1alpha1.ServiceType,
ID: optional.Some("udevd"),
Kind: controller.InputWeak,
},
}
}

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

udevdService, err := safe.ReaderGetByID[*v1alpha1.Service](ctx, r, "udevd")
if err != nil && !state.IsNotFoundError(err) {
return fmt.Errorf("failed to get udevd service: %w", err)
}

if udevdService == nil {
logger.Debug("udevd service not registered yet")

continue
}

if !(udevdService.TypedSpec().Running && udevdService.TypedSpec().Healthy) {
logger.Debug("waiting for udevd service to be running and healthy")

continue
}

discoveredVolumes, err := safe.ReaderListAll[*block.DiscoveredVolume](ctx, r)
if err != nil {
return fmt.Errorf("failed to list discovered volumes: %w", err)
Expand Down

0 comments on commit b7801df

Please sign in to comment.