Skip to content

Commit e7452e4

Browse files
thaJeztahfahedouch
authored andcommitted
go.mod: cut circular dependency on github.com/containerd/containerd
This forces vendoring to only take dependencies of this repository to be taken into account, effectively cutting the circular dependency (for the vendored code), and to prevent depending on transitive dependencies coming from older versions of containerd. go mod does not allow using the main module as a local "replace" rule using a path; see golang/go#45492 and golang/go#34417, so instead, an empty module is used. One change observed is that older versions containerd depended on an older version of imgcrypt that had an "indirect" dependency on more current versions of gopkg.in/yaml.v2 and prometheus/procfs. For those, a temporary "indirect" dependency was added, until prometheus/client_golang and kubernetes are updated. from go mod graph (before): github.com/containerd/imgcrypt@v1.0.4-0.20210301171431-0ae5c75f59ba gopkg.in/yaml.v2@v2.4.0 github.com/containerd/imgcrypt@v1.0.4-0.20210301171431-0ae5c75f59ba github.com/prometheus/procfs@v0.6.0 For some reason, some older versions of containerd are still taken into account, causing satori/go.uuid to be added as "indirect" dependency, likely because some modules have this dependency in their go.sum. This should likely disappear once those plugins are updated to contain a current version of containerd. git grep 'github.com/satori/go.uuid' vendor/github.com/Microsoft/hcsshim/go.sum:github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= vendor/github.com/containerd/aufs/go.sum:github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= vendor/github.com/containerd/imgcrypt/go.sum:github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= vendor/github.com/containerd/nri/go.sum:github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= vendor/github.com/containerd/zfs/go.sum:github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 659a85b commit e7452e4

File tree

5 files changed

+24
-199
lines changed

5 files changed

+24
-199
lines changed

.empty-mod/go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// module empty-mod is an empty module that's used to help with containerd
2+
// having a circular dependency on itself through plugin modules.
3+
//
4+
// We use this module as a "replace" rule in containerd's go.mod, to prevent
5+
// relying on transitive dependencies (coming from older versions of containerd
6+
// defined on plugin go.mod).
7+
//
8+
// The replace rule forces go modules to consider the "current" version of
9+
// containerd to be the source of truth, helping us catch missing go.mod rules,
10+
// or version changes early.
11+
module empty-mod

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ require (
4646
github.com/pelletier/go-toml v1.8.1
4747
github.com/pkg/errors v0.9.1
4848
github.com/prometheus/client_golang v1.7.1
49+
github.com/prometheus/procfs v0.6.0 // indirect; temporarily force v0.6.0, which was previously defined in imgcrypt as explicit version
50+
github.com/satori/go.uuid v1.2.0 // indirect
4951
github.com/sirupsen/logrus v1.7.0
5052
github.com/stretchr/testify v1.6.1
5153
github.com/tchap/go-patricia v2.2.6+incompatible
@@ -68,6 +70,9 @@ require (
6870

6971
// When updating replace rules, make sure to also update the rules in integration/client/go.mod
7072
replace (
73+
// prevent transitional dependencies due to containerd having a circular
74+
// dependency on itself through plugins. see .empty-mod/go.mod for details
75+
github.com/containerd/containerd => ./.empty-mod/
7176
github.com/gogo/googleapis => github.com/gogo/googleapis v1.3.2
7277
github.com/golang/protobuf => github.com/golang/protobuf v1.3.5
7378
// urfave/cli must be <= v1.22.1 due to a regression: https://github.com/urfave/cli/issues/1092

0 commit comments

Comments
 (0)