-
Notifications
You must be signed in to change notification settings - Fork 38
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
Conversation
1bd1def
to
5cfecb5
Compare
There was a problem hiding this 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)
namespacedResources, err := findAllResourcesInNamespace(c, resource) | ||
if err != nil { | ||
errs = errors.Join(errs, err) | ||
continue | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
pkg/engine2/reconciler/reconciler.go
Outdated
continue | ||
} | ||
|
||
for _, res := range namespacedResources.ToSlice() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for _, res := range namespacedResources.ToSlice() { | |
for res := range namespacedResources { |
nit: don't need to copy the set to iterate it
pkg/engine2/reconciler/reconciler.go
Outdated
|
||
for _, res := range namespacedResources.ToSlice() { | ||
|
||
// Since we are explicitly deleting the namespace resource, we will explicitly delete the resources namespaced to it |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
pkg/engine2/reconciler/reconciler.go
Outdated
queue := make([]deleteRequest, 0) | ||
queue = append(queue, deleteRequest{ | ||
resource: resource, | ||
explicit: explicit, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queue := make([]deleteRequest, 0) | |
queue = append(queue, deleteRequest{ | |
resource: resource, | |
explicit: explicit, | |
}) | |
queue := []deleteRequest{{ | |
resource: resource, | |
explicit: explicit, | |
}} |
nit: more concise
5cfecb5
to
4db827f
Compare
4db827f
to
ac10893
Compare
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