Skip to content

Commit

Permalink
Merge pull request #6401 from jeffdyoung/arm-agent-installer
Browse files Browse the repository at this point in the history
ARMOCP-417: enable arm64 for agent installer
  • Loading branch information
openshift-merge-robot authored Mar 2, 2023
2 parents 56e85be + 1fc134b commit 78e72e5
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ spec:
clusterRef:
name: ostest
namespace: cluster0
cpuArchitecture: x86_64
ipxeScriptType: ""
nmStateConfigLabelSelector:
matchLabels:
Expand Down
26 changes: 13 additions & 13 deletions pkg/asset/agent/image/baseiso.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"time"

"github.com/coreos/stream-metadata-go/arch"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

Expand All @@ -16,18 +17,14 @@ import (
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/agent/mirror"
"github.com/openshift/installer/pkg/rhcos"
"github.com/openshift/installer/pkg/types"
)

// BaseIso generates the base ISO file for the image
type BaseIso struct {
File *asset.File
}

const (
// TODO - add support for other architectures
archName = "x86_64"
)

var (
baseIsoFilename = ""
)
Expand All @@ -40,7 +37,7 @@ func (i *BaseIso) Name() string {
}

// getIsoFile is a pluggable function that gets the base ISO file
type getIsoFile func() (string, error)
type getIsoFile func(archName string) (string, error)

