Skip to content

Commit 0fe79b6

Browse files
authored
Merge pull request containerd#10346 from mauri870/hotfix/gotip-test
Fix TestNewBinaryIOCleanup failing with gotip
2 parents 6c6eac5 + f0aecaa commit 0fe79b6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cmd/containerd-shim-runc-v2/process/io_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ package process
2020

2121
import (
2222
"context"
23+
"fmt"
2324
"net/url"
2425
"os"
26+
"strings"
2527
"testing"
2628

2729
"github.com/containerd/containerd/v2/pkg/namespaces"
@@ -68,5 +70,28 @@ func TestNewBinaryIOCleanup(t *testing.T) {
6870
func descriptorCount(t *testing.T) int {
6971
t.Helper()
7072
files, _ := os.ReadDir("/proc/self/fd")
73+
74+
// Go 1.23 introduced a new internal file descriptor type "pidfd"
75+
// that we don't want to count towards the total file descriptors in
76+
// use by the process. This retains the behavior of previous Go
77+
// versions.
78+
// See https://go.dev/issues/62654.
79+
//
80+
// Once the proposal to check for internal file descriptors is
81+
// accepted, we can use that instead to detect internal fds in use
82+
// by the Go runtime.
83+
// See https://go.dev/issues/67639.
84+
for i, file := range files {
85+
sym, err := os.Readlink(fmt.Sprintf("/proc/self/fd/%s", file.Name()))
86+
if err != nil {
87+
// ignore fds that cannot be followed.
88+
continue
89+
}
90+
91+
if strings.HasPrefix(sym, "pidfd:") {
92+
files = append(files[:i], files[i+1:]...)
93+
}
94+
}
95+
7196
return len(files)
7297
}

0 commit comments

Comments
 (0)