-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Decouple bootstrap and cluster bootimages #2061
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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Package rhcos contains assets for RHCOS. | ||
| package rhcos | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/installconfig" | ||
| "github.com/openshift/installer/pkg/rhcos" | ||
| "github.com/openshift/installer/pkg/types/baremetal" | ||
| ) | ||
|
|
||
| // BootstrapImage is location of the RHCOS image for the Bootstrap node | ||
| // 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. | ||
| // Note that for most platforms this is the same as rhcos.Image | ||
| type BootstrapImage string | ||
|
|
||
| var _ asset.Asset = (*BootstrapImage)(nil) | ||
|
|
||
| // Name returns the human-friendly name of the asset. | ||
| func (i *BootstrapImage) Name() string { | ||
| return "BootstrapImage" | ||
| } | ||
|
|
||
| // Dependencies returns no dependencies. | ||
| func (i *BootstrapImage) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &installconfig.InstallConfig{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate the RHCOS Bootstrap image location. | ||
| func (i *BootstrapImage) Generate(p asset.Parents) error { | ||
| ic := &installconfig.InstallConfig{} | ||
| p.Get(ic) | ||
| config := ic.Config | ||
|
|
||
| var osimage string | ||
| var err error | ||
| ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second) | ||
| defer cancel() | ||
| switch config.Platform.Name() { | ||
| case baremetal.Name: | ||
| // Baremetal IPI launches a local VM for the bootstrap node | ||
| // Hence requires the QEMU image to use the libvirt backend | ||
|
||
| osimage, err = rhcos.QEMU(ctx) | ||
hardys marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| default: | ||
| // other platforms use the same image for all nodes | ||
| osimage, err = osImage(config) | ||
| } | ||
| if err != nil { | ||
| return err | ||
| } | ||
| *i = BootstrapImage(osimage) | ||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package rhcos | ||
|
|
||
| import ( | ||
| "context" | ||
| "net/url" | ||
|
|
||
| "github.com/pkg/errors" | ||
| ) | ||
|
|
||
| // OpenStack fetches the URL of the Red Hat Enterprise Linux CoreOS release, | ||
| // for the openstack platform | ||
| func OpenStack(ctx context.Context) (string, error) { | ||
| meta, err := fetchRHCOSBuild(ctx) | ||
| if err != nil { | ||
| return "", errors.Wrap(err, "failed to fetch RHCOS metadata") | ||
| } | ||
|
|
||
| base, err := url.Parse(meta.BaseURI) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| relOpenStack, err := url.Parse(meta.Images.OpenStack.Path) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| return base.ResolveReference(relOpenStack).String(), nil | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.