Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into laverya/sc-116440/run…
Browse files Browse the repository at this point in the history
…-online-tests-on-prerelease
  • Loading branch information
laverya committed Dec 2, 2024
2 parents 3a841d4 + cbdc74f commit 6ce9b5d
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 167 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export K0S_VERSION=$(make print-K0S_VERSION)
export EC_VERSION=$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')
export EC_VERSION=$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')
export SHORT_SHA=dev-${{ needs.git-sha.outputs.git_sha }}
export APP_VERSION=appver-dev-${{ needs.git-sha.outputs.git_sha }}
# avoid rate limiting
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
run: |
export K0S_VERSION=$(make print-PREVIOUS_K0S_VERSION)
export K0S_GO_VERSION=$(make print-PREVIOUS_K0S_GO_VERSION)
export EC_VERSION=$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-previous-k0s
export EC_VERSION=$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')-previous-k0s
export APP_VERSION=appver-dev-${{ needs.git-sha.outputs.git_sha }}-previous-k0s
# avoid rate limiting
export FIO_VERSION=$(gh release list --repo axboe/fio --json tagName,isLatest | jq -r '.[] | select(.isLatest==true)|.tagName' | cut -d- -f2)
Expand Down Expand Up @@ -357,7 +357,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export K0S_VERSION=$(make print-K0S_VERSION)
export EC_VERSION=$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-upgrade
export EC_VERSION=$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')-upgrade
export APP_VERSION=appver-dev-${{ needs.git-sha.outputs.git_sha }}-upgrade
# avoid rate limiting
export FIO_VERSION=$(gh release list --repo axboe/fio --json tagName,isLatest | jq -r '.[] | select(.isLatest==true)|.tagName' | cut -d- -f2)
Expand Down Expand Up @@ -481,25 +481,25 @@ jobs:
./scripts/ci-release-app.sh
# install the previous k0s version to ensure an upgrade occurs
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-previous-k0s"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')-previous-k0s"
export APP_VERSION="appver-${SHORT_SHA}-previous-k0s"
export RELEASE_YAML_DIR=e2e/kots-release-install
./scripts/ci-release-app.sh
# then install the current k0s version
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}"
export RELEASE_YAML_DIR=e2e/kots-release-install
./scripts/ci-release-app.sh
# then a noop upgrade
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}-noop"
export RELEASE_YAML_DIR=e2e/kots-release-install
./scripts/ci-release-app.sh
# and finally an app upgrade
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-upgrade"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')-upgrade"
export APP_VERSION="appver-${SHORT_SHA}-upgrade"
export RELEASE_YAML_DIR=e2e/kots-release-upgrade
./scripts/ci-release-app.sh
Expand All @@ -521,19 +521,19 @@ jobs:
./scripts/ci-release-app.sh
# install the previous k0s version to ensure an upgrade occurs
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-previous-k0s"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')-previous-k0s"
export APP_VERSION="appver-${SHORT_SHA}-previous-k0s"
export RELEASE_YAML_DIR=e2e/kots-release-install
./scripts/ci-release-app.sh
# then install the current k0s version
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}"
export RELEASE_YAML_DIR=e2e/kots-release-install
./scripts/ci-release-app.sh
# and finally an app upgrade
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')-upgrade"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')-upgrade"
export APP_VERSION="appver-${SHORT_SHA}-upgrade"
export RELEASE_YAML_DIR=e2e/kots-release-upgrade
./scripts/ci-release-app.sh
Expand All @@ -542,7 +542,7 @@ jobs:
if: github.event_name == 'pull_request'
run: |
export SHORT_SHA=dev-${{ needs.git-sha.outputs.git_sha }}
export EC_VERSION="$(git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')"
export EC_VERSION="$(git describe --tags --abbrev=4 --match='[0-9]*.[0-9]*.[0-9]*')"
export APP_VERSION="appver-${SHORT_SHA}"
echo "This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app [license ID](https://vendor.staging.replicated.com/apps/embedded-cluster-smoke-test-staging-app/customers?sort=name-asc)." > download-link.txt
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ rebuild-release: check-env-EC_VERSION check-env-APP_VERSION
./scripts/build-and-release.sh

