Merge pull request #65823 from loburm/fix_truncate

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix truncating and batch backends integration.

Truncating backend was not starting batch thread that is responsible for reading events from the channel.

Fixes https://github.com/kubernetes/kubernetes/pull/65819

```release-note
None
```
This commit is contained in:
Kubernetes Submit Queue 2018-07-09 04:28:58 -07:00 committed by GitHub
commit 40806a2660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -102,6 +102,7 @@ type bufferedBackend struct {
var _ audit.Backend = &bufferedBackend{} var _ audit.Backend = &bufferedBackend{}
// NewBackend returns a buffered audit backend that wraps delegate backend. // NewBackend returns a buffered audit backend that wraps delegate backend.
// Buffered backend automatically runs and shuts down the delegate backend.
func NewBackend(delegate audit.Backend, config BatchConfig) audit.Backend { func NewBackend(delegate audit.Backend, config BatchConfig) audit.Backend {
var throttle flowcontrol.RateLimiter var throttle flowcontrol.RateLimiter
if config.ThrottleEnable { if config.ThrottleEnable {

View File

@ -62,6 +62,7 @@ type backend struct {
var _ audit.Backend = &backend{} var _ audit.Backend = &backend{}
// NewBackend returns a new truncating backend, using configuration passed in the parameters. // NewBackend returns a new truncating backend, using configuration passed in the parameters.
// Truncate backend automatically runs and shut downs the delegate backend.
func NewBackend(delegateBackend audit.Backend, config Config, groupVersion schema.GroupVersion) audit.Backend { func NewBackend(delegateBackend audit.Backend, config Config, groupVersion schema.GroupVersion) audit.Backend {
return &backend{ return &backend{
delegateBackend: delegateBackend, delegateBackend: delegateBackend,
@ -128,12 +129,11 @@ func truncate(e *auditinternal.Event) *auditinternal.Event {
} }
func (b *backend) Run(stopCh <-chan struct{}) error { func (b *backend) Run(stopCh <-chan struct{}) error {
// Nothing to do here return b.delegateBackend.Run(stopCh)
return nil
} }
func (b *backend) Shutdown() { func (b *backend) Shutdown() {
// Nothing to do here b.delegateBackend.Shutdown()
} }
func (b *backend) calcSize(e *auditinternal.Event) (int64, error) { func (b *backend) calcSize(e *auditinternal.Event) (int64, error) {