Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Nov 21, 2024
1 parent d37d3ed commit 58829b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
6 changes: 6 additions & 0 deletions pkg/embeddedcluster/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
dockerregistrytypes "github.com/replicatedhq/kots/pkg/docker/registry/types"
"github.com/replicatedhq/kots/pkg/imageutil"
"github.com/replicatedhq/kots/pkg/k8sutil"
"github.com/replicatedhq/kots/pkg/logger"
registrytypes "github.com/replicatedhq/kots/pkg/registry/types"
"github.com/replicatedhq/kots/pkg/util"
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
Expand Down Expand Up @@ -75,6 +76,11 @@ func startClusterUpgrade(

log.Printf("Starting cluster upgrade to version %s...", newcfg.Version)

// We cannot notify the upgrade started until the new install is created
if err := NotifyUpgradeStarted(ctx, license.Spec.Endpoint, newInstall, current); err != nil {
logger.Errorf("Failed to notify upgrade started: %v", err)
}

err = runClusterUpgrade(ctx, k8sClient, newInstall, registrySettings, license, versionLabel)
if err != nil {
return fmt.Errorf("run cluster upgrade: %w", err)
Expand Down
29 changes: 0 additions & 29 deletions pkg/upgradeservice/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ func Deploy(opts DeployOptions) error {
defer close(finishedCh)
tasks.StartTicker(task.GetID(opts.Params.AppSlug), finishedCh)

if err := notifyUpgradeStarted(context.Background(), kbClient, opts); err != nil {
logger.Errorf("Failed to notify upgrade started: %v", err)
}

if err := embeddedcluster.StartClusterUpgrade(context.Background(), opts.KotsKinds, opts.RegistrySettings); err != nil {
return errors.Wrap(err, "failed to start cluster upgrade")
}
Expand All @@ -158,31 +154,6 @@ func Deploy(opts DeployOptions) error {
return nil
}

// notifyUpgradeStarted sends a metrics event to the api that the upgrade started.
func notifyUpgradeStarted(ctx context.Context, kbClient kbclient.Client, opts DeployOptions) error {
ins, err := embeddedcluster.GetCurrentInstallation(ctx, kbClient)
if err != nil {
return fmt.Errorf("failed to get current installation: %w", err)
}

if ins.Spec.AirGap {
return nil
}

prev, err := embeddedcluster.GetPreviousInstallation(ctx, kbClient)
if err != nil {
return errors.Wrap(err, "failed to get previous installation")
} else if prev == nil {
return errors.New("previous installation not found")
}

err = embeddedcluster.NotifyUpgradeStarted(ctx, opts.KotsKinds.License.Spec.Endpoint, ins, prev)
if err != nil {
return errors.Wrap(err, "failed to send event")
}
return nil
}

// notifyUpgradeFailed sends a metrics event to the api that the upgrade failed.
func notifyUpgradeFailed(ctx context.Context, kbClient kbclient.Client, opts DeployOptions, reason string) error {
ins, err := embeddedcluster.GetCurrentInstallation(ctx, kbClient)
Expand Down

0 comments on commit 58829b0

Please sign in to comment.