.PHONY: upgrade-release
upgrade-release: export EC_VERSION = $(VERSION)-$(CURRENT_USER)-upgrade
upgrade-release: export APP_VERSION = appver-dev-$(call random-string)-upgrade
upgrade-release: RANDOM_STRING = $(call random-string)
upgrade-release: export EC_VERSION = $(VERSION)-$(CURRENT_USER)-upgrade-$(RANDOM_STRING)
upgrade-release: export APP_VERSION = appver-dev-$(call random-string)-upgrade-$(RANDOM_STRING)
upgrade-release: check-env-EC_VERSION check-env-APP_VERSION
UPLOAD_BINARIES=1 \
RELEASE_YAML_DIR=e2e/kots-release-upgrade \
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MELANGE ?= $(LOCALBIN)/melange
APKO ?= $(LOCALBIN)/apko

## Version to use for building
VERSION ?= $(shell git describe --tags --match='[0-9]*.[0-9]*.[0-9]*')
VERSION ?= $(shell git describe --tags --match='[0-9]*.[0-9]*.[0-9]*' --abbrev=4)

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/aws/aws-sdk-go-v2 v1.32.5
github.com/aws/aws-sdk-go-v2/config v1.28.5
github.com/aws/aws-sdk-go-v2/credentials v1.17.46
github.com/aws/aws-sdk-go-v2/service/s3 v1.68.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0
github.com/bombsimon/logrusr/v4 v4.1.0
github.com/canonical/lxd v0.0.0-20241030172432-dee0d04b56ee
github.com/containers/image/v5 v5.33.0
Expand All @@ -23,12 +23,12 @@ require (
github.com/google/go-github/v62 v62.0.0
github.com/google/uuid v1.6.0
github.com/gosimple/slug v1.14.0
github.com/jedib0t/go-pretty/v6 v6.6.2
github.com/jedib0t/go-pretty/v6 v6.6.3
github.com/k0sproject/dig v0.3.1
github.com/k0sproject/k0s v1.30.7-0.20241029184556-a942e759e13b
github.com/ohler55/ojg v1.25.0
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.35.1
github.com/onsi/gomega v1.36.0
github.com/replicatedhq/embedded-cluster/kinds v0.0.0
github.com/replicatedhq/embedded-cluster/utils v0.0.0
github.com/replicatedhq/kotskinds v0.0.0-20240814191029-3f677ee409a0
Expand Down Expand Up @@ -323,7 +323,7 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/websocket v1.5.1
github.com/gorilla/websocket v1.5.3
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 h1:wtpJ4zcwr
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5/go.mod h1:qu/W9HXQbbQ4+1+JcZp0ZNPV31ym537ZJN+fiS7Ti8E=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.5 h1:P1doBzv5VEg1ONxnJss1Kh5ZG/ewoIE4MQtKKc6Crgg=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.5/go.mod h1:NOP+euMW7W3Ukt28tAxPuoWao4rhhqJD3QEBk7oCg7w=
github.com/aws/aws-sdk-go-v2/service/s3 v1.68.0 h1:bFpcqdwtAEsgpZXvkTxIThFQx/EM0oV6kXmfFIGjxME=
github.com/aws/aws-sdk-go-v2/service/s3 v1.68.0/go.mod h1:ralv4XawHjEMaHOWnTFushl0WRqim/gQWesAMF6hTow=
github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0 h1:Q2ax8S21clKOnHhhr933xm3JxdJebql+R7aNo7p7GBQ=
github.com/aws/aws-sdk-go-v2/service/s3 v1.69.0/go.mod h1:ralv4XawHjEMaHOWnTFushl0WRqim/gQWesAMF6hTow=
github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 h1:3zu537oLmsPfDMyjnUS2g+F2vITgy5pB74tHI+JBNoM=
github.com/aws/aws-sdk-go-v2/service/sso v1.24.6/go.mod h1:WJSZH2ZvepM6t6jwu4w/Z45Eoi75lPN7DcydSRtJg6Y=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 h1:K0OQAsDywb0ltlFrZm0JHPY3yZp/S9OaoLU33S7vPS8=
Expand Down Expand Up @@ -674,8 +674,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gosimple/slug v1.14.0 h1:RtTL/71mJNDfpUbCOmnf/XFkzKRtD6wL6Uy+3akm4Es=
github.com/gosimple/slug v1.14.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=
Expand Down Expand Up @@ -730,8 +730,8 @@ github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jedib0t/go-pretty/v6 v6.6.2 h1:27bLj3nRODzaiA7tPIxy9UVWHoPspFfME9XxgwiiNsM=
github.com/jedib0t/go-pretty/v6 v6.6.2/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
github.com/jedib0t/go-pretty/v6 v6.6.3 h1:nGqgS0tgIO1Hto47HSaaK4ac/I/Bu7usmdD3qvs0WvM=
github.com/jedib0t/go-pretty/v6 v6.6.3/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
github.com/jeremija/gosubmit v0.2.7 h1:At0OhGCFGPXyjPYAsCchoBUhE099pcBXmsb4iZqROIc=
github.com/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
Expand Down Expand Up @@ -908,8 +908,8 @@ github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/onsi/gomega v1.36.0 h1:Pb12RlruUtj4XUuPUqeEWc6j5DkVVVA49Uf6YLfC95Y=
github.com/onsi/gomega v1.36.0/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
Expand Down
5 changes: 4 additions & 1 deletion operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ include ../common.mk
OS ?= linux
ARCH ?= $(shell go env GOARCH)

ADMIN_CONSOLE_IMAGE_OVERRIDE =

# VERSION defines the project version for the bundle.
# Update this value when you upgrade the version of your project.
# To re-generate a bundle for another specific version without changing the standard setup, you can:
Expand All @@ -27,7 +29,8 @@ export PATH := $(shell pwd)/bin:$(PATH)

LD_FLAGS = \
-X github.com/replicatedhq/embedded-cluster/pkg/versions.K0sVersion=$(K0S_VERSION) \
-X github.com/replicatedhq/embedded-cluster/pkg/versions.Version=$(VERSION)
-X github.com/replicatedhq/embedded-cluster/pkg/versions.Version=$(VERSION) \
-X github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole.AdminConsoleImageOverride=$(ADMIN_CONSOLE_IMAGE_OVERRIDE)

# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
Expand Down
47 changes: 0 additions & 47 deletions operator/controllers/installation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,47 +248,6 @@ func (r *InstallationReconciler) ReportNodesChanges(ctx context.Context, in *v1b
}
}

