mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #98961 from aojea/donotleak
Do not leak files on iptables unit tests
This commit is contained in:
commit
63f89493ec
@ -1025,6 +1025,9 @@ func TestRestoreAllWaitOldIptablesRestore(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
lockPath14x, lockPath16x := getLockPaths()
|
lockPath14x, lockPath16x := getLockPaths()
|
||||||
|
// the lockPath14x is a UNIX socket which is cleaned up automatically on close, but the
|
||||||
|
// lockPath16x is a plain file which is not cleaned up.
|
||||||
|
defer os.Remove(lockPath16x)
|
||||||
runner := newInternal(&fexec, ProtocolIPv4, lockPath14x, lockPath16x)
|
runner := newInternal(&fexec, ProtocolIPv4, lockPath14x, lockPath16x)
|
||||||
|
|
||||||
err := runner.RestoreAll([]byte{}, NoFlushTables, RestoreCounters)
|
err := runner.RestoreAll([]byte{}, NoFlushTables, RestoreCounters)
|
||||||
@ -1077,7 +1080,10 @@ func TestRestoreAllGrabNewLock(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected to open %s, got %v", lockPath16x, err)
|
t.Fatalf("expected to open %s, got %v", lockPath16x, err)
|
||||||
}
|
}
|
||||||
defer runLock.Close()
|
defer func() {
|
||||||
|
runLock.Close()
|
||||||
|
os.Remove(lockPath16x)
|
||||||
|
}()
|
||||||
|
|
||||||
if err := grabIptablesFileLock(runLock); err != nil {
|
if err := grabIptablesFileLock(runLock); err != nil {
|
||||||
t.Errorf("expected to lock %s, got %v", lockPath16x, err)
|
t.Errorf("expected to lock %s, got %v", lockPath16x, err)
|
||||||
@ -1111,6 +1117,9 @@ func TestRestoreAllGrabOldLock(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
lockPath14x, lockPath16x := getLockPaths()
|
lockPath14x, lockPath16x := getLockPaths()
|
||||||
|
// the lockPath14x is a UNIX socket which is cleaned up automatically on close, but the
|
||||||
|
// lockPath16x is a plain file which is not cleaned up.
|
||||||
|
defer os.Remove(lockPath16x)
|
||||||
runner := newInternal(&fexec, ProtocolIPv4, lockPath14x, lockPath16x)
|
runner := newInternal(&fexec, ProtocolIPv4, lockPath14x, lockPath16x)
|
||||||
|
|
||||||
var runLock *net.UnixListener
|
var runLock *net.UnixListener
|
||||||
|
Loading…
Reference in New Issue
Block a user