Skip to content

Commit

Permalink
Check before migration app deletion (#390)
Browse files Browse the repository at this point in the history
* check before migration app deletion

* adding changelog
  • Loading branch information
tomahawk28 authored Jun 30, 2020
1 parent 509ee94 commit 5c77102
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s

## [Unreleased]

### Changed

- Delete migration app after checking the release.

## [v1.1.6] 2020-06-29

### Changed
Expand Down
16 changes: 13 additions & 3 deletions service/controller/app/resource/releasemigration/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ func (r *Resource) Name() string {
}

func (r *Resource) deleteMigrationApp(ctx context.Context, helmClient helmclient.Interface, tillerNamespace string) error {
err := helmClient.DeleteRelease(ctx, tillerNamespace, migrationApp)
_, err := helmClient.GetReleaseContent(ctx, tillerNamespace, migrationApp)
if helmclient.IsReleaseNotFound(err) {
// migration app had been deleted already.
// no-op
return nil
} else if err != nil {
return microerror.Mask(err)
}

err = helmClient.DeleteRelease(ctx, tillerNamespace, migrationApp)
if err != nil {
return microerror.Mask(err)
}
Expand Down Expand Up @@ -135,16 +144,17 @@ func (r *Resource) ensureReleasesMigrated(ctx context.Context, k8sClient k8sclie
}
if len(releases) > 0 {
desc := fmt.Sprintf("%d helm v2 releases not migrated", len(releases))
r.logger.Log("level", "debug", "message", desc)
r.logger.LogCtx(ctx, "level", "debug", "message", desc)

return microerror.Maskf(executionFailedError, desc)
}
r.logger.LogCtx(ctx, "level", "debug", "message", "migration completed")

return nil
}

n := func(err error, t time.Duration) {
r.logger.Log("level", "debug", "message", "migration not complete")
r.logger.LogCtx(ctx, "level", "debug", "message", "migration not complete")
}

b := backoff.NewConstant(5*time.Minute, 10*time.Second)
Expand Down

0 comments on commit 5c77102

Please sign in to comment.