// ReportInstallationChanges reports back to the metrics server if the installation status has changed.
func (r *InstallationReconciler) ReportInstallationChanges(ctx context.Context, before, after *v1beta1.Installation) {
if len(before.Status.State) == 0 || before.Status.State == after.Status.State {
return
}
var err error
var beforeVer, afterVer string
if before.Spec.Config != nil {
beforeVer = before.Spec.Config.Version
}
if after.Spec.Config != nil {
afterVer = after.Spec.Config.Version
}
switch after.Status.State {
case v1beta1.InstallationStateInstalling:
if beforeVer != "" {
err = metrics.NotifyUpgradeStarted(ctx, after.Spec.MetricsBaseURL, metrics.UpgradeStartedEvent{
ClusterID: after.Spec.ClusterID,
TargetVersion: afterVer,
InitialVersion: beforeVer,
})
}
case v1beta1.InstallationStateInstalled:
err = metrics.NotifyUpgradeSucceeded(ctx, after.Spec.MetricsBaseURL, metrics.UpgradeSucceededEvent{
ClusterID: after.Spec.ClusterID,
TargetVersion: afterVer,
InitialVersion: beforeVer,
})
case v1beta1.InstallationStateFailed:
err = metrics.NotifyUpgradeFailed(ctx, after.Spec.MetricsBaseURL, metrics.UpgradeFailedEvent{
ClusterID: after.Spec.ClusterID,
Reason: after.Status.Reason,
TargetVersion: afterVer,
InitialVersion: beforeVer,
})
}
if err != nil {
ctrl.LoggerFrom(ctx).Error(err, "failed to notify cluster installation status")
}
}

