Skip to content

Commit

Permalink
MGMT-13445: Update Assisted Installer with the new LVMS requirements
Browse files Browse the repository at this point in the history
With openshift/lvm-operator#303, the resource requirements for LVMS has been reduced. Based on this reduction, this PR adjusts the LVMS requirement on Assisted Installer solving https://issues.redhat.com/browse/MGMT-13445.

Signed-off-by: Suleyman Akbas <sakbas@redhat.com>
  • Loading branch information
suleymanakbas91 committed Feb 28, 2023
1 parent e563fc6 commit 6d6a9d7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/operators/lvm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
10 changes: 9 additions & 1 deletion internal/operators/lvm/lvm_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
11 changes: 8 additions & 3 deletions internal/operators/lvm/lvm_operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
),
)
})
Expand Down
74 changes: 68 additions & 6 deletions subsystem/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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, &params)
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, &params)
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())
})
})

Expand Down

0 comments on commit 6d6a9d7

Please sign in to comment.