mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
rename to sharedLimitWriter
This commit is contained in:
parent
a4230055f3
commit
0e178f9341
@ -81,8 +81,8 @@ func (d *dockerService) GetContainerLogs(_ context.Context, pod *v1.Pod, contain
|
|||||||
if logOptions.LimitBytes != nil {
|
if logOptions.LimitBytes != nil {
|
||||||
// stdout and stderr share the total write limit
|
// stdout and stderr share the total write limit
|
||||||
max := *logOptions.LimitBytes
|
max := *logOptions.LimitBytes
|
||||||
stderr = limitedWriter(stderr, &max)
|
stderr = sharedLimitWriter(stderr, &max)
|
||||||
stdout = limitedWriter(stdout, &max)
|
stdout = sharedLimitWriter(stdout, &max)
|
||||||
}
|
}
|
||||||
sopts := libdocker.StreamOptions{
|
sopts := libdocker.StreamOptions{
|
||||||
OutputStream: stdout,
|
OutputStream: stdout,
|
||||||
|
@ -426,7 +426,7 @@ func (w sharedWriteLimiter) Write(p []byte) (int, error) {
|
|||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func limitedWriter(w io.Writer, limit *int64) io.Writer {
|
func sharedLimitWriter(w io.Writer, limit *int64) io.Writer {
|
||||||
if w == nil {
|
if w == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ func TestLimitedWriter(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
limit := tc.limit
|
limit := tc.limit
|
||||||
w := limitedWriter(&tc.w, &limit)
|
w := sharedLimitWriter(&tc.w, &limit)
|
||||||
n, err := w.Write([]byte(tc.toWrite))
|
n, err := w.Write([]byte(tc.toWrite))
|
||||||
if int64(n) > max(0, tc.limit) {
|
if int64(n) > max(0, tc.limit) {
|
||||||
t.Fatalf("bytes written (%d) exceeds limit (%d)", n, tc.limit)
|
t.Fatalf("bytes written (%d) exceeds limit (%d)", n, tc.limit)
|
||||||
@ -421,8 +421,8 @@ func TestLimitedWriter(t *testing.T) {
|
|||||||
var (
|
var (
|
||||||
b1, b2 bytes.Buffer
|
b1, b2 bytes.Buffer
|
||||||
limit = int64(10)
|
limit = int64(10)
|
||||||
w1 = limitedWriter(&b1, &limit)
|
w1 = sharedLimitWriter(&b1, &limit)
|
||||||
w2 = limitedWriter(&b2, &limit)
|
w2 = sharedLimitWriter(&b2, &limit)
|
||||||
ch = make(chan struct{})
|
ch = make(chan struct{})
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user