diff --git a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go index 8d14752161..ee0f6e7b93 100644 --- a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go +++ b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go @@ -1327,6 +1327,20 @@ func (i *InstallConfig) DiskMatchExpression() (*cel.Expression, error) { exprs = append(exprs, patternMatcherExpr(selector.Modalias, "modalias")) } + // disk.transport != "" (otherwise it might select e.g. DM devices) + exprs = append(exprs, + builder.NewCall( + builder.NextID(), + operators.NotEquals, + builder.NewSelect( + builder.NextID(), + builder.NewIdent(builder.NextID(), "disk"), + "transport", + ), + builder.NewLiteral(builder.NextID(), types.String("")), + ), + ) + if selector.Type != "" { switch selector.Type { case "nvme": // disk.transport == "nvme" @@ -1339,18 +1353,8 @@ func (i *InstallConfig) DiskMatchExpression() (*cel.Expression, error) { builder.NewIdent(builder.NextID(), "disk"), "rotational", )) - case "ssd": // disk.transport != "" && !disk.rotational + case "ssd": // !disk.rotational exprs = append(exprs, - builder.NewCall( - builder.NextID(), - operators.NotEquals, - builder.NewSelect( - builder.NextID(), - builder.NewIdent(builder.NextID(), "disk"), - "transport", - ), - builder.NewLiteral(builder.NextID(), types.String("")), - ), builder.NewCall( builder.NextID(), operators.LogicalNot, diff --git a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider_test.go b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider_test.go index 7328613c04..812db8320e 100644 --- a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider_test.go +++ b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider_test.go @@ -35,7 +35,7 @@ func TestInstallDiskSelector(t *testing.T) { }, }, - expected: `disk.size <= 262144u && !disk.readonly && !disk.cdrom`, + expected: `disk.size <= 262144u && disk.transport != "" && !disk.readonly && !disk.cdrom`, }, { name: "size and type", @@ -49,7 +49,8 @@ func TestInstallDiskSelector(t *testing.T) { Type: v1alpha1.InstallDiskType("nvme"), }, - expected: `disk.size == 1048576u && disk.transport == "nvme" && !disk.readonly && !disk.cdrom`, + expected: `disk.size == 1048576u && disk.transport != "" && disk.transport == "nvme" && !disk.readonly && +!disk.cdrom`, }, { name: "size and type and modalias", @@ -64,8 +65,8 @@ func TestInstallDiskSelector(t *testing.T) { Modalias: "pci:1234:5678*", }, - expected: `disk.size == 1048576u && glob("pci:1234:5678*", disk.modalias) && disk.rotational && -!disk.readonly && !disk.cdrom`, + expected: `disk.size == 1048576u && glob("pci:1234:5678*", disk.modalias) && disk.transport != "" && +disk.rotational && !disk.readonly && !disk.cdrom`, }, { name: "ssd",