Skip to content
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

Read installer image digests from an environment variable #3009

Merged
merged 1 commit into from
Jul 11, 2023
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
27 changes: 24 additions & 3 deletions cmd/aro/update_ocp_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package main

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"os"

Expand All @@ -30,19 +32,38 @@ func getLatestOCPVersions(ctx context.Context, log *logrus.Entry) ([]api.OpenShi
dstRepo := dstAcr + acrDomainSuffix
ocpVersions := []api.OpenShiftVersion{}

// INSTALLER_IMAGE_DIGESTS is the mapping of a minor version to
// the aro-installer wrapper digest. This allows us to utilize
// Azure Safe Deployment Practices (SDP) instead of pushing the
// version tag and deploying to all regions at once.
var installerImageDigests map[string]string
jsonData := []byte(os.Getenv("INSTALLER_IMAGE_DIGESTS"))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "INSTALLER_IMAGE_DIGESTS" can be a const and then used on lines 48,52 as well


// For Azure DevOps pipelines, the JSON data is Base64-encoded
// since it's embedded in JSON-formatted build artifacts. But
// let's not force that on local development mode.
if !env.IsLocalDevelopmentMode() {
jsonData, err = base64.StdEncoding.DecodeString(string(jsonData))
if err != nil {
return nil, fmt.Errorf("INSTALLER_IMAGE_DIGESTS: Failed to decode base64: %v", err)
}
}
if err = json.Unmarshal(jsonData, &installerImageDigests); err != nil {
return nil, fmt.Errorf("INSTALLER_IMAGE_DIGESTS: Failed to parse JSON: %v", err)
}

for _, vers := range version.HiveInstallStreams {
installerPullSpec := fmt.Sprintf("%s/aro-installer:%s", dstRepo, vers.Version.MinorVersion())
digest, ok := version.InstallerImageDigest[vers.Version.MinorVersion()]
digest, ok := installerImageDigests[vers.Version.MinorVersion()]
if !ok {
return nil, fmt.Errorf("no digest found for version %s", vers.Version.String())
}

installerPullSpec = fmt.Sprintf("%s@sha256:%s", installerPullSpec, digest)
ocpVersions = append(ocpVersions, api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: vers.Version.String(),
OpenShiftPullspec: vers.PullSpec,
InstallerPullspec: installerPullSpec,
InstallerPullspec: installerPullSpec + "@" + digest,
Enabled: true,
},
})
Expand Down
8 changes: 0 additions & 8 deletions pkg/util/version/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ const (

var GitCommit = "unknown"

// InstallerImageDigest is the mapping of a minor version to the aro-installer wrapper digest
// this allows us to utilize SDP instead of pushing up the tag and it rolling out to all regions
// at once
var InstallerImageDigest = map[string]string{
NewVersion(4, 10).MinorVersion(): "eef5f0d82ab07c866999f99a632edafd845e0dc48a0f06eac9df46b0ab882231",
NewVersion(4, 11).MinorVersion(): "82869dd10841046c4b98fc46c6f87030c82b320b82f990610c1fa87150004730",
}

// DefaultInstallStream describes stream we are defaulting to for all new clusters
var DefaultInstallStream = &Stream{
Version: NewVersion(4, 10, 54),
Expand Down