Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions test/extended-priv/controlplanemachineset.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
"github.com/openshift/machine-config-operator/test/extended-priv/util/architecture"

logger "github.com/openshift/machine-config-operator/test/extended-priv/util/logext"
"github.com/tidwall/gjson"
"k8s.io/apimachinery/pkg/util/wait"
Expand All @@ -23,7 +23,7 @@ const (
// BootImageResource is an interface for resources that have boot images (MachineSet and ControlPlaneMachineSet)
type BootImageResource interface {
GetOC() *exutil.CLI
GetArchitectureOrFail() architecture.Architecture
GetArchitectureOrFail() exutil.Architecture
GetCoreOsBootImage() (string, error)
String() string
}
Expand Down Expand Up @@ -210,34 +210,34 @@ func (cpms ControlPlaneMachineSet) SetCoreOsBootImage(coreosBootImage string) er
}

// GetArchitecture returns the architecture for this ControlPlaneMachineSet
func (cpms ControlPlaneMachineSet) GetArchitecture() (architecture.Architecture, error) {
func (cpms ControlPlaneMachineSet) GetArchitecture() (exutil.Architecture, error) {
platform := exutil.CheckPlatform(cpms.GetOC())
if platform == VspherePlatform {
// In vsphere only the AMD64 architecture is supported
return architecture.AMD64, nil
// In vsphere only the exutil.AMD64 architecture is supported
return exutil.AMD64, nil
}

// Get machines created by the ControlPlaneMachineSet
machines, err := cpms.GetMachines()
if err != nil {
return architecture.UNKNOWN, err
return exutil.UNKNOWN, err
}

if len(machines) == 0 {
return architecture.UNKNOWN, fmt.Errorf("ControlPlaneMachineSet %s has no machines, so we cannot get the architecture from any existing machine", cpms.GetName())
return exutil.UNKNOWN, fmt.Errorf("ControlPlaneMachineSet %s has no machines, so we cannot get the architecture from any existing machine", cpms.GetName())
}

// Get the node associated with the first machine
node, err := machines[0].GetNode()
if err != nil {
return architecture.UNKNOWN, err
return exutil.UNKNOWN, err
}

return node.GetArchitecture()
}

// GetArchitectureOrFail returns the architecture and fails the test if any error happens
func (cpms ControlPlaneMachineSet) GetArchitectureOrFail() architecture.Architecture {
func (cpms ControlPlaneMachineSet) GetArchitectureOrFail() exutil.Architecture {
arch, err := cpms.GetArchitecture()
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(), "Error getting the architecture in %s", cpms)
return arch
Expand Down
31 changes: 15 additions & 16 deletions test/extended-priv/machineconfigpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
"github.com/openshift/machine-config-operator/test/extended-priv/util/architecture"
logger "github.com/openshift/machine-config-operator/test/extended-priv/util/logext"
"github.com/tidwall/gjson"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -461,16 +460,16 @@ func (mcp *MachineConfigPool) GetNodes() ([]*Node, error) {
}

// GetNodesByArchitecture returns a list of nodes that belong to this pool and use the given architecture
func (mcp *MachineConfigPool) GetNodesByArchitecture(arch architecture.Architecture, archs ...architecture.Architecture) ([]*Node, error) {
func (mcp *MachineConfigPool) GetNodesByArchitecture(arch exutil.Architecture, archs ...exutil.Architecture) ([]*Node, error) {
archsList := arch.String()
for _, itemArch := range archs {
archsList = archsList + "," + itemArch.String()
}
return mcp.GetNodesByLabel(fmt.Sprintf(`%s in (%s)`, architecture.NodeArchitectureLabel, archsList))
return mcp.GetNodesByLabel(fmt.Sprintf(`%s in (%s)`, exutil.NodeArchitectureLabel, archsList))
}

// GetNodesByArchitectureOrFail returns a list of nodes that belong to this pool and use the given architecture. It fails the test if any error happens
func (mcp *MachineConfigPool) GetNodesByArchitectureOrFail(arch architecture.Architecture, archs ...architecture.Architecture) []*Node {
// GetNodesByArchitectureOrFail returns a list of nodes that belong to this pool and use the given It fails the test if any error happens
func (mcp *MachineConfigPool) GetNodesByArchitectureOrFail(arch exutil.Architecture, archs ...exutil.Architecture) []*Node {
nodes, err := mcp.GetNodesByArchitecture(arch)
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(), "In MCP %s. Cannot get the nodes using architectures %s", mcp.GetName(), append(archs, arch))
return nodes
Expand Down Expand Up @@ -927,8 +926,8 @@ func (mcp *MachineConfigPool) SanityCheck() error {
}

// GetArchitectures returns the list of architectures that the nodes in this pool are using
func (mcp *MachineConfigPool) GetArchitectures() ([]architecture.Architecture, error) {
archs := []architecture.Architecture{}
func (mcp *MachineConfigPool) GetArchitectures() ([]exutil.Architecture, error) {
archs := []exutil.Architecture{}
nodes, err := mcp.GetNodes()
if err != nil {
return archs, err
Expand All @@ -942,14 +941,14 @@ func (mcp *MachineConfigPool) GetArchitectures() ([]architecture.Architecture, e
}

// GetArchitecturesOrFail returns the list of architectures that the nodes in this pool are using, if there is any error it fails the test
func (mcp *MachineConfigPool) GetArchitecturesOrFail() []architecture.Architecture {
func (mcp *MachineConfigPool) GetArchitecturesOrFail() []exutil.Architecture {
archs, err := mcp.GetArchitectures()
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(), "Error getting the architectures used by nodes in MCP %s", mcp.GetName())
return archs
}

// AllNodesUseArch return true if all the nodes in the pool has the given architecture
func (mcp *MachineConfigPool) AllNodesUseArch(arch architecture.Architecture) bool {
func (mcp *MachineConfigPool) AllNodesUseArch(arch exutil.Architecture) bool {
for _, currentArch := range mcp.GetArchitecturesOrFail() {
if arch != currentArch {
return false
Expand Down Expand Up @@ -1336,7 +1335,7 @@ func DeleteCustomMCP(oc *exutil.CLI, name string) error {
// 2) A custom pool with 1 arm node in it if there are arm nodes in the worker pool. The pool will have the same osstream used by the worker pool
// 3) Any existing custom MCP with all nodes using arm64
// 4) The master pools if the master pool is arm64
func GetPoolAndNodesForArchitectureOrFail(oc *exutil.CLI, createMCPName string, arch architecture.Architecture, numNodes int) (*MachineConfigPool, []*Node) {
func GetPoolAndNodesForArchitectureOrFail(oc *exutil.CLI, createMCPName string, arch exutil.Architecture, numNodes int) (*MachineConfigPool, []*Node) {

var (
wMcp = NewMachineConfigPool(oc, MachineConfigPoolWorker)
Expand All @@ -1356,8 +1355,8 @@ func GetPoolAndNodesForArchitectureOrFail(oc *exutil.CLI, createMCPName string,
if len(wMcp.GetNodesByArchitectureOrFail(arch)) > 0 {
var err error

mcp, err := CreateCustomMCPWithStreamByLabel(oc.AsAdmin(), createMCPName, fmt.Sprintf(`%s=%s`, architecture.NodeArchitectureLabel, arch), osstream, numNodes)
o.Expect(err).NotTo(o.HaveOccurred(), "Error creating the custom pool for infrastructure %s", architecture.ARM64)
mcp, err := CreateCustomMCPWithStreamByLabel(oc.AsAdmin(), createMCPName, fmt.Sprintf(`%s=%s`, exutil.NodeArchitectureLabel, arch), osstream, numNodes)
o.Expect(err).NotTo(o.HaveOccurred(), "Error creating the custom pool for infrastructure %s", exutil.ARM64)
return mcp, mcp.GetNodesOrFail()
}

Expand Down Expand Up @@ -1450,14 +1449,14 @@ func FilterExtensions(extensions map[string][]string, hasARM64, fips bool, osIma
filteredExtensions[ext] = pkgs
}

// sandboxed-containers extension is not supported for ARM64 if FIPS is enabled
// sandboxed-containers extension is not supported for exutil.ARM64 if FIPS is enabled
if fips && hasARM64 {
logger.Infof("%s extension not supported in ARM64+FIPS clusters. Skipping extension.", sandboxedContainersExtension)
logger.Infof("%s extension not supported in exutil.ARM64+FIPS clusters. Skipping extension.", sandboxedContainersExtension)
delete(filteredExtensions, sandboxedContainersExtension)
} else if hasARM64 && osImageStream == OSImageStreamRHEL10 {
// TODO Remove with https://issues.redhat.com/browse/MCO-2156
// This change is temporal till RHEL 10 ARM64 builds have kata-containers
logger.Infof("%s extension is temporarily not supported in RHEL 10 ARM64 clusters. Skipping extension.", sandboxedContainersExtension)
// This change is temporal till RHEL 10 exutil.ARM64 builds have kata-containers
logger.Infof("%s extension is temporarily not supported in RHEL 10 exutil.ARM64 clusters. Skipping extension.", sandboxedContainersExtension)
delete(filteredExtensions, sandboxedContainersExtension)
}

Expand Down
27 changes: 13 additions & 14 deletions test/extended-priv/machineset.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

o "github.com/onsi/gomega"
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
"github.com/openshift/machine-config-operator/test/extended-priv/util/architecture"
logger "github.com/openshift/machine-config-operator/test/extended-priv/util/logext"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
Expand Down Expand Up @@ -261,42 +260,42 @@ func (ms MachineSet) SetCoreOsBootImage(coreosBootImage string) error {
}

// GetArchitecture returns the architecture configured for this Machineset
func (ms MachineSet) GetArchitecture() (architecture.Architecture, error) {
func (ms MachineSet) GetArchitecture() (exutil.Architecture, error) {
labeledArch, err := ms.Get(`{.metadata.annotations.capacity\.cluster-autoscaler\.kubernetes\.io/labels}`)
if err != nil {
return architecture.UNKNOWN, err
return exutil.UNKNOWN, err
}

if !strings.Contains(labeledArch, "kubernetes.io/arch=") {
platform := exutil.CheckPlatform(ms.GetOC())
if platform == VspherePlatform {
// In vsphere only the AMD64 architecture is supported
return architecture.AMD64, nil
// In vsphere only the exutil.AMD64 architecture is supported
return exutil.AMD64, nil
}

logger.Infof("No arch annotation in the machineset. Not Vsphere. We need to get the architecture from the existing nodes created by the machineset %s", ms.GetName())
nodes, err := ms.GetNodes()
if err != nil {
return architecture.UNKNOWN, err
return exutil.UNKNOWN, err
}

if len(nodes) == 0 {
return architecture.UNKNOWN, fmt.Errorf("Machineset %s has no replicas, so we cannot get the architecture from any existing node", ms.GetName())
return exutil.UNKNOWN, fmt.Errorf("Machineset %s has no replicas, so we cannot get the architecture from any existing node", ms.GetName())
}

narch, err := nodes[0].GetArchitecture()
if err != nil {
return architecture.UNKNOWN, err
return exutil.UNKNOWN, err
}

return narch, nil
}

return architecture.FromString(strings.Split(labeledArch, "kubernetes.io/arch=")[1]), nil
return exutil.FromString(strings.Split(labeledArch, "kubernetes.io/arch=")[1]), nil
}

// GetArchitectureOrFail returns the architecture configured for this Machineset and fails the test if any error happens
func (ms MachineSet) GetArchitectureOrFail() architecture.Architecture {
func (ms MachineSet) GetArchitectureOrFail() exutil.Architecture {
arch, err := ms.GetArchitecture()
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred(), "Error getting the annotated architecture in %s", ms)
return arch
Expand Down Expand Up @@ -513,11 +512,11 @@ func convertUserDataToNewVersion(userData, newIgnitionVersion string) (string, e
}
currentIgnitionVersion := currentIgnitionVersionResult.String()

if CompareVersions(currentIgnitionVersion, "=", newIgnitionVersion) {
if exutil.CompareVersions(currentIgnitionVersion, "=", newIgnitionVersion) {
logger.Infof("Current ignition version %s is the same as the new ignition version %s. No need to manipulate the userData info",
currentIgnitionVersion, newIgnitionVersion)
} else {
if CompareVersions(newIgnitionVersion, "<", "3.0.0") {
if exutil.CompareVersions(newIgnitionVersion, "<", "3.0.0") {
logger.Infof("New ignition version is %s, we need to adapt the userData ignition config to 2.0 config", newIgnitionVersion)
userData, err = ConvertUserDataIgnition3ToIgnition2(userData)
if err != nil {
Expand Down Expand Up @@ -597,10 +596,10 @@ func getUserDataIgnitionVersionFromOCPVersion(baseImageVersion string) string {
4.1: 2.2.0
*/

if CompareVersions(baseImageVersion, "<", "4.6") {
if exutil.CompareVersions(baseImageVersion, "<", "4.6") {
return "2.2.0"
}
if CompareVersions(baseImageVersion, "<", "4.10") {
if exutil.CompareVersions(baseImageVersion, "<", "4.10") {
return "3.1.0"
}
return "3.2.0"
Expand Down
2 changes: 1 addition & 1 deletion test/extended-priv/mco.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func skipTestIfRHELVersion(node *Node, operator, constraintVersion string) {
actualVersion, err := node.GetRHELVersion()
o.Expect(err).NotTo(o.HaveOccurred(), "Error getting RHEL version from node %s", node.GetName())

if CompareVersions(actualVersion, operator, constraintVersion) {
if exutil.CompareVersions(actualVersion, operator, constraintVersion) {
g.Skip(fmt.Sprintf("Test requires RHEL version NOT %s %s, but node has %s", operator, constraintVersion, actualVersion))
}
}
Loading