Skip to content

Commit

Permalink
MULTIARCH-4569: aws: support multi-arch nodes
Browse files Browse the repository at this point in the history
Use different RHCOS images based on the node's architecture.
  • Loading branch information
r4f4 committed Jul 10, 2024
1 parent 39e9578 commit 20e04e3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
6 changes: 5 additions & 1 deletion pkg/asset/machines/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,11 @@ func (w *Worker) Generate(ctx context.Context, dependencies asset.Parents) error
}

if mpool.InstanceType == "" {
instanceTypes := awsdefaults.InstanceTypes(installConfig.Config.Platform.AWS.Region, installConfig.Config.ControlPlane.Architecture, configv1.HighlyAvailableTopologyMode)
arch := installConfig.Config.ControlPlane.Architecture
if len(installConfig.Config.Compute) > 0 {
arch = installConfig.Config.Compute[0].Architecture
}
instanceTypes := awsdefaults.InstanceTypes(installConfig.Config.Platform.AWS.Region, arch, configv1.HighlyAvailableTopologyMode)
switch pool.Name {
case types.MachinePoolEdgeRoleName:
ok := awsSetPreferredInstanceByEdgeZone(ctx, instanceTypes, installConfig.AWS, zones)
Expand Down
40 changes: 30 additions & 10 deletions pkg/asset/rhcos/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,40 @@ func osImage(ctx context.Context, config *types.InstallConfig) (string, string,
if len(config.Platform.AWS.AMIID) > 0 {
return config.Platform.AWS.AMIID, "", nil
}
const globalResourceRegion = "us-east-1"
var osimageControlPlane, osimageCompute string
region := config.Platform.AWS.Region
if !rhcos.AMIRegions(config.ControlPlane.Architecture).Has(region) {
const globalResourceRegion = "us-east-1"
logrus.Debugf("No AMI found in %s. Using AMI from %s.", region, globalResourceRegion)
region = globalResourceRegion
{
if !rhcos.AMIRegions(config.ControlPlane.Architecture).Has(region) {
logrus.Debugf("No AMI found in %s. Using AMI from %s.", region, globalResourceRegion)
region = globalResourceRegion
}
osimageControlPlane, err = st.GetAMI(archName, region)
if err != nil {
return "", "", err
}
if region != config.Platform.AWS.Region {
osimageControlPlane = fmt.Sprintf("%s,%s", osimageControlPlane, region)
}
}
osimageControlPlane, err := st.GetAMI(archName, region)
if err != nil {
return "", "", err
if len(config.Compute) == 0 || config.Compute[0].Architecture == config.ControlPlane.Architecture {
return osimageControlPlane, "", nil
}
if region != config.Platform.AWS.Region {
osimageControlPlane = fmt.Sprintf("%s,%s", osimageControlPlane, region)
{
if !rhcos.AMIRegions(config.Compute[0].Architecture).Has(region) {
logrus.Debugf("No AMI found in %s. Using AMI from %s.", region, globalResourceRegion)
region = globalResourceRegion
}
archName := arch.RpmArch(string(config.Compute[0].Architecture))
osimageCompute, err = st.GetAMI(archName, region)
if err != nil {
return "", "", err
}
if region != config.Platform.AWS.Region {
osimageCompute = fmt.Sprintf("%s,%s", osimageCompute, region)
}
}
return osimageControlPlane, "", nil
return osimageControlPlane, osimageCompute, nil
case gcp.Name:
if streamArch.Images.Gcp != nil {
img := streamArch.Images.Gcp
Expand Down

0 comments on commit 20e04e3

Please sign in to comment.