Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SHIPA-2024] Prunes dead apps from framework status when removing framework #171

Merged
merged 2 commits into from
Oct 21, 2021

Conversation

stinkyfingers
Copy link
Contributor

Description

Deleting a framework and it's apps simultaneously, e.g. terraform, script, etc. can occasionally create a situation where an app is removed, but is still in the framework's framework.Status.Apps list. This can cause frustration since a user cannot remove the framework ("contains running apps" error) nor can they remove the already-removed app. This PR prunes non-existent apps from the framework.Status.Apps list prior to the framework delete.

Fixes # 2024

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Chore (documentation addition or typo, file relocation)

Testing

  • New tests were added with this PR that prove my fix is effective or that my feature works (describe below this bullet)
  • This change requires no testing (i.e. documentation update)

Documentation

  • All added public packages, funcs, and types have been documented with doc comments
  • I have commented my code, particularly in hard-to-understand areas

Final Checklist:

  • I followed standard GitHub flow guidelines
  • I have performed a self-review of my own code
  • My changes generate no new warnings

@@ -48,6 +49,9 @@ func frameworkRemove(ctx context.Context, cfg config, options frameworkRemoveOpt
return fmt.Errorf("failed to get framework: %w", err)
}

if err := pruneRemovedAppsFromStatus(ctx, cfg, framework); err != nil {
return fmt.Errorf("failed to update framework's apps: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be better to have the message say failed to prune framework's apps: just for a little bit more clarification?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sure would. Change made.

Copy link
Contributor

@DavisFrench DavisFrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion, but nothing that is an actual concern.
Excited to see this problem fixed!

patchedFramework := framework
patchedFramework.Status.Apps = updatedApps
patch := client.MergeFrom(&framework)
return cfg.Client().Status().Patch(ctx, &patchedFramework, patch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a chance to get the object has been modified; please apply your changes to the latest version and try again? retry.RetryOnConflict()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I added it around the entire pruneRemovedAppsFromStatus function.

@stinkyfingers stinkyfingers merged commit 36e993c into main Oct 21, 2021
@stinkyfingers stinkyfingers deleted the shipa-2024 branch October 21, 2021 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants