From 6ec3990319745f5f624ad3ec3f9a969c4f0565de Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 14 Feb 2022 16:18:34 +0100 Subject: [PATCH] Bump github.com/containerd/go-cni to v1.1.2 Signed-off-by: CrazyMax --- go.mod | 2 +- go.sum | 3 +- vendor/github.com/containerd/go-cni/README.md | 1 + vendor/github.com/containerd/go-cni/cni.go | 36 +++++++++++++++++-- .../github.com/containerd/go-cni/namespace.go | 4 +++ vendor/modules.txt | 2 +- 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index b2101918..5a58d649 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/containerd/containerd v1.6.0-rc.1 github.com/containerd/continuity v0.2.2 github.com/containerd/fuse-overlayfs-snapshotter v1.0.2 - github.com/containerd/go-cni v1.1.1 + github.com/containerd/go-cni v1.1.2 github.com/containerd/go-runc v1.0.0 github.com/containerd/stargz-snapshotter v0.11.0 github.com/containerd/stargz-snapshotter/estargz v0.11.0 diff --git a/go.sum b/go.sum index 0478f5cb..7f9ce375 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,9 @@ github.com/containerd/fuse-overlayfs-snapshotter v1.0.2/go.mod h1:nRZceC8a7dRm3A github.com/containerd/go-cni v1.0.1/go.mod h1:+vUpYxKvAF72G9i1WoDOiPGRtQpqsNW/ZHtSlv++smU= github.com/containerd/go-cni v1.0.2/go.mod h1:nrNABBHzu0ZwCug9Ije8hL2xBCYh/pjfMb1aZGrrohk= github.com/containerd/go-cni v1.1.0/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA= -github.com/containerd/go-cni v1.1.1 h1:UV64yhzDgs27mBIVUrlzG8Z2bc1K0/zokOW5vDNkI4c= github.com/containerd/go-cni v1.1.1/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA= +github.com/containerd/go-cni v1.1.2 h1:futGN9fI70oOPA1DKSN4oFmeZ8tNldb382g5TlwYfFc= +github.com/containerd/go-cni v1.1.2/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA= github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0= github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328/go.mod h1:PpyHrqVs8FTi9vpyHwPwiNEGaACDxT/N/pLcvMSRA9g= diff --git a/vendor/github.com/containerd/go-cni/README.md b/vendor/github.com/containerd/go-cni/README.md index 969c56e2..d028749f 100644 --- a/vendor/github.com/containerd/go-cni/README.md +++ b/vendor/github.com/containerd/go-cni/README.md @@ -11,6 +11,7 @@ A generic CNI library to provide APIs for CNI plugin interactions. The library p - Setup networks for container namespace - Remove networks from container namespace - Query status of CNI network plugin initialization +- Check verifies the network is still in desired state go-cni aims to support plugins that implement [Container Network Interface](https://github.com/containernetworking/cni) diff --git a/vendor/github.com/containerd/go-cni/cni.go b/vendor/github.com/containerd/go-cni/cni.go index f26a6eef..44dceaea 100644 --- a/vendor/github.com/containerd/go-cni/cni.go +++ b/vendor/github.com/containerd/go-cni/cni.go @@ -19,12 +19,15 @@ package cni import ( "context" "fmt" + "os" "strings" "sync" cnilibrary "github.com/containernetworking/cni/libcni" + "github.com/containernetworking/cni/pkg/invoke" "github.com/containernetworking/cni/pkg/types" types100 "github.com/containernetworking/cni/pkg/types/100" + "github.com/containernetworking/cni/pkg/version" ) type CNI interface { @@ -32,6 +35,8 @@ type CNI interface { Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*Result, error) // Remove tears down the network of the namespace. Remove(ctx context.Context, id string, path string, opts ...NamespaceOpts) error + // Check checks if the network is still in desired state + Check(ctx context.Context, id string, path string, opts ...NamespaceOpts) error // Load loads the cni network config Load(opts ...Opt) error // Status checks the status of the cni initialization @@ -84,9 +89,15 @@ func defaultCNIConfig() *libcni { pluginMaxConfNum: DefaultMaxConfNum, prefix: DefaultPrefix, }, - cniConfig: &cnilibrary.CNIConfig{ - Path: []string{DefaultCNIDir}, - }, + cniConfig: cnilibrary.NewCNIConfig( + []string{ + DefaultCNIDir, + }, + &invoke.DefaultExec{ + RawExec: &invoke.RawExec{Stderr: os.Stderr}, + PluginDecoder: version.PluginDecoder{}, + }, + ), networkCount: 1, } } @@ -217,6 +228,25 @@ func (c *libcni) Remove(ctx context.Context, id string, path string, opts ...Nam return nil } +// Check checks if the network is still in desired state +func (c *libcni) Check(ctx context.Context, id string, path string, opts ...NamespaceOpts) error { + if err := c.Status(); err != nil { + return err + } + ns, err := newNamespace(id, path, opts...) + if err != nil { + return err + } + for _, network := range c.Networks() { + err := network.Check(ctx, ns) + if err != nil { + return err + } + } + + return nil +} + // GetConfig returns a copy of the CNI plugin configurations as parsed by CNI func (c *libcni) GetConfig() *ConfigResult { c.RLock() diff --git a/vendor/github.com/containerd/go-cni/namespace.go b/vendor/github.com/containerd/go-cni/namespace.go index 9dd3b1d1..319182bc 100644 --- a/vendor/github.com/containerd/go-cni/namespace.go +++ b/vendor/github.com/containerd/go-cni/namespace.go @@ -41,6 +41,10 @@ func (n *Network) Remove(ctx context.Context, ns *Namespace) error { return n.cni.DelNetworkList(ctx, n.config, ns.config(n.ifName)) } +func (n *Network) Check(ctx context.Context, ns *Namespace) error { + return n.cni.CheckNetworkList(ctx, n.config, ns.config(n.ifName)) +} + type Namespace struct { id string path string diff --git a/vendor/modules.txt b/vendor/modules.txt index 2262e0a8..a71c5d68 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -146,7 +146,7 @@ github.com/containerd/fifo # github.com/containerd/fuse-overlayfs-snapshotter v1.0.2 ## explicit; go 1.16 github.com/containerd/fuse-overlayfs-snapshotter -# github.com/containerd/go-cni v1.1.1 +# github.com/containerd/go-cni v1.1.2 ## explicit; go 1.13 github.com/containerd/go-cni # github.com/containerd/go-runc v1.0.0