-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Audit use buffered backend #60237
Audit use buffered backend #60237
Conversation
5d8bb64
to
502a2b1
Compare
/assign @yliaog |
<-b.shutdownCh | ||
|
||
// Wait until all sending routines exit. | ||
b.wg.Wait() |
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 believe the new wg shutdown logic is correct:
- when
b.shutdownCh
is closed, we know that the go routine inRun
has terminated. - this means that
processIncomingEvents
has terminated - which means that b.buffer is closed and cannot accept any new events anymore.
- because
processEvents
is called synchronously from theRun
go routine, the waitgroup has its final value. - Hence,
wg.Wait
will not miss any more outgoing batches.
Should we put this proof into a comment (follow-up is fine)?
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.
Sounds good, added a comment
// recover from. | ||
defer func() { | ||
if err := recover(); err != nil { | ||
sendErr = fmt.Errorf("panic when processing events: %v", err) |
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 liked the old error message more. The new one sounds like something is broken.
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.
Agree, done
d27e4d4
to
6900f27
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.
@sttts Thanks for the review, comments addressed
<-b.shutdownCh | ||
|
||
// Wait until all sending routines exit. | ||
b.wg.Wait() |
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.
Sounds good, added a comment
// recover from. | ||
defer func() { | ||
if err := recover(); err != nil { | ||
sendErr = fmt.Errorf("panic when processing events: %v", err) |
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.
Agree, done
161d1a3
to
4a42acb
Compare
/approve |
4a42acb
to
503c0a7
Compare
/assign @thockin Could you please approve this PR for the new dependency? |
503c0a7
to
68cfc48
Compare
/approve |
68cfc48
to
2a54b3b
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, except the flag issue
fs.DurationVar(&o.BatchConfig.InitialBackoff, "audit-webhook-batch-initial-backoff", | ||
o.BatchConfig.InitialBackoff, "The amount of time to wait before retrying the "+ | ||
"first failed requests. Only used in batch mode.") | ||
fs.DurationVar(&o.InitialBackoff, "audit-webhook-initial-backoff", |
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.
Unfortunately you can't just change flags (see deprecation policy, #5b). I suggest marking the old one as deprecated, and making it an alias for the new one.
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.
Good point, thanks, done
2a54b3b
to
c870cab
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.
@tallclair Thanks! PTAL
fs.DurationVar(&o.BatchConfig.InitialBackoff, "audit-webhook-batch-initial-backoff", | ||
o.BatchConfig.InitialBackoff, "The amount of time to wait before retrying the "+ | ||
"first failed requests. Only used in batch mode.") | ||
fs.DurationVar(&o.InitialBackoff, "audit-webhook-initial-backoff", |
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.
Good point, thanks, done
"first failed requests.") | ||
fs.DurationVar(&o.InitialBackoff, "audit-webhook-batch-initial-backoff", | ||
o.InitialBackoff, "The amount of time to wait before retrying the first failed "+ | ||
"requests. Deprecated, use --audit-webhook-initial-backoff instead.") |
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.
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.
Thanks! Was deceived by an example in another file
Done
Signed-off-by: Mik Vyatskov <vmik@google.com>
c870cab
to
881e6d4
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: crassirostris, sttts, tallclair, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Automatic merge from submit-queue (batch tested with PRs 60542, 60237). If you want to cherry-pick this change to another branch, please follow the instructions here. |
audit e2e tests started flaking as soon as this merged. tracking in #60719 |
LogOptions: AuditLogOptions{ | ||
Format: pluginlog.FormatJson, | ||
BatchOptions: AuditBatchOptions{ | ||
Mode: ModeBatch, |
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 changes default behavior of log backend.
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.
There is already a pull request: #60739
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 know, this is a conscious decision. I believe batching is always better by default than blocking
This is the next step after #60076
This PR fixes #53020, to address #53006 later
In this PR buffered backend, introduced in #60076, is used to replace ad-hoc solution for webhook and add an ability to enable buffering for the log audit backend.
/cc @sttts @tallclair @ericchiang @CaoShuFeng