Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Nov 26, 2024
1 parent 65867a0 commit ce04d56
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
5 changes: 4 additions & 1 deletion pkg/embeddedcluster/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ func startClusterUpgrade(

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

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

err = runClusterUpgrade(ctx, k8sClient, newInstall, registrySettings, license, versionLabel)
if err != nil {
if err := NotifyUpgradeFailed(ctx, license.Spec.Endpoint, newInstall, current, err.Error()); err != nil {
logger.Errorf("Failed to notify upgrade failed: %v", err)
}
return fmt.Errorf("run cluster upgrade: %w", err)
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,14 +1052,14 @@ func (o *Operator) waitForClusterUpgrade(appID string, appSlug string) error {
}
if embeddedcluster.InstallationSucceeded(ctx, ins) {
logger.Infof("Cluster upgrade succeeded")
if err := o.notifyUpgradeSucceeded(ctx, kbClient, ins, appID); err != nil {
if err := o.notifyClusterUpgradeSucceeded(ctx, kbClient, ins, appID); err != nil {
logger.Errorf("Failed to notify upgrade succeeded: %v", err)
}
return nil
}
if embeddedcluster.InstallationFailed(ctx, ins) {
logger.Infof("Cluster upgrade failed")
if err := o.notifyUpgradeFailed(ctx, kbClient, ins, appID); err != nil {
if err := o.notifyClusterUpgradeFailed(ctx, kbClient, ins, appID); err != nil {
logger.Errorf("Failed to notify upgrade failed: %v", err)
}
if err := upgradeservicetask.SetStatusUpgradeFailed(appSlug, ins.Status.Reason); err != nil {
Expand All @@ -1074,8 +1074,8 @@ func (o *Operator) waitForClusterUpgrade(appID string, appSlug string) error {
}
}

// notifyUpgradeSucceeded sends a metrics event to the api that the upgrade succeeded.
func (o *Operator) notifyUpgradeSucceeded(ctx context.Context, kbClient kbclient.Client, ins *embeddedclusterv1beta1.Installation, appID string) error {
// notifyClusterUpgradeSucceeded sends a metrics event to the api that the upgrade succeeded.
func (o *Operator) notifyClusterUpgradeSucceeded(ctx context.Context, kbClient kbclient.Client, ins *embeddedclusterv1beta1.Installation, appID string) error {
if ins.Spec.AirGap {
return nil
}
Expand All @@ -1099,8 +1099,8 @@ func (o *Operator) notifyUpgradeSucceeded(ctx context.Context, kbClient kbclient
return nil
}

// notifyUpgradeFailed sends a metrics event to the api that the upgrade failed.
func (o *Operator) notifyUpgradeFailed(ctx context.Context, kbClient kbclient.Client, ins *embeddedclusterv1beta1.Installation, appID string) error {
// notifyClusterUpgradeFailed sends a metrics event to the api that the upgrade failed.
func (o *Operator) notifyClusterUpgradeFailed(ctx context.Context, kbClient kbclient.Client, ins *embeddedclusterv1beta1.Installation, appID string) error {
if ins.Spec.AirGap {
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/upgradeservice/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ func Deploy(opts DeployOptions) error {
go func() (finalError error) {
defer func() {
if finalError != nil {
if err := notifyUpgradeFailed(context.Background(), kbClient, opts, finalError.Error()); err != nil {
logger.Errorf("Failed to notify upgrade failed: %v", err)
}
if err := task.SetStatusUpgradeFailed(opts.Params.AppSlug, finalError.Error()); err != nil {
logger.Error(errors.Wrap(err, "failed to set task status to upgrade failed"))
}
Expand All @@ -145,6 +142,9 @@ func Deploy(opts DeployOptions) error {
tgzArchiveKey: tgzArchiveKey,
requiresClusterUpgrade: true,
}); err != nil {
if err := notifyClusterUpgradeFailed(context.Background(), kbClient, opts, finalError.Error()); err != nil {
logger.Errorf("Failed to notify upgrade failed: %v", err)
}
return errors.Wrap(err, "failed to create deployment")
}

Expand All @@ -154,8 +154,8 @@ func Deploy(opts DeployOptions) error {
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 {
// notifyClusterUpgradeFailed sends a metrics event to the api that the upgrade failed.
func notifyClusterUpgradeFailed(ctx context.Context, kbClient kbclient.Client, opts DeployOptions, reason string) error {
ins, err := embeddedcluster.GetCurrentInstallation(ctx, kbClient)
if err != nil {
return fmt.Errorf("failed to get current installation: %w", err)
Expand Down

0 comments on commit ce04d56

Please sign in to comment.