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

updating reconciler to understand how to delete resources in groups based on iac dependencies #815

Merged
merged 4 commits into from
Dec 12, 2023

Conversation

jhsinger-klotho
Copy link
Contributor

makes the reconciliation check iac dependencies of namespaced resources to see if we need to clean up more than just the namespaced resources

Standard checks

  • Unit tests: Any special considerations?
  • Docs: Do we need to update any docs, internal or public?
  • Backwards compatibility: Will this break existing apps? If so, what would be the extra work required to keep them working?

Copy link
Contributor

@gordon-klotho gordon-klotho left a comment

Choose a reason for hiding this comment

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

Can you add an engine test for the delete? Maybe covering both use-cases (delete namespace resources & delete deploy dependencies)

Comment on lines +59 to +64
namespacedResources, err := findAllResourcesInNamespace(c, resource)
if err != nil {
errs = errors.Join(errs, err)
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: move this closer to where it's used below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we cant, ill add a comment, but it hast to be done before we remove the resource otherwise those resources wont be namespaced anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

The edges shouldn't impact it, since it looks like it just walks the graph. But for removing the resource, makes sense. In that case, can the for loop be moved up?

continue
}

for _, res := range namespacedResources.ToSlice() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for _, res := range namespacedResources.ToSlice() {
for res := range namespacedResources {

nit: don't need to copy the set to iterate it


for _, res := range namespacedResources.ToSlice() {

// Since we are explicitly deleting the namespace resource, we will explicitly delete the resources namespaced to it
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: update comment, we're forwarding the explicit here, the comment suggests that it's passing in true

found = true
}
default:
if reflect.ValueOf(val).Kind() == reflect.Slice || reflect.ValueOf(val).Kind() == reflect.Array {
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look deeper into maps, or lists of lists but that can be a TODO. Only case it might be relevant is for policies that have a PropertyRef.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well that should be ok because doesnt loop properties get all indices of lists and keys of maps?

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, but then shouldn't this not need to be added since it'd go into each index?

Comment on lines 26 to 30
queue := make([]deleteRequest, 0)
queue = append(queue, deleteRequest{
resource: resource,
explicit: explicit,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
queue := make([]deleteRequest, 0)
queue = append(queue, deleteRequest{
resource: resource,
explicit: explicit,
})
queue := []deleteRequest{{
resource: resource,
explicit: explicit,
}}

nit: more concise

@jhsinger-klotho jhsinger-klotho merged commit dbc2f00 into main Dec 12, 2023
6 checks passed
@jhsinger-klotho jhsinger-klotho deleted the reconcile_iac branch December 12, 2023 21:38
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.

2 participants