type getIso struct {
getter getIsoFile
Expand All @@ -54,8 +51,7 @@ func newGetIso(getter getIsoFile) *getIso {
var GetIsoPluggable = downloadIso

// Download the ISO using the URL in rhcos.json
func downloadIso() (string, error) {

func downloadIso(archName string) (string, error) {
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
defer cancel()

Expand All @@ -64,9 +60,6 @@ func downloadIso() (string, error) {
if err != nil {
return "", err
}

// Defaults to using the x86_64 baremetal ISO for all platforms
// archName := arch.RpmArch(string(config.ControlPlane.Architecture))
streamArch, err := st.GetArchitecture(archName)
if err != nil {
return "", err
Expand Down Expand Up @@ -107,10 +100,17 @@ func (i *BaseIso) Generate(dependencies asset.Parents) error {
// use the GetIso function to get the BaseIso from the release payload
agentManifests := &manifests.AgentManifests{}
dependencies.Get(agentManifests)

var baseIsoFileName string
var err error

// Default iso archName to x86_64.
archName := arch.RpmArch(types.ArchitectureAMD64)

if agentManifests.ClusterImageSet != nil {
// If specified, use InfraEnv.Spec.CpuArchitecture for iso archName
if agentManifests.InfraEnv.Spec.CpuArchitecture != "" {
archName = agentManifests.InfraEnv.Spec.CpuArchitecture
}
releaseImage := agentManifests.ClusterImageSet.Spec.ReleaseImage
pullSecret := agentManifests.GetPullSecretData()
registriesConf := &mirror.RegistriesConf{}
Expand All @@ -135,7 +135,7 @@ func (i *BaseIso) Generate(dependencies asset.Parents) error {

logrus.Info("Downloading base ISO")
isoGetter := newGetIso(GetIsoPluggable)
baseIsoFileName, err2 := isoGetter.getter()
baseIsoFileName, err2 := isoGetter.getter(archName)
if err2 == nil {
logrus.Debugf("Using base ISO image %s", baseIsoFileName)
i.File = &asset.File{Filename: baseIsoFileName}
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/agent/image/baseiso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestInfraBaseIso_Generate(t *testing.T) {

GetIsoPluggable = func() (string, error) {
GetIsoPluggable = func(archName string) (string, error) {
return "some-openshift-release.iso", nil
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/asset/agent/image/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/coreos/ignition/v2/config/util"
igntypes "github.com/coreos/ignition/v2/config/v3_2/types"
"github.com/coreos/stream-metadata-go/arch"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand All @@ -29,6 +30,7 @@ import (
"github.com/openshift/installer/pkg/asset/password"
"github.com/openshift/installer/pkg/asset/tls"
"github.com/openshift/installer/pkg/rhcos"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/agent"
"github.com/openshift/installer/pkg/version"
)
Expand Down Expand Up @@ -126,8 +128,12 @@ func (a *Ignition) Generate(dependencies asset.Parents) error {
logrus.Infof("The rendezvous host IP (node0 IP) is %s", nodeZeroIP)

a.RendezvousIP = nodeZeroIP
// Default to x86_64
archName := arch.RpmArch(types.ArchitectureAMD64)
if infraEnv.Spec.CpuArchitecture != "" {
archName = infraEnv.Spec.CpuArchitecture
}

// TODO: don't hard-code target arch
releaseImageList, err := releaseImageList(agentManifests.ClusterImageSet.Spec.ReleaseImage, archName)
if err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions pkg/asset/agent/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,19 @@ func (a *OptionalInstallConfig) validateSupportedArchs(installConfig *types.Inst

switch string(installConfig.ControlPlane.Architecture) {
case types.ArchitectureAMD64:
case types.ArchitectureARM64:
default:
allErrs = append(allErrs, field.NotSupported(fieldPath, installConfig.ControlPlane.Architecture, []string{types.ArchitectureAMD64}))
allErrs = append(allErrs, field.NotSupported(fieldPath, installConfig.ControlPlane.Architecture, []string{types.ArchitectureAMD64, types.ArchitectureARM64}))
}

for i, compute := range installConfig.Compute {
fieldPath := field.NewPath(fmt.Sprintf("Compute[%d]", i), "Architecture")

switch string(compute.Architecture) {
case types.ArchitectureAMD64:
case types.ArchitectureARM64:
default:
allErrs = append(allErrs, field.NotSupported(fieldPath, compute.Architecture, []string{types.ArchitectureAMD64}))
allErrs = append(allErrs, field.NotSupported(fieldPath, compute.Architecture, []string{types.ArchitectureAMD64, types.ArchitectureARM64}))
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/asset/agent/installconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ baseDomain: test-domain
networking:
networkType: OVNKubernetes
compute:
- architecture: arm64
- architecture: s390x
hyperthreading: Enabled
name: worker
platform: {}
replicas: 0
controlPlane:
architecture: arm64
architecture: s390x
hyperthreading: Enabled
name: master
platform: {}
Expand All @@ -237,7 +237,7 @@ platform:
pullSecret: "{\"auths\":{\"example.com\":{\"auth\":\"authorization value\"}}}"
`,
expectedFound: false,
expectedError: "invalid install-config configuration: [ControlPlane.Architecture: Unsupported value: \"arm64\": supported values: \"amd64\", Compute[0].Architecture: Unsupported value: \"arm64\": supported values: \"amd64\"]",
expectedError: "invalid install-config configuration: [ControlPlane.Architecture: Unsupported value: \"s390x\": supported values: \"amd64\", \"arm64\", Compute[0].Architecture: Unsupported value: \"s390x\": supported values: \"amd64\", \"arm64\"]",
},
{
name: "valid configuration for none platform for sno",
Expand Down
19 changes: 18 additions & 1 deletion pkg/asset/agent/manifests/infraenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path/filepath"
"strings"

"github.com/coreos/stream-metadata-go/arch"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -15,6 +16,7 @@ import (
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent"
"github.com/openshift/installer/pkg/asset/agent/agentconfig"
"github.com/openshift/installer/pkg/types"
)

var (
Expand Down Expand Up @@ -70,6 +72,12 @@ func (i *InfraEnv) Generate(dependencies asset.Parents) error {
},
},
}

// Use installConfig.Config.ControlPlane.Architecture to determine cpuarchitecture for infraEnv.Spec.CpuArchiteture.
// installConfig.Config.ControlPlance.Architecture uses go/Debian cpuarchitecture values (amd64, arm64) so we must convert to rpmArch because infraEnv.Spec.CpuArchitecture expects x86_64 or aarch64.
if installConfig.Config.ControlPlane.Architecture != "" {
infraEnv.Spec.CpuArchitecture = arch.RpmArch(string(installConfig.Config.ControlPlane.Architecture))
}
if installConfig.Config.Proxy != nil {
infraEnv.Spec.Proxy = getProxy(installConfig)
}
Expand Down Expand Up @@ -116,7 +124,10 @@ func (i *InfraEnv) Load(f asset.FileFetcher) (bool, error) {
if err := yaml.UnmarshalStrict(file.Data, config); err != nil {
return false, errors.Wrapf(err, "failed to unmarshal %s", infraEnvFilename)
}

// If defined, convert to RpmArch amd64 -> x86_64 or arm64 -> aarch64
if config.Spec.CpuArchitecture != "" {
config.Spec.CpuArchitecture = arch.RpmArch(config.Spec.CpuArchitecture)
}
i.File, i.Config = file, config
if err = i.finish(); err != nil {
return false, err
Expand All @@ -131,5 +142,11 @@ func (i *InfraEnv) finish() error {
return errors.New("missing configuration or manifest file")
}

// Throw an error if CpuArchitecture isn't x86_64, aarch64, or ""
switch i.Config.Spec.CpuArchitecture {
case arch.RpmArch(types.ArchitectureAMD64), arch.RpmArch(types.ArchitectureARM64), "":
default:
return errors.Errorf("Config.Spec.CpuArchitecture %s is not supported ", i.Config.Spec.CpuArchitecture)
}
return nil
}

0 comments on commit 78e72e5

Please sign in to comment.