func (r *InstallationReconciler) ReconcileOpenebs(ctx context.Context, in *v1beta1.Installation) error {
log := ctrl.LoggerFrom(ctx)

Expand Down Expand Up @@ -642,11 +601,6 @@ func (r *InstallationReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, fmt.Errorf("failed to update installation status: %w", err)
}

// we create a copy of the installation so we can compare if it
// changed its status after the reconcile (this is mostly for
// calling back to us with events).
before := in.DeepCopy()

// verify if a new node has been added, removed or changed.
events, err := r.ReconcileNodeStatuses(ctx, in)
if err != nil {
Expand Down Expand Up @@ -698,7 +652,6 @@ func (r *InstallationReconciler) Reconcile(ctx context.Context, req ctrl.Request
// if we are not in an airgap environment this is the time to call back to
// replicated and inform the status of this installation.
if !in.Spec.AirGap {
r.ReportInstallationChanges(ctx, before, in)
r.ReportNodesChanges(ctx, in, events)
}

Expand Down
2 changes: 1 addition & 1 deletion operator/deploy/apko.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contents:
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
- ./melange.rsa.pub
packages:
- embedded-cluster-operator # This is expected to be built locally by `melange`.
- ec-operator # This is expected to be built locally by `melange`.
- ca-certificates-bundle

accounts:
Expand Down
2 changes: 1 addition & 1 deletion operator/deploy/melange.tmpl.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package:
name: embedded-cluster-operator
name: ec-operator
version: ${PACKAGE_VERSION}
epoch: 0
description: Embedded Cluster Operator
Expand Down
11 changes: 0 additions & 11 deletions operator/pkg/cli/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

clusterv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
"github.com/replicatedhq/embedded-cluster/operator/pkg/k8sutil"
"github.com/replicatedhq/embedded-cluster/operator/pkg/metrics"
"github.com/replicatedhq/embedded-cluster/operator/pkg/upgrade"
"github.com/replicatedhq/embedded-cluster/pkg/kubeutils"
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
Expand Down Expand Up @@ -63,16 +62,6 @@ func UpgradeCmd() *cobra.Command {
if err != nil {
return fmt.Errorf("failed to upgrade: %w", err)
}
if !in.Spec.AirGap {
err = metrics.NotifyUpgradeStarted(cmd.Context(), in.Spec.MetricsBaseURL, metrics.UpgradeStartedEvent{
ClusterID: in.Spec.ClusterID,
TargetVersion: in.Spec.Config.Version,
InitialVersion: previousInstallation.Spec.Config.Version,
})
if err != nil {
fmt.Printf("failed to report that the upgrade was started: %v\n", err)
}
}

fmt.Println("Upgrade job created successfully")

Expand Down
15 changes: 0 additions & 15 deletions operator/pkg/cli/upgrade_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package cli

import (
"fmt"
"strings"
"time"

"github.com/replicatedhq/embedded-cluster/operator/pkg/k8sutil"
"github.com/replicatedhq/embedded-cluster/operator/pkg/metrics"
"github.com/replicatedhq/embedded-cluster/operator/pkg/upgrade"
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
"github.com/replicatedhq/embedded-cluster/pkg/versions"
Expand Down Expand Up @@ -48,25 +46,12 @@ func UpgradeJobCmd() *cobra.Command {
fmt.Printf("Upgrading to installation %s (version %s)\n", in.Name, in.Spec.Config.Version)

i := 0
allErrors := []string{}
sleepDuration := time.Second * 5
for {
err = upgrade.Upgrade(cmd.Context(), cli, in)
if err != nil {
fmt.Printf("Upgrade failed, retrying: %s\n", err.Error())
allErrors = append(allErrors, err.Error())
if i >= 10 {
if !in.Spec.AirGap {
err = metrics.NotifyUpgradeFailed(cmd.Context(), in.Spec.MetricsBaseURL, metrics.UpgradeFailedEvent{
ClusterID: in.Spec.ClusterID,
TargetVersion: in.Spec.Config.Version,
InitialVersion: previousInstallationVersion,
Reason: strings.Join(allErrors, ", "),
})
if err != nil {
fmt.Printf("failed to report that the upgrade was started: %v\n", err)
}
}
return fmt.Errorf("failed to upgrade after %s", (sleepDuration * time.Duration(i)).String())
}

Expand Down
Loading

0 comments on commit 6ce9b5d

Please sign in to comment.