-
Notifications
You must be signed in to change notification settings - Fork 784
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
Improve init container to use DeleteCollection to remove policy reports #2477
Conversation
Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
cmd/initContainer/main.go
Outdated
go deleteResource(client, "", kind, ns.GetName(), reportName, &wg) | ||
} | ||
wg.Wait() | ||
go func(namespaceName string) { |
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.
Do we still want to spin up goroutines? Not sure if it would improve runtime.
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.
I will try and test that with Kind to see if there is any improvement.
My only concern with using |
This is because the name changes for the report. Those three names were added just to ensure all reports should be deleted. With |
Signed-off-by: Trey Dockendorf <tdockendorf@osc.edu>
I am testing with Kind 0.11.1 which is Kubernetes 1.21.1. I created 500 namespaces:
I restarted Kyverno deployment to trigger init container and this resulted in a bunch of throttling messages like this:
The end result was the init container took 1 minute and 39 seconds. First and last log messages:
I then removed the go routine so the function was simply a loop over all namespaces deleting all policy reports and that took 1 minute 40 seconds. First and last log messages without go routine:
So it seems that the go routine isn't needed. I've removed it so just loops over namespaces. |
The e2e failures look unrelated to this change, since failed on some mutate or other thing unrelated to this. |
No, the failure has nothing to do with your changes. Is there anything you want to add? Otherwise we can merge it. |
Only thing I can think of is I wonder if a new change is needed to avoid running the removes multiple times when starting HA pair pods. My deployment has replica count of 2 and noticed the long running init container was run for both pods. I wonder if maybe need to improve logic so that only the leader runs these processes or is the leader election not done till after the init container runs? |
Yes @ojhaarjun1 is working on leader election for the init container #1965. |
Excellent, then I think nothing else needed on this pull request. |
Signed-off-by: Trey Dockendorf tdockendorf@osc.edu
Related issue
Relates to #2474 but not sure if solves.
Milestone of this PR
What type of PR is this
Proposed Changes
Checklist
Further Comments
Based on feedback from #2474 but not sure if solves the issue encountered where containers would go into crash loops and dump traces.