Skip to content

Commit

Permalink
Merge branch 'master' into niontive/maintenance-signals-monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Ontiveros committed Jul 5, 2023
2 parents 386ce5b + d82d4f5 commit 4a72b39
Show file tree
Hide file tree
Showing 38 changed files with 524 additions and 196 deletions.
2 changes: 2 additions & 0 deletions .pipelines/onebranch/pipeline.buildrp.official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ extends:
suppression:
suppressionFile: $(Build.SourcesDirectory)\.gdn\.gdnsuppress
suppressionSet: default
git:
longpaths: true

stages:
- stage: Build_ARO
Expand Down
2 changes: 2 additions & 0 deletions .pipelines/onebranch/pipeline.buildrp.pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ extends:
suppression:
suppressionFile: $(Build.SourcesDirectory)\.gdn\.gdnsuppress
suppressionSet: default
git:
longpaths: true

stages:
- stage: Build_ARO
Expand Down
2 changes: 1 addition & 1 deletion cmd/aro/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func mirror(ctx context.Context, log *logrus.Entry) error {
// https://quay.io/repository/app-sre/hive?tab=tags
// Temporary image to evaluate memory leak
// TODO: move to official hive image once we fix memory leak
"quay.io/app-sre/hive:32e143a294",
"quay.io/bvesel/hive:fec14dcf0-20230623",
} {
log.Printf("mirroring %s -> %s", ref, pkgmirror.Dest(dstAcr+acrDomainSuffix, ref))

Expand Down
9 changes: 8 additions & 1 deletion cmd/aro/update_ocp_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ func getLatestOCPVersions(ctx context.Context, log *logrus.Entry) ([]api.OpenShi
ocpVersions := []api.OpenShiftVersion{}

for _, vers := range version.HiveInstallStreams {
installerPullSpec := fmt.Sprintf("%s/aro-installer:%s", dstRepo, vers.Version.MinorVersion())
digest, ok := version.InstallerImageDigest[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: fmt.Sprintf("%s/aro-installer:release-%s", dstRepo, vers.Version.MinorVersion()),
InstallerPullspec: installerPullSpec,
Enabled: true,
},
})
Expand Down
1 change: 1 addition & 0 deletions pkg/backend/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (ocb *openShiftClusterBackend) try(ctx context.Context) (bool, error) {
log = utillog.EnrichWithResourceID(log, doc.OpenShiftCluster.ID)
log = utillog.EnrichWithCorrelationData(log, doc.CorrelationData)
log = utillog.EnrichWithClusterVersion(log, doc.OpenShiftCluster.Properties.ClusterProfile.Version)
log = utillog.EnrichWithClusterDeploymentNamespace(log, doc.OpenShiftCluster.Properties.HiveProfile.Namespace)

if doc.Dequeues > maxDequeueCount {
err := fmt.Errorf("dequeued %d times, failing", doc.Dequeues)
Expand Down
28 changes: 0 additions & 28 deletions pkg/cluster/install_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cluster

import (
"context"
"fmt"
"strings"
"testing"

Expand All @@ -14,7 +13,6 @@ import (

"github.com/Azure/ARO-RP/pkg/api"
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
"github.com/Azure/ARO-RP/pkg/util/version"
testdatabase "github.com/Azure/ARO-RP/test/database"
"github.com/Azure/ARO-RP/test/util/deterministicuuid"
"github.com/Azure/ARO-RP/test/util/testliveconfig"
Expand All @@ -32,32 +30,6 @@ func TestGetOpenShiftVersionFromVersion(t *testing.T) {
wantErrString string
want *api.OpenShiftVersion
}{
{
name: "no versions gets default version",
f: func(f *testdatabase.Fixture) {},
m: manager{
doc: &api.OpenShiftClusterDocument{
Key: strings.ToLower(key),
OpenShiftCluster: &api.OpenShiftCluster{
ID: key,
Properties: api.OpenShiftClusterProperties{
ClusterProfile: api.ClusterProfile{
Version: version.DefaultInstallStream.Version.String(),
},
},
},
},
openShiftClusterDocumentVersioner: new(openShiftClusterDocumentVersionerService),
},
wantErrString: "",
want: &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: version.DefaultInstallStream.Version.String(),
OpenShiftPullspec: version.DefaultInstallStream.PullSpec,
InstallerPullspec: fmt.Sprintf("%s/aro-installer:release-%d.%d", testACRDomain, version.DefaultInstallStream.Version.V[0], version.DefaultInstallStream.Version.V[1]),
},
},
},
{
name: "select nonexistent version",
f: func(f *testdatabase.Fixture) {
Expand Down
50 changes: 6 additions & 44 deletions pkg/cluster/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ package cluster

import (
"context"
"fmt"
"net/http"
"strings"

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

// openShiftClusterDocumentVersioner is the interface that validates and obtains the version from an OpenShiftClusterDocument.
Expand All @@ -28,28 +26,6 @@ type openShiftClusterDocumentVersionerService struct{}
func (service *openShiftClusterDocumentVersionerService) Get(ctx context.Context, doc *api.OpenShiftClusterDocument, dbOpenShiftVersions database.OpenShiftVersions, env env.Interface, installViaHive bool) (*api.OpenShiftVersion, error) {
requestedInstallVersion := doc.OpenShiftCluster.Properties.ClusterProfile.Version

// Honor any installer pull spec override
installerPullSpec := env.LiveConfig().DefaultInstallerPullSpecOverride(ctx)
if installerPullSpec == "" {
installerPullSpec = fmt.Sprintf("%s/aro-installer:release-%s", env.ACRDomain(), version.DefaultInstallStream.Version.MinorVersion())
}

// add the default OCP version as we require it as an install target
// if this is removed, we need to also update the logic in
// pkg/frontend/frontend.go, pkg/frontend/validate.go
defaultVersion := &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: version.DefaultInstallStream.Version.String(),
OpenShiftPullspec: version.DefaultInstallStream.PullSpec,
InstallerPullspec: installerPullSpec,
Enabled: true,
},
}

if requestedInstallVersion == defaultVersion.Properties.Version {
return defaultVersion, nil
}

// TODO: Refactor to use changefeeds rather than querying the database every time
// should also leverage shared changefeed or shared logic
docs, err := dbOpenShiftVersions.ListAll(ctx)
Expand All @@ -66,31 +42,17 @@ func (service *openShiftClusterDocumentVersionerService) Get(ctx context.Context

errUnsupportedVersion := api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "properties.clusterProfile.version", "The requested OpenShift version '%s' is not supported.", requestedInstallVersion)

// when we have no OpenShiftVersion entries in CosmoDB, default to building one using the DefaultInstallStream
if len(activeOpenShiftVersions) == 0 {
if requestedInstallVersion != version.DefaultInstallStream.Version.String() {
return nil, errUnsupportedVersion
}

openshiftPullSpec := version.DefaultInstallStream.PullSpec
if installViaHive {
openshiftPullSpec = strings.Replace(openshiftPullSpec, "quay.io", env.ACRDomain(), 1)
}

return &api.OpenShiftVersion{
Properties: api.OpenShiftVersionProperties{
Version: version.DefaultInstallStream.Version.String(),
OpenShiftPullspec: openshiftPullSpec,
InstallerPullspec: installerPullSpec,
Enabled: true,
}}, nil
}

for _, active := range activeOpenShiftVersions {
if requestedInstallVersion == active.Properties.Version {
if installViaHive {
active.Properties.OpenShiftPullspec = strings.Replace(active.Properties.OpenShiftPullspec, "quay.io", env.ACRDomain(), 1)
}

// Honor any pull spec override set
installerPullSpecOverride := env.LiveConfig().DefaultInstallerPullSpecOverride(ctx)
if installerPullSpecOverride != "" {
active.Properties.InstallerPullspec = installerPullSpecOverride
}
return active, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/assets/env-development.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
"autoUpgradeMinorVersion": true,
"settings": {},
"protectedSettings": {
"script": "[base64(concat(base64ToString('c2V0IC1leAoK'),'PROXYIMAGE=$(base64 -d \u003c\u003c\u003c''',base64(parameters('proxyImage')),''')\n','PROXYIMAGEAUTH=$(base64 -d \u003c\u003c\u003c''',base64(parameters('proxyImageAuth')),''')\n','PROXYCERT=''',parameters('proxyCert'),'''\n','PROXYCLIENTCERT=''',parameters('proxyClientCert'),'''\n','PROXYKEY=''',parameters('proxyKey'),'''\n','\n',base64ToString('ZWNobyAicnVubmluZyBSSFVJIGZpeCIKeXVtIHVwZGF0ZSAteSAtLWRpc2FibGVyZXBvPScqJyAtLWVuYWJsZXJlcG89J3JodWktbWljcm9zb2Z0LWF6dXJlKicKCnl1bSAteSAteCBXQUxpbnV4QWdlbnQgLXggV0FMaW51eEFnZW50LXVkZXYgdXBkYXRlCnl1bSAteSBpbnN0YWxsIHBvZG1hbi1kb2NrZXIKCmZpcmV3YWxsLWNtZCAtLWFkZC1wb3J0PTQ0My90Y3AgLS1wZXJtYW5lbnQKCm1rZGlyIC9yb290Ly5kb2NrZXIKY2F0ID4vcm9vdC8uZG9ja2VyL2NvbmZpZy5qc29uIDw8RU9GCnsKCSJhdXRocyI6IHsKCQkiJHtQUk9YWUlNQUdFJSUvKn0iOiB7CgkJCSJhdXRoIjogIiRQUk9YWUlNQUdFQVVUSCIKCQl9Cgl9Cn0KRU9GCgpta2RpciAtcCAvZXRjL2NvbnRhaW5lcnMvCnRvdWNoIC9ldGMvY29udGFpbmVycy9ub2RvY2tlcgoKZG9ja2VyIHB1bGwgIiRQUk9YWUlNQUdFIgoKbWtkaXIgL2V0Yy9wcm94eQpiYXNlNjQgLWQgPDw8IiRQUk9YWUNFUlQiID4vZXRjL3Byb3h5L3Byb3h5LmNydApiYXNlNjQgLWQgPDw8IiRQUk9YWUtFWSIgPi9ldGMvcHJveHkvcHJveHkua2V5CmJhc2U2NCAtZCA8PDwiJFBST1hZQ0xJRU5UQ0VSVCIgPi9ldGMvcHJveHkvcHJveHktY2xpZW50LmNydApjaG93biAtUiAxMDAwOjEwMDAgL2V0Yy9wcm94eQpjaG1vZCAwNjAwIC9ldGMvcHJveHkvcHJveHkua2V5CgpjYXQgPi9ldGMvc3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base64ToString('c2V0IC1leAoK'),'PROXYIMAGE=$(base64 -d \u003c\u003c\u003c''',base64(parameters('proxyImage')),''')\n','PROXYIMAGEAUTH=$(base64 -d \u003c\u003c\u003c''',base64(parameters('proxyImageAuth')),''')\n','PROXYCERT=''',parameters('proxyCert'),'''\n','PROXYCLIENTCERT=''',parameters('proxyClientCert'),'''\n','PROXYKEY=''',parameters('proxyKey'),'''\n','\n',base64ToString('ZWNobyAicnVubmluZyBSSFVJIGZpeCIKeXVtIHVwZGF0ZSAteSAtLWRpc2FibGVyZXBvPScqJyAtLWVuYWJsZXJlcG89J3JodWktbWljcm9zb2Z0LWF6dXJlKicKCnl1bSAteSAteCBXQUxpbnV4QWdlbnQgLXggV0FMaW51eEFnZW50LXVkZXYgdXBkYXRlCnl1bSAteSBpbnN0YWxsIHBvZG1hbi1kb2NrZXIKCmZpcmV3YWxsLWNtZCAtLWFkZC1wb3J0PTQ0My90Y3AgLS1wZXJtYW5lbnQKCm1rZGlyIC9yb290Ly5kb2NrZXIKY2F0ID4vcm9vdC8uZG9ja2VyL2NvbmZpZy5qc29uIDw8RU9GCnsKCSJhdXRocyI6IHsKCQkiJHtQUk9YWUlNQUdFJSUvKn0iOiB7CgkJCSJhdXRoIjogIiRQUk9YWUlNQUdFQVVUSCIKCQl9Cgl9Cn0KRU9GCgpta2RpciAtcCAvZXRjL2NvbnRhaW5lcnMvCnRvdWNoIC9ldGMvY29udGFpbmVycy9ub2RvY2tlcgoKZG9ja2VyIHB1bGwgIiRQUk9YWUlNQUdFIgoKbWtkaXIgL2V0Yy9wcm94eQpiYXNlNjQgLWQgPDw8IiRQUk9YWUNFUlQiID4vZXRjL3Byb3h5L3Byb3h5LmNydApiYXNlNjQgLWQgPDw8IiRQUk9YWUtFWSIgPi9ldGMvcHJveHkvcHJveHkua2V5CmJhc2U2NCAtZCA8PDwiJFBST1hZQ0xJRU5UQ0VSVCIgPi9ldGMvcHJveHkvcHJveHktY2xpZW50LmNydApjaG93biAtUiAxMD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2V0Yy9jcm9uLndlZWtseS95dW11cGRhdGUKCmNhdCA+L2V0Yy9jcm9uLmRhaWx5L3Jlc3RhcnQtcHJveHkgPDwnRU9GJwojIS9iaW4vYmFzaAoKc3lzdGVtY3RsIHJlc3RhcnQgcHJveHkuc2VydmljZQpFT0YKY2htb2QgK3ggL2V0Yy9jcm9uLmRhaWx5L3Jlc3RhcnQtcHJveHkKCigKCXNsZWVwIDMwCglyZWJvb3QKKSAmCg==')))]"
},
"provisionAfterExtensions": [
"Microsoft.Azure.Monitor.AzureMonitorLinuxAgent",
Expand Down
7 changes: 7 additions & 0 deletions pkg/deploy/generator/scripts/devProxyVMSS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ yum update -y
EOF
chmod +x /etc/cron.weekly/yumupdate

cat >/etc/cron.daily/restart-proxy <<'EOF'
#!/bin/bash
systemctl restart proxy.service
EOF
chmod +x /etc/cron.daily/restart-proxy

(
sleep 30
reboot
Expand Down
11 changes: 1 addition & 10 deletions pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/Azure/ARO-RP/pkg/util/heartbeat"
utillog "github.com/Azure/ARO-RP/pkg/util/log"
"github.com/Azure/ARO-RP/pkg/util/recover"
"github.com/Azure/ARO-RP/pkg/util/version"
)

type statusCodeError int
Expand Down Expand Up @@ -164,15 +163,7 @@ func NewFrontend(ctx context.Context,

clusterEnricher: enricher,

// add default installation version so it's always supported
enabledOcpVersions: map[string]*api.OpenShiftVersion{
version.DefaultInstallStream.Version.String(): {
Properties: api.OpenShiftVersionProperties{
Version: version.DefaultInstallStream.Version.String(),
Enabled: true,
},
},
},
enabledOcpVersions: map[string]*api.OpenShiftVersion{},

bucketAllocator: &bucket.Random{},

Expand Down
12 changes: 11 additions & 1 deletion pkg/frontend/openshiftcluster_preflightvalidation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/metrics/noop"
"github.com/Azure/ARO-RP/pkg/util/version"
testdatabase "github.com/Azure/ARO-RP/test/database"
)

Expand Down Expand Up @@ -112,13 +113,22 @@ func TestPreflightValidation(t *testing.T) {
t.Fatal(err)
}

f, err := NewFrontend(ctx, ti.audit, ti.log, ti.env, ti.asyncOperationsDatabase, ti.clusterManagerDatabase, ti.openShiftClustersDatabase, ti.subscriptionsDatabase, nil, api.APIs, &noop.Noop{}, nil, nil, nil, nil, nil)
f, err := NewFrontend(ctx, ti.audit, ti.log, ti.env, ti.asyncOperationsDatabase, ti.clusterManagerDatabase, ti.openShiftClustersDatabase, ti.subscriptionsDatabase, ti.openShiftVersionsDatabase, api.APIs, &noop.Noop{}, nil, nil, nil, nil, nil)
if err != nil {
t.Fatal(err)
}
oc := tt.preflightRequest()

go f.Run(ctx, nil, nil)
f.mu.Lock()
f.enabledOcpVersions = map[string]*api.OpenShiftVersion{
version.DefaultInstallStream.Version.String(): {
Properties: api.OpenShiftVersionProperties{
Version: version.DefaultInstallStream.Version.String(),
},
},
}
f.mu.Unlock()

headers := http.Header{
"Content-Type": []string{"application/json"},
Expand Down
Loading

0 comments on commit 4a72b39

Please sign in to comment.