-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MULTIARCH-4569: aws: support multi-arch nodes #8698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,10 @@ import ( | |
| // Image is location of RHCOS image. | ||
| // This stores the location of the image based on the platform. | ||
| // eg. on AWS this contains ami-id, on Livirt this can be the URI for QEMU image etc. | ||
| type Image string | ||
| type Image struct { | ||
| ControlPlane string | ||
| Compute string | ||
| } | ||
|
|
||
| var _ asset.Asset = (*Image)(nil) | ||
|
|
||
|
|
@@ -52,27 +55,35 @@ func (i *Image) Dependencies() []asset.Asset { | |
| func (i *Image) Generate(ctx context.Context, p asset.Parents) error { | ||
| if oi, ok := os.LookupEnv("OPENSHIFT_INSTALL_OS_IMAGE_OVERRIDE"); ok && oi != "" { | ||
| logrus.Warn("Found override for OS Image. Please be warned, this is not advised") | ||
| *i = Image(oi) | ||
| *i = *MakeAsset(oi) | ||
|
||
| return nil | ||
| } | ||
|
|
||
| ic := &installconfig.InstallConfig{} | ||
| p.Get(ic) | ||
| config := ic.Config | ||
| osimage, err := osImage(ctx, config) | ||
| osimageControlPlane, err := osImage(ctx, config, config.ControlPlane.Architecture) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| arch := config.ControlPlane.Architecture | ||
| if len(config.Compute) > 0 { | ||
| arch = config.Compute[0].Architecture | ||
| } | ||
| osimageCompute, err := osImage(ctx, config, arch) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| *i = Image(osimage) | ||
| *i = Image{osimageControlPlane, osimageCompute} | ||
| return nil | ||
| } | ||
|
|
||
| //nolint:gocyclo | ||
| func osImage(ctx context.Context, config *types.InstallConfig) (string, error) { | ||
| func osImage(ctx context.Context, config *types.InstallConfig, nodeArch types.Architecture) (string, error) { | ||
| ctx, cancel := context.WithTimeout(ctx, 30*time.Second) | ||
| defer cancel() | ||
|
|
||
| archName := arch.RpmArch(string(config.ControlPlane.Architecture)) | ||
| archName := arch.RpmArch(string(nodeArch)) | ||
|
|
||
| st, err := rhcos.FetchCoreOSBuild(ctx) | ||
| if err != nil { | ||
|
|
@@ -88,7 +99,7 @@ func osImage(ctx context.Context, config *types.InstallConfig) (string, error) { | |
| return config.Platform.AWS.AMIID, nil | ||
| } | ||
| region := config.Platform.AWS.Region | ||
| if !rhcos.AMIRegions(config.ControlPlane.Architecture).Has(region) { | ||
| if !rhcos.AMIRegions(nodeArch).Has(region) { | ||
| const globalResourceRegion = "us-east-1" | ||
| logrus.Debugf("No AMI found in %s. Using AMI from %s.", region, globalResourceRegion) | ||
| region = globalResourceRegion | ||
|
|
@@ -155,7 +166,6 @@ func osImage(ctx context.Context, config *types.InstallConfig) (string, error) { | |
| // FindArtifactURL just create the URL here. | ||
| artifact := a.Formats["ova"].Disk | ||
| u, err := url.Parse(artifact.Location) | ||
|
|
||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
@@ -212,3 +222,11 @@ func osImage(ctx context.Context, config *types.InstallConfig) (string, error) { | |
| return "", fmt.Errorf("invalid platform %v", config.Platform.Name()) | ||
| } | ||
| } | ||
|
|
||
| // MakeAsset returns an Image asset with the given os image. | ||
| func MakeAsset(osImage string) *Image { | ||
| return &Image{ | ||
| ControlPlane: osImage, | ||
| Compute: osImage, | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.