fix: delete sockets on shim exit

Signed-off-by: Henry Wang <henwang@amazon.com>
This commit is contained in:
Henry Wang
2024-05-08 21:21:55 +00:00
parent bfdc224861
commit d9dc2811ae
4 changed files with 81 additions and 3 deletions

View File

@@ -279,3 +279,14 @@ func dialHybridVsock(address string, timeout time.Duration) (net.Conn, error) {
}
return hybridVsockDialer(addr, port, timeout)
}
func cleanupSockets(ctx context.Context) {
if address, err := ReadAddress("address"); err == nil {
_ = RemoveSocket(address)
}
if len(socketFlag) > 0 {
_ = RemoveSocket("unix://" + socketFlag)
} else if address, err := SocketAddress(ctx, addressFlag, id); err == nil {
_ = RemoveSocket(address)
}
}