Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MGMT-17080: enable infrastructure operator when MCE and storage opera…
…tors are selected (#6037) Signed-off-by: Riccardo Piccoli <rpiccoli@redhat.com>
- Loading branch information
Showing
46 changed files
with
7,663 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package common | ||
|
||
import ( | ||
"github.com/openshift/assisted-service/models" | ||
"github.com/openshift/assisted-service/pkg/conversions" | ||
) | ||
|
||
// Returns count for disks that are not installion disk and fulfill size requirements (eligible disks) and | ||
// disks that are not installation disk (available disks) | ||
func NonInstallationDiskCount(disks []*models.Disk, installationDiskID string, minSizeGB int64) (int64, int64) { | ||
var eligibleDisks int64 | ||
var availableDisks int64 | ||
|
||
for _, disk := range disks { | ||
if (disk.DriveType == models.DriveTypeSSD || disk.DriveType == models.DriveTypeHDD) && installationDiskID != disk.ID && disk.SizeBytes != 0 { | ||
if disk.SizeBytes >= conversions.GbToBytes(minSizeGB) { | ||
eligibleDisks++ | ||
} else { | ||
availableDisks++ | ||
} | ||
} | ||
} | ||
return eligibleDisks, availableDisks | ||
} | ||
|
||
func HasOperator(operators []*models.MonitoredOperator, operatorName string) bool { | ||
for _, o := range operators { | ||
if o.Name == operatorName { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package common_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/ginkgo/extensions/table" | ||
. "github.com/onsi/gomega" | ||
"github.com/openshift/assisted-service/internal/operators/common" | ||
"github.com/openshift/assisted-service/internal/operators/mce" | ||
"github.com/openshift/assisted-service/internal/operators/odf" | ||
"github.com/openshift/assisted-service/models" | ||
"github.com/openshift/assisted-service/pkg/conversions" | ||
) | ||
|
||
var _ = DescribeTable( | ||
"Get valid disk count", | ||
func(disks []*models.Disk, diskID string, minSize, expectedEligibleDisks, expectedAvailableDisks int64) { | ||
eligibleDisks, availableDisks := common.NonInstallationDiskCount(disks, diskID, minSize) | ||
Expect(eligibleDisks).To(Equal(expectedEligibleDisks)) | ||
Expect(availableDisks).To(Equal(expectedAvailableDisks)) | ||
}, | ||
Entry("no disk provided", []*models.Disk{}, "", int64(0), int64(0), int64(0)), | ||
Entry("no valid disk provided", []*models.Disk{ | ||
{SizeBytes: 20 * conversions.GB, DriveType: models.DriveTypeUnknown, ID: "/dev/disk/by-id/disk-1"}, | ||
{SizeBytes: 20 * conversions.GB, DriveType: models.DriveTypeVirtual, ID: "/dev/disk/by-id/disk-2"}, | ||
}, "", int64(0), int64(0), int64(0)), | ||
Entry("valid disk provided, but wrong size", []*models.Disk{ | ||
{SizeBytes: 20 * conversions.GB, DriveType: models.DriveTypeSSD, ID: "/dev/disk/by-id/disk-1"}, | ||
{SizeBytes: 20 * conversions.GB, DriveType: models.DriveTypeSSD, ID: "/dev/disk/by-id/disk-2"}, | ||
}, "", int64(25), int64(0), int64(2)), | ||
Entry("only one valid disk provided with the right size, but chosen for install", []*models.Disk{ | ||
{SizeBytes: 20 * conversions.GB, DriveType: models.DriveTypeSSD, ID: "/dev/disk/by-id/disk-1"}, | ||
{SizeBytes: 200 * conversions.GB, DriveType: models.DriveTypeSSD, ID: "/dev/disk/by-id/disk-2"}, | ||
}, "/dev/disk/by-id/disk-2", int64(25), int64(0), int64(1)), | ||
Entry("only one valid disk provided with the right size", []*models.Disk{ | ||
{SizeBytes: 50 * conversions.GB, DriveType: models.DriveTypeHDD, ID: "/dev/disk/by-id/disk-1"}, | ||
{SizeBytes: 200 * conversions.GB, DriveType: models.DriveTypeSSD, ID: "/dev/disk/by-id/disk-2"}, | ||
}, "/dev/disk/by-id/disk-2", int64(25), int64(1), int64(0)), | ||
Entry("two valid disks provided with the right size", []*models.Disk{ | ||
{SizeBytes: 50 * conversions.GB, DriveType: models.DriveTypeHDD, ID: "/dev/disk/by-id/disk-1"}, | ||
{SizeBytes: 200 * conversions.GB, DriveType: models.DriveTypeSSD, ID: "/dev/disk/by-id/disk-2"}, | ||
{SizeBytes: 50 * conversions.GB, DriveType: models.DriveTypeSSD, ID: "/dev/disk/by-id/disk-3"}, | ||
}, "/dev/disk/by-id/disk-2", int64(25), int64(2), int64(0)), | ||
) | ||
|
||
var _ = DescribeTable( | ||
"has operator", | ||
func(operators []*models.MonitoredOperator, operatorName string, isExpected bool) { | ||
found := common.HasOperator(operators, operatorName) | ||
Expect(found).To(Equal(isExpected)) | ||
}, | ||
Entry("no operators", []*models.MonitoredOperator{}, mce.Operator.Name, false), | ||
Entry("not matching any operator", []*models.MonitoredOperator{&odf.Operator}, mce.Operator.Name, false), | ||
Entry("matching a operator", []*models.MonitoredOperator{&odf.Operator, &mce.Operator}, mce.Operator.Name, true), | ||
) | ||
|
||
func TestHandler(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Operators common test suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,17 @@ | ||
package lvm | ||
|
||
import ( | ||
"github.com/openshift/assisted-service/models" | ||
) | ||
|
||
const ( | ||
// LvmMinOpenshiftVersion is the minimum OCP version in which lvmo is supported | ||
// Any changes here should be updated at line 16 too. | ||
LvmoMinOpenshiftVersion string = "4.11.0" | ||
LvmsMinOpenshiftVersion4_12 string = "4.12.0" | ||
LvmsMinOpenshiftVersion_ForNewResourceRequirements string = "4.13.0" | ||
LvmMinMultiNodeSupportVersion string = "4.15.0" | ||
|
||
LvmoSubscriptionName string = "odf-lvm-operator" | ||
LvmsSubscriptionName string = "lvms-operator" | ||
|
||
// LvmsMemoryRequirement int64 = 400 | ||
// LvmsMemoryRequirementBefore4_13 int64 = 1200 | ||
|
||
) | ||
|
||
type Config struct { | ||
LvmCPUPerHost int64 `envconfig:"LVM_CPU_PER_HOST" default:"1"` | ||
LvmMemoryPerHostMiB int64 `envconfig:"LVM_MEMORY_PER_HOST_MIB" default:"400"` | ||
LvmMemoryPerHostMiBBefore4_13 int64 `envconfig:"LVM_MEMORY_PER_HOST_MIB" default:"1200"` | ||
LvmMinOpenshiftVersion string `envconfig:"LVM_MIN_OPENSHIFT_VERSION" default:"4.11.0"` | ||
} | ||
|
||
// count all disks of drive type ssd or hdd | ||
func (o *operator) getValidDiskCount(disks []*models.Disk, installationDiskID string) int64 { | ||
var countDisks int64 | ||
|
||
for _, disk := range disks { | ||
if (disk.DriveType == models.DriveTypeSSD || disk.DriveType == models.DriveTypeHDD) && installationDiskID != disk.ID && disk.SizeBytes != 0 { | ||
countDisks++ | ||
} | ||
} | ||
return countDisks | ||
LvmCPUPerHost int64 `envconfig:"LVM_CPU_PER_HOST" default:"1"` | ||
LvmMemoryPerHostMiB int64 `envconfig:"LVM_MEMORY_PER_HOST_MIB" default:"400"` | ||
LvmMemoryPerHostMiBBefore4_13 int64 `envconfig:"LVM_MEMORY_PER_HOST_MIB" default:"1200"` | ||
} |
Oops, something went wrong.