mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Fix portforward test flake with GOMAXPROCS > 1
This commit is contained in:
parent
9eb0970bdb
commit
11b4a9601b
@ -178,6 +178,8 @@ func (s *fakeUpgradeStream) Read(p []byte) (int, error) {
|
|||||||
s.readCalled = true
|
s.readCalled = true
|
||||||
b := []byte(s.data)
|
b := []byte(s.data)
|
||||||
n := copy(p, b)
|
n := copy(p, b)
|
||||||
|
// Indicate we returned all the data, and have no more data (EOF)
|
||||||
|
// Returning an EOF here will cause the port forwarder to immediately terminate, which is correct when we have no more data to send
|
||||||
return n, io.EOF
|
return n, io.EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,9 +187,10 @@ func (s *fakeUpgradeStream) Write(p []byte) (int, error) {
|
|||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
s.writeCalled = true
|
s.writeCalled = true
|
||||||
s.dataWritten = make([]byte, len(p))
|
s.dataWritten = append(s.dataWritten, p...)
|
||||||
copy(s.dataWritten, p)
|
// Indicate the stream accepted all the data, and can accept more (no err)
|
||||||
return len(p), io.EOF
|
// Returning an EOF here will cause the port forwarder to immediately terminate, which is incorrect, in case someone writes more data
|
||||||
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *fakeUpgradeStream) Close() error {
|
func (s *fakeUpgradeStream) Close() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user