Skip to content

Commit 0128d4a

Browse files
committed
Remove forked sysinfo package
During the migration to containerd v2, we forked sysinfo as docker was still depending on containerd v1 at that time. With their latest 28 release, docker has now moved on, and we can get rid of the fork. There is a few minor changes required to make it work: - move to runtime.NumCPU as the sysinfo indirection has been removed - remove use of deprecated fields Signed-off-by: apostasie <spam_blackhole@farcloser.world>
1 parent 66a7a75 commit 0128d4a

16 files changed

+26
-1129
lines changed

go.mod

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ module github.com/containerd/nerdctl/v2
22

33
go 1.22.7
44

5-
// FIXME:
6-
// github.com/docker/docker/pkg/sysinfo has been replaced by a fork kept under ./pkg2/sysinfo
7-
// as Moby is not going to move to containerd v2 anytime soon or fix these transient dependencies.
8-
// We should still move back to upstream in the future, and remove our copy.
9-
105
require (
116
github.com/Masterminds/semver/v3 v3.3.1
127
github.com/Microsoft/go-winio v0.6.2
@@ -35,8 +30,8 @@ require (
3530
github.com/coreos/go-systemd/v22 v22.5.0
3631
github.com/cyphar/filepath-securejoin v0.4.1
3732
github.com/distribution/reference v0.6.0
38-
github.com/docker/cli v27.5.1+incompatible
39-
github.com/docker/docker v27.5.1+incompatible
33+
github.com/docker/cli v28.0.0+incompatible
34+
github.com/docker/docker v28.0.0+incompatible
4035
github.com/docker/go-connections v0.5.0
4136
github.com/docker/go-units v0.5.0
4237
github.com/fahedouch/go-logrotate v0.2.1
@@ -48,7 +43,6 @@ require (
4843
github.com/klauspost/compress v1.18.0
4944
github.com/mattn/go-isatty v0.0.20
5045
github.com/moby/sys/mount v0.3.4
51-
github.com/moby/sys/mountinfo v0.7.2
5246
github.com/moby/sys/signal v0.7.1
5347
github.com/moby/sys/userns v0.1.0
5448
github.com/moby/term v0.5.2
@@ -106,6 +100,7 @@ require (
106100
github.com/mitchellh/go-homedir v1.1.0 // indirect
107101
github.com/moby/docker-image-spec v1.3.1 // indirect
108102
github.com/moby/locker v1.0.1 // indirect
103+
github.com/moby/sys/mountinfo v0.7.2 // indirect
109104
github.com/moby/sys/sequential v0.6.0 // indirect
110105
github.com/moby/sys/symlink v0.3.0 // indirect
111106
github.com/moby/sys/user v0.3.0 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr
9090
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
9191
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
9292
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
93-
github.com/docker/cli v27.5.1+incompatible h1:JB9cieUT9YNiMITtIsguaN55PLOHhBSz3LKVc6cqWaY=
94-
github.com/docker/cli v27.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
95-
github.com/docker/docker v27.5.1+incompatible h1:4PYU5dnBYqRQi0294d1FBECqT9ECWeQAIfE8q4YnPY8=
96-
github.com/docker/docker v27.5.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
93+
github.com/docker/cli v28.0.0+incompatible h1:ido37VmLUqEp+5NFb9icd6BuBB+SNDgCn+5kPCr2buA=
94+
github.com/docker/cli v28.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
95+
github.com/docker/docker v28.0.0+incompatible h1:Olh0KS820sJ7nPsBKChVhk5pzqcwDR15fumfAd/p9hM=
96+
github.com/docker/docker v28.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
9797
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
9898
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
9999
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=

pkg/infoutil/infoutil_freebsd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
package infoutil
1818

1919
import (
20+
"github.com/docker/docker/pkg/sysinfo"
21+
2022
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
21-
"github.com/containerd/nerdctl/v2/pkg/sysinfo"
2223
)
2324

2425
const UnameO = "FreeBSD"

pkg/infoutil/infoutil_linux.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ package infoutil
1818

1919
import (
2020
"fmt"
21+
"runtime"
2122
"strings"
2223

2324
"github.com/docker/docker/pkg/meminfo"
25+
"github.com/docker/docker/pkg/sysinfo"
2426

2527
"github.com/containerd/cgroups/v3"
2628

2729
"github.com/containerd/nerdctl/v2/pkg/apparmorutil"
2830
"github.com/containerd/nerdctl/v2/pkg/defaults"
2931
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
3032
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
31-
"github.com/containerd/nerdctl/v2/pkg/sysinfo"
3233
)
3334

3435
const UnameO = "GNU/Linux"
@@ -113,15 +114,19 @@ func fulfillPlatformInfo(info *dockercompat.Info) {
113114
if !info.IPv4Forwarding {
114115
info.Warnings = append(info.Warnings, "WARNING: IPv4 forwarding is disabled")
115116
}
116-
info.BridgeNfIptables = !mobySysInfo.BridgeNFCallIPTablesDisabled
117+
// FIXME: BridgeNFCallIP6TablesDisabled is deprecated in moby and always false now
118+
// Figure out what we want to do with this
119+
info.BridgeNfIptables = true // !mobySysInfo.BridgeNFCallIPTablesDisabled
117120
if !info.BridgeNfIptables {
118121
info.Warnings = append(info.Warnings, "WARNING: bridge-nf-call-iptables is disabled")
119122
}
120-
info.BridgeNfIP6tables = !mobySysInfo.BridgeNFCallIP6TablesDisabled
123+
// FIXME: BridgeNFCallIP6TablesDisabled is deprecated in moby and always false now
124+
// Figure out what we want to do with this
125+
info.BridgeNfIP6tables = true // !mobySysInfo.BridgeNFCallIP6TablesDisabled
121126
if !info.BridgeNfIP6tables {
122127
info.Warnings = append(info.Warnings, "WARNING: bridge-nf-call-ip6tables is disabled")
123128
}
124-
info.NCPU = sysinfo.NumCPU()
129+
info.NCPU = runtime.NumCPU()
125130
memLimit, err := meminfo.Read()
126131
if err != nil {
127132
info.Warnings = append(info.Warnings, fmt.Sprintf("failed to read mem info: %v", err))

pkg/infoutil/infoutil_windows.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import (
2222
"strings"
2323

2424
"github.com/docker/docker/pkg/meminfo"
25+
"github.com/docker/docker/pkg/sysinfo"
2526
"golang.org/x/sys/windows"
2627
"golang.org/x/sys/windows/registry"
2728

2829
"github.com/containerd/log"
2930

3031
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
31-
"github.com/containerd/nerdctl/v2/pkg/sysinfo"
3232
)
3333

3434
const UnameO = "Microsoft Windows"
@@ -204,15 +204,19 @@ func fulfillPlatformInfo(info *dockercompat.Info) {
204204
if !info.IPv4Forwarding {
205205
info.Warnings = append(info.Warnings, "WARNING: IPv4 forwarding is disabled")
206206
}
207-
info.BridgeNfIptables = !mobySysInfo.BridgeNFCallIPTablesDisabled
207+
// FIXME: BridgeNFCallIP6TablesDisabled is deprecated in moby and always false now
208+
// Figure out what we want to do with this
209+
info.BridgeNfIptables = true // !mobySysInfo.BridgeNFCallIPTablesDisabled
208210
if !info.BridgeNfIptables {
209211
info.Warnings = append(info.Warnings, "WARNING: bridge-nf-call-iptables is disabled")
210212
}
211-
info.BridgeNfIP6tables = !mobySysInfo.BridgeNFCallIP6TablesDisabled
213+
// FIXME: BridgeNFCallIP6TablesDisabled is deprecated in moby and always false now
214+
// Figure out what we want to do with this
215+
info.BridgeNfIP6tables = true // !mobySysInfo.BridgeNFCallIP6TablesDisabled
212216
if !info.BridgeNfIP6tables {
213217
info.Warnings = append(info.Warnings, "WARNING: bridge-nf-call-ip6tables is disabled")
214218
}
215-
info.NCPU = sysinfo.NumCPU()
219+
info.NCPU = runtime.NumCPU()
216220
memLimit, err := meminfo.Read()
217221
if err != nil {
218222
info.Warnings = append(info.Warnings, fmt.Sprintf("failed to read mem info: %v", err))

pkg/sysinfo/cgroup2_linux.go

Lines changed: 0 additions & 169 deletions
This file was deleted.

pkg/sysinfo/doc.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

pkg/sysinfo/numcpu.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)