Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
baremetal: Template RHCOS_IMAGE_URL in startironic.sh
Browse files Browse the repository at this point in the history
This shouldn't be hard-coded, so instead we replace the URL with the
appropriate data from rhcos.json.

Related: #37
  • Loading branch information
Steven Hardy committed Jul 16, 2019
1 parent 41b6b8a commit e019bc1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"quay.io/metal3-io/ironic-inspe
IPA_DOWNLOADER_IMAGE=${IPA_DOWNLOADER_IMAGE:-"quay.io/metal3-io/ironic-ipa-downloader:master"}
COREOS_DOWNLOADER_IMAGE=${COREOS_DOWNLOADER_IMAGE:-"quay.io/openshift-metal3/rhcos-downloader:master"}

# FIXME this should be provided by the installer
RHCOS_IMAGE_URL="https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/ootpa/410.8.20190520.0"
# This image is templated in via the installer pkg/asset/ignition/bootstrap/bootstrap.go
RHCOS_IMAGE_URL="{{.DeployImage}}"

# First we stop any previously started containers, because ExecStop only runs when the ExecStart process
# e.g this script is still running, but we exit if *any* of the containers exits unexpectedly
Expand Down
18 changes: 18 additions & 0 deletions pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
"github.com/openshift-metalkube/kni-installer/pkg/asset/machines"
"github.com/openshift-metalkube/kni-installer/pkg/asset/manifests"
"github.com/openshift-metalkube/kni-installer/pkg/asset/tls"
"github.com/openshift-metalkube/kni-installer/pkg/rhcos"
"github.com/openshift-metalkube/kni-installer/pkg/types"
bmtypes "github.com/openshift-metalkube/kni-installer/pkg/types/baremetal"
)

const (
Expand All @@ -42,6 +44,7 @@ type bootstrapTemplateData struct {
PullSecret string
ReleaseImage string
Proxy *configv1.ProxyStatus
DeployImage string
}

// Bootstrap is an asset that generates the ignition config for bootstrap nodes.
Expand Down Expand Up @@ -117,6 +120,7 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error {
if err != nil {
return errors.Wrap(err, "failed to get bootstrap templates")
}
logrus.Debugf("SHDEBUG templateData type %T", templateData)

a.Config = &igntypes.Config{
Ignition: igntypes.Ignition{
Expand Down Expand Up @@ -208,11 +212,25 @@ func (a *Bootstrap) getTemplateData(installConfig *types.InstallConfig, proxy *c
logrus.Debugf("Using internal constant for release image %s", releaseImage)
}

var deployImage string
// baremetal requires some additional templateData to download the RHCOS image
// so we can deploy the masters with the correct image from rhcos.json
if installConfig.Platform.Name() == bmtypes.Name {
var err error
deployImage, err = rhcos.Baremetal()
if err != nil {
return nil, err
}
} else {
deployImage = releaseImage
}

return &bootstrapTemplateData{
PullSecret: installConfig.PullSecret,
ReleaseImage: releaseImage,
EtcdCluster: strings.Join(etcdEndpoints, ","),
Proxy: &proxy.Status,
DeployImage: deployImage,
}, nil
}

Expand Down
23 changes: 23 additions & 0 deletions pkg/rhcos/baremetal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package rhcos

import (
"context"
"net/url"

"github.com/pkg/errors"
)

// Baremetal fetches the BaseURI where baremetal images can be downloaded from
func Baremetal() (string, error) {
meta, err := fetchRHCOSBuild(context.TODO())
if err != nil {
return "", errors.Wrap(err, "failed to fetch RHCOS metadata")
}

base, err := url.Parse(meta.BaseURI)
if err != nil {
return "", err
}

return base.String(), nil
}

0 comments on commit e019bc1

Please sign in to comment.