Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit ca45885

Browse files
authored
Merge pull request #137 from JoshVanL/periodic-flushing
Adds --flush-interval to set the flush interval of proxy handler
2 parents a14bc6a + 5eeb7b8 commit ca45885

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

cmd/app/options/app.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
package options
33

44
import (
5+
"time"
6+
57
"github.com/spf13/pflag"
68
cliflag "k8s.io/component-base/cli/flag"
79

@@ -12,6 +14,8 @@ type KubeOIDCProxyOptions struct {
1214
DisableImpersonation bool
1315
ReadinessProbePort int
1416

17+
FlushInterval time.Duration
18+
1519
ExtraHeaderOptions ExtraHeaderOptions
1620
TokenPassthrough TokenPassthroughOptions
1721
}
@@ -39,6 +43,12 @@ func (k *KubeOIDCProxyOptions) AddFlags(fs *pflag.FlagSet) *KubeOIDCProxyOptions
3943
fs.IntVarP(&k.ReadinessProbePort, "readiness-probe-port", "P", 8080,
4044
"Port to expose readiness probe.")
4145

46+
fs.DurationVar(&k.FlushInterval, "flush-interval", time.Millisecond*50,
47+
"Specifies the interval to flush request bodies. If 0ms, "+
48+
"no periodic flushing is done. A negative value means to flush "+
49+
"immediately after each write. Streaming requests such as 'kubectl exec' "+
50+
"will ignore this option and flush immediately.")
51+
4252
k.TokenPassthrough.AddFlags(fs)
4353
k.ExtraHeaderOptions.AddFlags(fs)
4454

cmd/app/run.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ func buildRunCommand(stopCh <-chan struct{}, opts *options.Options) *cobra.Comma
7676
TokenReview: opts.App.TokenPassthrough.Enabled,
7777
DisableImpersonation: opts.App.DisableImpersonation,
7878

79+
FlushInterval: opts.App.FlushInterval,
80+
7981
ExtraUserHeaders: opts.App.ExtraHeaderOptions.ExtraUserHeaders,
8082
ExtraUserHeadersClientIPEnabled: opts.App.ExtraHeaderOptions.EnableClientIPExtraUserHeader,
8183
}

pkg/proxy/proxy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ type Options struct {
4343
DisableImpersonation bool
4444
TokenReview bool
4545

46+
FlushInterval time.Duration
47+
4648
ExtraUserHeaders map[string][]string
4749
ExtraUserHeadersClientIPEnabled bool
4850
}
@@ -127,6 +129,7 @@ func (p *Proxy) Run(stopCh <-chan struct{}) (<-chan struct{}, error) {
127129
proxyHandler := httputil.NewSingleHostReverseProxy(url)
128130
proxyHandler.Transport = p
129131
proxyHandler.ErrorHandler = p.Error
132+
proxyHandler.FlushInterval = p.options.FlushInterval
130133

131134
waitCh, err := p.serve(proxyHandler, stopCh)
132135
if err != nil {

0 commit comments

Comments
 (0)