Skip to content

Commit a764f6b

Browse files
committed
fix: prevent hypervisor socket deletion during CAA rolling restart
During a rolling update, the old and new CAA pods share the same hostPath (/run/peerpod/). When the old pod's ttrpc.Shutdown() calls listener.Close(), it unlinks the socket file that the new pod already created, leaving the shim unable to connect. Set SetUnlinkOnClose(false) on the Unix listener so the old pod's shutdown does not remove the socket inode. The new pod's startup already handles cleanup via os.RemoveAll before creating a fresh socket. Signed-off-by: Thejas N <thn@redhat.com>
1 parent 10f23af commit a764f6b

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/cloud-api-adaptor/pkg/adaptor/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func (s *server) Start(ctx context.Context) (err error) {
124124
if err != nil {
125125
return err
126126
}
127+
listener.(*net.UnixListener).SetUnlinkOnClose(false)
127128

128129
ttRPCErr := make(chan error)
129130
go func() {

src/cloud-api-adaptor/pkg/adaptor/server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ func testServerShutdown(t *testing.T, s Server, socketPath, dir string, serverEr
174174
if err := <-serverErrCh; err != nil {
175175
t.Error(err)
176176
}
177-
if _, err := os.Stat(socketPath); err == nil {
178-
t.Errorf("Unix domain socket %s still remains\n", socketPath)
177+
if _, err := os.Stat(socketPath); err != nil {
178+
t.Errorf("Unix domain socket %s should remain after shutdown (SetUnlinkOnClose(false))\n", socketPath)
179179
}
180180
if err := os.RemoveAll(dir); err != nil {
181181
t.Error(err)

0 commit comments

Comments
 (0)