Skip to content

Commit

Permalink
hack: pin the os release build name
Browse files Browse the repository at this point in the history
One environment variable to be used when building the pinned release binary:
    RHCOS_BUILD_NAME: a string representing the build name(or rather number e.g. 47.48). If empty, then the latest one will be picked up.
This could just be hardcoded in the hack/build.sh script before making the release branch so that it stays baked in.
  • Loading branch information
Rajat Chopra committed Dec 14, 2018
1 parent 3ef7dbf commit 07f17f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ release)
then
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/asset/ignition/bootstrap.defaultReleaseImage=${RELEASE_IMAGE}"
fi
if test -n "${RHCOS_BUILD_NAME}"
then
LDFLAGS="${LDFLAGS} -X github.com/openshift/installer/pkg/rhcos.buildName=${RHCOS_BUILD_NAME}"
fi
if test "${SKIP_GENERATION}" != y
then
go generate ./data
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
ignitionUser = "core"
)

var t(
var (
defaultReleaseImage = "registry.svc.ci.openshift.org/openshift/origin-release:v4.0"
)

Expand Down
18 changes: 13 additions & 5 deletions pkg/rhcos/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ import (
"github.com/sirupsen/logrus"
)

const (
var (
// DefaultChannel is the default RHCOS channel for the cluster.
DefaultChannel = "maipo"

// buildName is the name of the build in the channel that will be picked up
// empty string means the first one in the build list (latest) will be used
buildName = ""

baseURL = "https://releases-rhcos.svc.ci.openshift.org/storage/releases"
)

Expand All @@ -33,9 +37,13 @@ type metadata struct {
}

func fetchLatestMetadata(ctx context.Context, channel string) (metadata, error) {
build, err := fetchLatestBuild(ctx, channel)
if err != nil {
return metadata{}, errors.Wrap(err, "failed to fetch latest build")
build := buildName
var err error
if build == "" {
build, err = fetchLatestBuild(ctx, channel)
if err != nil {
return metadata{}, errors.Wrap(err, "failed to fetch latest build")
}
}

url := fmt.Sprintf("%s/%s/%s/meta.json", baseURL, channel, build)
Expand All @@ -48,7 +56,7 @@ func fetchLatestMetadata(ctx context.Context, channel string) (metadata, error)
client := &http.Client{}
resp, err := client.Do(req.WithContext(ctx))
if err != nil {
return metadata{}, errors.Wrap(err, "failed to fetch metadata")
return metadata{}, errors.Wrapf(err, "failed to fetch metadata for build %s", build)
}
defer resp.Body.Close()

Expand Down

0 comments on commit 07f17f4

Please sign in to comment.