Skip to content

Commit

Permalink
Remove old upgradestreams logic from the monitor & old parts of the RP (
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkowl authored Aug 30, 2023
1 parent c3a282c commit 1e3c102
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 317 deletions.
2 changes: 1 addition & 1 deletion cmd/aro/update_ocp_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func getLatestOCPVersions(ctx context.Context, log *logrus.Entry) ([]api.OpenShi
return nil, err
}

for _, vers := range version.HiveInstallStreams {
for _, vers := range version.AvailableInstallStreams {
installerPullSpec := fmt.Sprintf("%s/aro-installer:%s", dstRepo, vers.Version.MinorVersion())
digest, ok := installerImageDigests[vers.Version.MinorVersion()]
if !ok {
Expand Down
17 changes: 1 addition & 16 deletions pkg/deploy/saveversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ package deploy
import (
"bytes"
"context"
"encoding/json"
"net/url"
"time"

mgmtstorage "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
azstorage "github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest/date"

"github.com/Azure/ARO-RP/pkg/util/version"
)

// SaveVersion for current location in shared storage account for environment
Expand Down Expand Up @@ -45,17 +42,5 @@ func (d *deployer) SaveVersion(ctx context.Context) error {
// save version of RP which is deployed in this location
containerRef := blobClient.GetContainerReference("rpversion")
blobRef := containerRef.GetBlobReference(d.config.Location)
err = blobRef.CreateBlockBlobFromReader(bytes.NewReader([]byte(d.version)), nil)
if err != nil {
return err
}

// save OCP upgrade streams which are used by RP in this location
containerRef = blobClient.GetContainerReference("ocpversions")
blobRef = containerRef.GetBlobReference(d.config.Location)
streams, err := json.Marshal(version.UpgradeStreams)
if err != nil {
return err
}
return blobRef.CreateBlockBlobFromReader(bytes.NewReader(streams), nil)
return blobRef.CreateBlockBlobFromReader(bytes.NewReader([]byte(d.version)), nil)
}
18 changes: 0 additions & 18 deletions pkg/monitor/cluster/clusterversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (mon *Monitor) emitClusterVersions(ctx context.Context) error {
"provisionedByResourceProviderVersion": mon.oc.Properties.ProvisionedBy, // last successful Put or Patch
"resourceProviderVersion": version.GitCommit, // RP version currently running
"operatorVersion": operatorVersion, // operator version in the cluster
"availableVersion": availableVersion(cv, version.UpgradeStreams), // current available version for upgrade from stream
"availableRP": availableRP, // current RP version available for document update, empty when none
"latestGaMinorVersion": version.DefaultInstallStream.Version.MinorVersion(), // Latest GA in ARO Minor version
"actualMinorVersion": actualMinorVersion, // Minor version, empty if actual version is not in expected form
Expand Down Expand Up @@ -83,20 +82,3 @@ func desiredVersion(cv *configv1.ClusterVersion) string {

return cv.Status.Desired.Version
}

// availableVersion checks the upgradeStreams for possible upgrade of the cluster
// when the upgrade is possible withing the current Y version, return true and closest upgrade stream version
func availableVersion(cv *configv1.ClusterVersion, streams []*version.Stream) string {
av := actualVersion(cv)
v, err := version.ParseVersion(av)
if err != nil {
return ""
}

uStream := version.GetUpgradeStream(streams, v, false)
if uStream == nil {
return ""
}

return uStream.Version.String()
}
81 changes: 0 additions & 81 deletions pkg/monitor/cluster/clusterversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestEmitClusterVersion(t *testing.T) {
wantActualVersion string
wantDesiredVersion string
wantProvisionedByResourceProviderVersion string
wantAvailableVersion string
wantAvailableRP string
wantActualMinorVersion string
}{
Expand Down Expand Up @@ -78,7 +77,6 @@ func TestEmitClusterVersion(t *testing.T) {
wantActualVersion: "4.5.1",
wantDesiredVersion: "4.5.3",
wantProvisionedByResourceProviderVersion: "",
wantAvailableVersion: "4.5.39",
wantAvailableRP: "unknown",
wantActualMinorVersion: "4.5",
},
Expand Down Expand Up @@ -159,7 +157,6 @@ func TestEmitClusterVersion(t *testing.T) {
"provisionedByResourceProviderVersion": tt.wantProvisionedByResourceProviderVersion,
"operatorVersion": "test",
"resourceProviderVersion": "unknown",
"availableVersion": tt.wantAvailableVersion,
"availableRP": tt.wantAvailableRP,
"latestGaMinorVersion": version.DefaultInstallStream.Version.MinorVersion(),
"actualMinorVersion": tt.wantActualMinorVersion,
Expand All @@ -172,81 +169,3 @@ func TestEmitClusterVersion(t *testing.T) {
})
}
}

func TestBaselineVersion(t *testing.T) {
streams := []*version.Stream{
{
Version: version.NewVersion(4, 4, 38),
},
{
Version: version.NewVersion(4, 5, 2),
},
{
Version: version.NewVersion(4, 6, 17),
},
}

for _, tt := range []struct {
cv configv1.ClusterVersion
want string
upgrade bool
}{
{
cv: configv1.ClusterVersion{
Status: configv1.ClusterVersionStatus{
History: []configv1.UpdateHistory{
{
State: configv1.CompletedUpdate,
Version: "4.4.2",
},
},
},
},
want: "4.4.38",
},
{
cv: configv1.ClusterVersion{
Status: configv1.ClusterVersionStatus{
History: []configv1.UpdateHistory{
{
State: configv1.CompletedUpdate,
Version: "4.4.40",
},
},
},
},
want: "",
},
{
cv: configv1.ClusterVersion{
Status: configv1.ClusterVersionStatus{
History: []configv1.UpdateHistory{
{
State: configv1.CompletedUpdate,
Version: "4.5.1",
},
},
},
},
want: "4.5.2",
},
{
cv: configv1.ClusterVersion{
Status: configv1.ClusterVersionStatus{
History: []configv1.UpdateHistory{
{
State: configv1.CompletedUpdate,
Version: "4.5.2",
},
},
},
},
want: "",
},
} {
bVersion := availableVersion(&tt.cv, streams)
if bVersion != tt.want {
t.Fatalf("Upgrade version does not match. want==%s, got==%s\n", tt.want, bVersion)
}
}
}
38 changes: 6 additions & 32 deletions pkg/util/version/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const (

var GitCommit = "unknown"

type Stream struct {
Version *Version `json:"version"`
PullSpec string `json:"-"`
}

// DefaultMinorVersion describes the minor OpenShift version to default to
var DefaultMinorVersion = 11

Expand All @@ -47,7 +52,7 @@ var DefaultInstallStreams = map[int]*Stream{
// DefaultInstallStream describes stream we are defaulting to for all new clusters
var DefaultInstallStream = DefaultInstallStreams[DefaultMinorVersion]

var HiveInstallStreams = []*Stream{
var AvailableInstallStreams = []*Stream{
DefaultInstallStreams[10],
{
Version: NewVersion(4, 10, 54),
Expand All @@ -65,37 +70,6 @@ var HiveInstallStreams = []*Stream{
DefaultInstallStreams[12],
}

// UpgradeStreams describes list of streams we support for upgrades
var (
UpgradeStreams = []*Stream{
DefaultInstallStream,
{
Version: NewVersion(4, 9, 28),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:4084d94969b186e20189649b5affba7da59f7d1943e4e5bc7ef78b981eafb7a8",
},
{
Version: NewVersion(4, 8, 18),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:321aae3d3748c589bc2011062cee9fd14e106f258807dc2d84ced3f7461160ea",
},
{
Version: NewVersion(4, 7, 30),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:aba54b293dc151f5c0fd96d4353ced6ced3e7da6620c1c10714ab32d0577486f",
},
{
Version: NewVersion(4, 6, 44),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:d042aa235b538721a39989b13d7d9d3537af9b57e9fd10f485dd04461932ec85",
},
{
Version: NewVersion(4, 5, 39),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:c4b9eb565c64df97afe7841bbcc0469daec7973e46ae588739cc30ea9062172b",
},
{
Version: NewVersion(4, 4, 33),
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:a035dddd8a5e5c99484138951ef4aba021799b77eb9046f683a5466c23717738",
},
}
)

// FluentbitImage contains the location of the Fluentbit container image
func FluentbitImage(acrDomain string) string {
return acrDomain + "/fluentbit:1.9.10-cm20230805"
Expand Down
44 changes: 0 additions & 44 deletions pkg/util/version/stream.go

This file was deleted.

Loading

0 comments on commit 1e3c102

Please sign in to comment.