diff --git a/internal/operators/lvm/config.go b/internal/operators/lvm/config.go index d2d52bd44f9..02d2043f464 100644 --- a/internal/operators/lvm/config.go +++ b/internal/operators/lvm/config.go @@ -16,7 +16,7 @@ const ( type Config struct { LvmCPUPerHost int64 `envconfig:"LVM_CPU_PER_HOST" default:"1"` - LvmMemoryPerHostMiB int64 `envconfig:"LVM_MEMORY_PER_HOST_MIB" default:"1200"` + LvmMemoryPerHostMiB int64 `envconfig:"LVM_MEMORY_PER_HOST_MIB" default:"400"` LvmMinOpenshiftVersion string `envconfig:"LVM_MIN_OPENSHIFT_VERSION" default:"4.11.0"` } diff --git a/internal/operators/lvm/lvm_operator.go b/internal/operators/lvm/lvm_operator.go index bbde47918f8..de30558f65a 100644 --- a/internal/operators/lvm/lvm_operator.go +++ b/internal/operators/lvm/lvm_operator.go @@ -163,7 +163,7 @@ func (o *operator) GetPreflightRequirements(context context.Context, cluster *co Master: &models.HostTypeHardwareRequirements{ Quantitative: &models.ClusterHostRequirementsDetails{ CPUCores: o.config.LvmCPUPerHost, - RAMMib: o.config.LvmMemoryPerHostMiB, + RAMMib: o.getLvmMemoryPerHostMib(cluster), }, Qualitative: []string{ "At least 1 non-installation disk with no partitions or filesystems", @@ -179,3 +179,11 @@ func (o *operator) GetPreflightRequirements(context context.Context, cluster *co func (o *operator) GetSupportedArchitectures() []string { return []string{common.X86CPUArchitecture, common.ARM64CPUArchitecture} } + +func (o *operator) getLvmMemoryPerHostMib(cluster *common.Cluster) int64 { + if greaterOrEqual, _ := common.BaseVersionGreaterOrEqual("4.13", cluster.OpenshiftVersion); !greaterOrEqual { + return 1200 // Value before resource usage reduction work on lvms in 4.13 + } + + return o.config.LvmMemoryPerHostMiB +} diff --git a/internal/operators/lvm/lvm_operator_test.go b/internal/operators/lvm/lvm_operator_test.go index e9427aae217..b4a005db76a 100644 --- a/internal/operators/lvm/lvm_operator_test.go +++ b/internal/operators/lvm/lvm_operator_test.go @@ -60,10 +60,15 @@ var _ = Describe("Lvm Operator", func() { res, _ := operator.GetHostRequirements(ctx, cluster, host) Expect(res).Should(Equal(expectedResult)) }, - table.Entry("host", - &common.Cluster{Cluster: models.Cluster{Hosts: []*models.Host{hostWithSufficientResources}}}, + table.Entry("version is 4.13", + &common.Cluster{Cluster: models.Cluster{OpenshiftVersion: "4.13.0", Hosts: []*models.Host{hostWithSufficientResources}}}, + hostWithSufficientResources, + &models.ClusterHostRequirementsDetails{CPUCores: operator.config.LvmCPUPerHost, RAMMib: 400}, + ), + table.Entry("version is 4.12", + &common.Cluster{Cluster: models.Cluster{OpenshiftVersion: "4.12.0", Hosts: []*models.Host{hostWithSufficientResources}}}, hostWithSufficientResources, - &models.ClusterHostRequirementsDetails{CPUCores: operator.config.LvmCPUPerHost, RAMMib: operator.config.LvmMemoryPerHostMiB}, + &models.ClusterHostRequirementsDetails{CPUCores: operator.config.LvmCPUPerHost, RAMMib: 1200}, ), ) }) diff --git a/subsystem/cluster_test.go b/subsystem/cluster_test.go index 4ffdfaaaaae..0874e81f202 100644 --- a/subsystem/cluster_test.go +++ b/subsystem/cluster_test.go @@ -3670,10 +3670,6 @@ var _ = Describe("Preflight Cluster Requirements", func() { CPUCores: 6, RAMMib: conversions.GibToMib(19), } - masterLVMRequirements = models.ClusterHostRequirementsDetails{ - CPUCores: 1, - RAMMib: 1200, - } ) BeforeEach(func() { @@ -3713,13 +3709,79 @@ var _ = Describe("Preflight Cluster Requirements", func() { case cnv.Operator.Name: Expect(*op.Requirements.Master.Quantitative).To(BeEquivalentTo(masterCNVRequirements)) Expect(*op.Requirements.Worker.Quantitative).To(BeEquivalentTo(workerCNVRequirements)) + default: + Fail("Unexpected operator") + } + } + }) +}) + +var _ = Describe("Preflight Cluster Requirements for lvms", func() { + var ( + ctx = context.Background() + masterLVMRequirementsBefore4_13 = models.ClusterHostRequirementsDetails{ + CPUCores: 1, + RAMMib: 1200, + } + masterLVMRequirements = models.ClusterHostRequirementsDetails{ + CPUCores: 1, + RAMMib: 400, + } + ) + It("should be reported for 4.12 cluster", func() { + var cluster, err = userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ + NewClusterParams: &models.ClusterCreateParams{ + Name: swag.String("test-cluster"), + OpenshiftVersion: swag.String("4.12.0"), + PullSecret: swag.String(pullSecret), + BaseDNSDomain: "example.com", + VipDhcpAllocation: swag.Bool(true), + }, + }) + Expect(err).ToNot(HaveOccurred()) + clusterID := *cluster.GetPayload().ID + params := installer.V2GetPreflightRequirementsParams{ClusterID: clusterID} + + response, err := userBMClient.Installer.V2GetPreflightRequirements(ctx, ¶ms) + Expect(err).ToNot(HaveOccurred()) + requirements := response.GetPayload() + for _, op := range requirements.Operators { + switch op.OperatorName { + case lvm.Operator.Name: + Expect(*op.Requirements.Master.Quantitative).To(BeEquivalentTo(masterLVMRequirementsBefore4_13)) + Expect(*op.Requirements.Worker.Quantitative).To(BeEquivalentTo(models.ClusterHostRequirementsDetails{})) + } + } + _, err = userBMClient.Installer.V2DeregisterCluster(ctx, &installer.V2DeregisterClusterParams{ClusterID: clusterID}) + Expect(err).NotTo(HaveOccurred()) + }) + + It("should be reported for 4.13 cluster", func() { + var cluster, err = userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ + NewClusterParams: &models.ClusterCreateParams{ + Name: swag.String("test-cluster"), + OpenshiftVersion: swag.String("4.13.0"), + PullSecret: swag.String(pullSecret), + BaseDNSDomain: "example.com", + VipDhcpAllocation: swag.Bool(true), + }, + }) + Expect(err).ToNot(HaveOccurred()) + clusterID := *cluster.GetPayload().ID + params := installer.V2GetPreflightRequirementsParams{ClusterID: clusterID} + + response, err := userBMClient.Installer.V2GetPreflightRequirements(ctx, ¶ms) + Expect(err).ToNot(HaveOccurred()) + requirements := response.GetPayload() + for _, op := range requirements.Operators { + switch op.OperatorName { case lvm.Operator.Name: Expect(*op.Requirements.Master.Quantitative).To(BeEquivalentTo(masterLVMRequirements)) Expect(*op.Requirements.Worker.Quantitative).To(BeEquivalentTo(models.ClusterHostRequirementsDetails{})) - default: - Fail("Unexpected operator") } } + _, err = userBMClient.Installer.V2DeregisterCluster(ctx, &installer.V2DeregisterClusterParams{ClusterID: clusterID}) + Expect(err).NotTo(HaveOccurred()) }) })