Skip to content

Commit

Permalink
fix: make Talos META partition match more precise
Browse files Browse the repository at this point in the history
Fixes #9786

Match on exact expected size otherwise as `META` name is common, Talos
might find `META` where it shouldn't be.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Nov 27, 2024
1 parent 9adaf7f commit 2a9130a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions internal/app/machined/pkg/controllers/block/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,7 @@ func (ctrl *DiscoveryController) rescan(ctx context.Context, r controller.Runtim
dv.TypedSpec().Parent = id
dv.TypedSpec().ParentDevPath = filepath.Join("/dev", id)

if nested.ProbedSize != 0 {
dv.TypedSpec().SetSize(nested.ProbedSize)
} else {
dv.TypedSpec().SetSize(nested.PartitionSize)
}
dv.TypedSpec().SetSize(nested.PartitionSize)

dv.TypedSpec().SectorSize = info.SectorSize
dv.TypedSpec().IOSize = info.IOSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func labelVolumeMatchAndNonEmpty(label string) cel.Expression {
}

func metaMatch() cel.Expression {
return cel.MustExpression(cel.ParseBooleanExpression(fmt.Sprintf("volume.partition_label == '%s' && volume.name in ['', 'talosmeta']", constants.MetaPartitionLabel), celenv.VolumeLocator()))
return cel.MustExpression(cel.ParseBooleanExpression(fmt.Sprintf("volume.partition_label == '%s' && volume.name in ['', 'talosmeta'] && volume.size == 1048576u", constants.MetaPartitionLabel), celenv.VolumeLocator())) //nolint:lll
}

func systemDiskMatch() cel.Expression {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (suite *VolumeConfigSuite) TestReconcileDefaults() {
locator, err := r.TypedSpec().Locator.Match.MarshalText()
asrt.NoError(err)

asrt.Equal(`volume.partition_label == "META" && volume.name in ["", "talosmeta"]`, string(locator))
asrt.Equal(`volume.partition_label == "META" && volume.name in ["", "talosmeta"] && volume.size == 1048576u`, string(locator))
})
ctest.AssertResource(suite, constants.StatePartitionLabel, func(r *block.VolumeConfig, asrt *assert.Assertions) {
asrt.NotEmpty(r.TypedSpec().Provisioning)
Expand Down

0 comments on commit 2a9130a

Please sign in to comment.