-
Notifications
You must be signed in to change notification settings - Fork 764
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
fix: #3146 Support close open/fail for Ready Tracker & surface errors swallowed by grp.Wait() #3308
fix: #3146 Support close open/fail for Ready Tracker & surface errors swallowed by grp.Wait() #3308
Conversation
0b9e1f4
to
96644d8
Compare
25e891e
to
2c5000d
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.
Thank you for the PR! Added a couple comments.
e1fa4a6
to
cbfcfc8
Compare
Separating out constraint template v1beta1 -> v1 changes in separate PR. |
77559ff
to
7c5e5a0
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.
LGTM after nit, thank you!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3308 +/- ##
==========================================
- Coverage 54.49% 47.83% -6.67%
==========================================
Files 134 219 +85
Lines 12329 14884 +2555
==========================================
+ Hits 6719 7120 +401
- Misses 5116 6955 +1839
- Partials 494 809 +315
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
1705b33
to
aa2b049
Compare
c9601c0
to
7d63dbf
Compare
Thanks for the PR @David-Jaeyoon-Lee |
ab0fdbb
to
bf1ac93
Compare
pkg/readiness/ready_tracker.go
Outdated
@@ -45,7 +45,7 @@ import ( | |||
logf "sigs.k8s.io/controller-runtime/pkg/log" | |||
) | |||
|
|||
var crashOnFailureFetchingExpectations = flag.Bool("crash-on-failure-fetching-expectations", false, "When set (defaults to false), gatekeeper will ignore errors that occur when gathering expectations. This prevents bootstrapping errors from crashing Gatekeeper at the cost of increasing the risk Gatekeeper will under-enforce policy by serving before it has loaded in all policies. Enabling this will help prevent under-enforcement at the risk of crashing during startup for issues like network errors.") | |||
var crashOnFailureFetchingExpectations = flag.Bool("crash-on-failure-fetching-expectations", false, "When set (defaults to false), gatekeeper will ignore errors that occur when gathering expectations. This prevents bootstrapping errors from crashing Gatekeeper at the cost of increasing the risk Gatekeeper will under-enforce policy by serving before it has loaded in all policies. Enabling this will help prevent under-enforcement at the risk of crashing during startup for issues like network errors. Note that enabling this flag currently does not achieve the aforementioned effect since fetching expectations are set to retry until success so failures during fetching expectations currently do not occurr.") |
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.
@maxsmythe Just wanted to double check this wording
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.
"When set" -> "unless set"
fc45d15
to
1b69eac
Compare
I still need to fix lint errors for the Error return value is not checked for the goroutine deleted object polling. Any ideas on how to fix this? @maxsmythe |
ef710df
to
f6ee82e
Compare
bbf995a
to
6df8c51
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.
LGTM with nits
Thank you for figuring this out!
@@ -46,6 +46,8 @@ import ( | |||
|
|||
var log = logf.Log.WithName("readiness-tracker") | |||
|
|||
var crashOnFailureFetchingExpectations = flag.Bool("crash-on-failure-fetching-expectations", false, "Unless set (defaults to false), gatekeeper will ignore errors that occur when gathering expectations. This prevents bootstrapping errors from crashing Gatekeeper at the cost of increasing the risk Gatekeeper will under-enforce policy by serving before it has loaded in all policies. Enabling this will help prevent under-enforcement at the risk of crashing during startup for issues like network errors. Note that enabling this flag currently does not achieve the aforementioned effect since fetching expectations are set to retry until success so failures during fetching expectations currently do not occur.") |
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: I think this can be shortened
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 you mean the naming or the description or both?
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.
Description
Add fail-close support for fetching expectations by adding error handling & surfacing the errors being swallowed by grp.Wait(). Signed-off-by: David-Jaeyoon-Lee <[email protected]>
Remove the starting hyphen from the crash-on-failure-fetching-expectations flag Signed-off-by: David-Jaeyoon-Lee <[email protected]>
and add unit tests Fix comments and return error in trackConfigAndSyncSets. Add unit tests for each track method & each wait in Run method. Signed-off-by: David-Jaeyoon-Lee <[email protected]>
in test Signed-off-by: David-Jaeyoon-Lee <[email protected]>
Change errgroup logic such that we instead use waitgroups and errchannels. This is that we remove the idea of shared fate between each tracking/subtracking threads. Removes complexity of figuring out what the errgroups are doing as well as complicated logic with shared fate between tracking threads and singlerunners Signed-off-by: David-Jaeyoon-Lee <[email protected]>
Signed-off-by: David-Jaeyoon-Lee <[email protected]>
4f8a07d
to
f874270
Compare
Signed-off-by: David-Jaeyoon-Lee <[email protected]>
@David-Jaeyoon-Lee Unit tests are failing |
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.
code LGTM. @David-Jaeyoon-Lee unit tests are failing.
Unit test passed, re-running to check for flakiness. |
Running once more to check. |
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.
LGTM
Thank you for the PR!
… & surface errors swallowed by grp.Wait() (open-policy-agent#3308) Signed-off-by: David-Jaeyoon-Lee <[email protected]> Co-authored-by: Sertaç Özercan <[email protected]> Co-authored-by: Jaydipkumar Arvindbhai Gabani <[email protected]>
What this PR does / why we need it:
This change fixes Run() method in Ready Tracker to have a fail-close option so that if we fail to fetch expectations we surface those errors & fail. By default, this won't be enabled & we will fail-open.
Which issue(s) this PR fixes (optional, using
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when the PR gets merged):Fixes #3146
Special notes for your reviewer: Refer to issue link for more information