Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Ensure that delete jobs run when projects are deleted (#1893) #1886

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

thedadams
Copy link
Contributor

@thedadams thedadams commented Jul 6, 2023

There are a few situations where we need a buffer between a project being deleted and the corresponding namespace being deleted. One such scenario is ensuring that delete jobs run when a project is deleted.

This change adds a project instance, which is this buffer. Using the project instance, we can ensure that all apps are successfully cleaned up before the namespace is deleted. This should also give the user the ability to use the ignore-cleanup functionality when deleting a project.

Checklist

  • The title of this PR would make a good line in Acorn's Release Note's Changelog
  • The title of this PR ends with a link to the main issue being address in parentheses, like: This is a title (#1216). Here's an example
  • All relevant issues are referenced in the PR description. NOTE: don't use GitHub keywords that auto-close issues
  • Commits follow contributing guidance
  • Automated tests added to cover the changes. If tests couldn't be added, an explanation is provided in the Verification and Testing section
  • Changes to user-facing functionality, API, CLI, and upgrade impacts are clearly called out in PR description
  • PR has at least two approvals before merging (or a reasonable exception, like it's just a docs change)

Requires: acorn-io/baaah#90
Issue: #1893

@thedadams thedadams requested a review from ibuildthecloud July 6, 2023 02:21
@thedadams thedadams force-pushed the add-project-instances branch 2 times, most recently from fc30dfe to ba0246e Compare July 6, 2023 02:41
@@ -10,9 +10,6 @@ spec:
"": sample-compute-class
status:
observedGeneration: 1
defaults:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a duplicate entry.

@thedadams thedadams force-pushed the add-project-instances branch 7 times, most recently from 736086e to 0e92484 Compare July 6, 2023 18:10
Comment on lines +38 to +41
type projectCreater struct {
creater strategy.Creater
client kclient.Client
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I know the underlying typo/misspelling comes from mink, but I think this is worth changing anyway

Suggested change
type projectCreater struct {
creater strategy.Creater
client kclient.Client
}
type projectCreator struct {
creator strategy.Creater
client kclient.Client
}

(Would need to modify other parts of this file too.)

@thedadams thedadams requested a review from g-linville July 6, 2023 20:11
@thedadams thedadams force-pushed the add-project-instances branch 4 times, most recently from 560eb3f to e33a983 Compare July 7, 2023 15:24
@thedadams thedadams changed the title Ensure that delete jobs run when projects are deleted Ensure that delete jobs run when projects are deleted (#1893) Jul 7, 2023
if err := c.Get(ctx, kclient.ObjectKey{Namespace: "kube-system", Name: "acorn-controller"}, controllerLease); !apierror.IsNotFound(err) && err != nil {
return nil, err
}
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

the err here is not the err in the if statement above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. Will fix.

@@ -80,6 +82,14 @@ func baseResources(ctx context.Context, c kclient.Client) (resources []kclient.O
}
}

controllerLease := &coordinationv1.Lease{}
if err := c.Get(ctx, kclient.ObjectKey{Namespace: "kube-system", Name: "acorn-controller"}, controllerLease); !apierror.IsNotFound(err) && err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the lease live in acorn-system or kube-system?

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 lives in the kube-system namespace.

@thedadams thedadams force-pushed the add-project-instances branch from e33a983 to 0c2ecd4 Compare July 7, 2023 17:26
@thedadams thedadams force-pushed the add-project-instances branch from 0c2ecd4 to 20d54dc Compare July 7, 2023 17:33
There are a few situations where we need a buffer between a project
being deleted and the corresponding namespace being deleted. One such
scenario is ensuring that delete jobs run when a project is deleted.

This change adds a project instance, which is this buffer. Using the
project instance, we can ensure that all apps are successfully cleaned
up before the namespace is deleted. This should also give the user the
ability to use the ignore-cleanup functionality when deleting a project.

Changes are also made to the integration tests to use project instances
instead of namespaces.

Signed-off-by: Donnie Adams <[email protected]>
@thedadams thedadams force-pushed the add-project-instances branch from 20d54dc to 0b9b373 Compare July 7, 2023 19:47
@thedadams thedadams merged commit 0184d27 into acorn-io:main Jul 7, 2023
@thedadams thedadams deleted the add-project-instances branch July 7, 2023 20:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants