Skip to content

Commit 53b85c4

Browse files
committed
security: handle transient files in certificate directory loading
The 'TestDemoLocality' was failing with "no certificates found; does certs dir exist?" errors. This resulted in connection failures when nodes attempted to establish RPC connections. Root cause: The demo cluster stores both TLS certificates and Unix socket files (e.g., .s.PGSQL.26267) in the same directory. When loading certificates, readDir() lists all directory entries and then calls entry.Info() to stat each file. Between these operations, transient socket lock files (e.g., .s.PGSQL.26267.lock.887590299) can be deleted, causing lstat() to fail with ENOENT. This caused the entire certificate loading to fail, even though the actual certificate files existed and were valid. Fix: this change modified the readDir() to skip files that disappear between directory listing and stat operations (a standard pattern for handling concurrent file-system modifications). Fixes #155255 Epic: none Release note: None
1 parent 21b75ac commit 53b85c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/security/securityassets/security_assets.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ func readDir(dirname string) ([]os.FileInfo, error) {
6969
for _, entry := range entries {
7070
info, err := entry.Info()
7171
if err != nil {
72+
// Skip files that disappeared between ReadDir and Info().
73+
// This can happen when the directory contains transient files
74+
// like Unix socket lock files that are created/deleted rapidly.
75+
if oserror.IsNotExist(err) {
76+
continue
77+
}
7278
return nil, err
7379
}
7480
infos = append(infos, info)

0 commit comments

Comments
 (0)