Skip to content
Merged
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
1,783 changes: 918 additions & 865 deletions docs/design/resource_dep.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (t *TerraformVariables) Dependencies() []asset.Asset {
&installconfig.ClusterID{},
&installconfig.InstallConfig{},
new(rhcos.Image),
new(rhcos.BootstrapImage),
&bootstrap.Bootstrap{},
&machine.Master{},
&machines.Master{},
Expand All @@ -90,7 +91,8 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
mastersAsset := &machines.Master{}
workersAsset := &machines.Worker{}
rhcosImage := new(rhcos.Image)
parents.Get(clusterID, installConfig, bootstrapIgnAsset, masterIgnAsset, mastersAsset, workersAsset, rhcosImage)
rhcosBootstrapImage := new(rhcos.BootstrapImage)
parents.Get(clusterID, installConfig, bootstrapIgnAsset, masterIgnAsset, mastersAsset, workersAsset, rhcosImage, rhcosBootstrapImage)

platform := installConfig.Config.Platform.Name()
switch platform {
Expand Down Expand Up @@ -261,7 +263,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
data, err = baremetaltfvars.TFVars(
installConfig.Config.Platform.BareMetal.LibvirtURI,
installConfig.Config.Platform.BareMetal.IronicURI,
string(*rhcosImage),
string(*rhcosBootstrapImage),
"baremetal",
"provisioning",
installConfig.Config.Platform.BareMetal.Hosts,
Expand Down
58 changes: 58 additions & 0 deletions pkg/asset/rhcos/bootstrap_image.go
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: the openstack image cannot be used to boot a VM using QEMU in libvirt backend? Is there a technical limitation?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abhinavdahiya The reason is that the libvirt backend uses the qemu_fw_cfg driver to pass the Ignition config, and the only image which has this enabled is the QEMU one:

https://github.com/openshift/installer/blob/master/pkg/terraform/exec/plugins/vendor/github.com/dmacvicar/terraform-provider-libvirt/libvirt/domain.go#L243

It might be that in future we can rework that to enable passing the config via a config-drive so that we can use the openstack image in both places, but I've not investigated that yet, or had any discussion with the terraform-provider-libvirt community

osimage, err = rhcos.QEMU(ctx)
default:
// other platforms use the same image for all nodes
osimage, err = osImage(config)
}
if err != nil {
return err
}
*i = BootstrapImage(osimage)
return nil
}
21 changes: 16 additions & 5 deletions pkg/asset/rhcos/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"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"
"github.com/openshift/installer/pkg/types/aws"
"github.com/openshift/installer/pkg/types/azure"
"github.com/openshift/installer/pkg/types/baremetal"
Expand Down Expand Up @@ -52,7 +53,15 @@ func (i *Image) Generate(p asset.Parents) error {
ic := &installconfig.InstallConfig{}
p.Get(ic)
config := ic.Config
osimage, err := osImage(config)
if err != nil {
return err
}
*i = Image(osimage)
return nil
}

func osImage(config *types.InstallConfig) (string, error) {
var osimage string
var err error
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
Expand All @@ -73,14 +82,16 @@ func (i *Image) Generate(p asset.Parents) error {
//TODO(serbrech): change to right image once available.
osimage = "/resourceGroups/rhcos_images/providers/Microsoft.Compute/images/rhcostestimage"
case baremetal.Name:
osimage, err = rhcos.QEMU(ctx)
// Note that baremetal IPI currently uses the OpenStack image
// because this contains the necessary ironic config drive
// ignition support, which isn't enabled in the UPI BM images
osimage, err = rhcos.OpenStack(ctx)
case none.Name, vsphere.Name:
default:
return errors.New("invalid Platform")
return "", errors.New("invalid Platform")
}
if err != nil {
return err
return "", err
}
*i = Image(osimage)
return nil
return osimage, nil
}
4 changes: 4 additions & 0 deletions pkg/rhcos/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type metadata struct {
Path string `json:"path"`
SHA256 string `json:"sha256"`
} `json:"qemu"`
OpenStack struct {
Path string `json:"path"`
SHA256 string `json:"sha256"`
} `json:"openstack"`
} `json:"images"`
OSTreeVersion string `json:"ostree-version"`
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/rhcos/openstack.go
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
}