Merge pull request #7009 from mikebrow/update-gocni
This commit is contained in:
		
							
								
								
									
										4
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.mod
									
									
									
									
									
								
							@@ -13,7 +13,7 @@ require (
 | 
			
		||||
	github.com/containerd/console v1.0.3
 | 
			
		||||
	github.com/containerd/continuity v0.2.2
 | 
			
		||||
	github.com/containerd/fifo v1.0.0
 | 
			
		||||
	github.com/containerd/go-cni v1.1.5
 | 
			
		||||
	github.com/containerd/go-cni v1.1.6
 | 
			
		||||
	github.com/containerd/go-runc v1.0.0
 | 
			
		||||
	github.com/containerd/imgcrypt v1.1.5-0.20220421044638-8ba028dca028
 | 
			
		||||
	github.com/containerd/nri v0.1.0
 | 
			
		||||
@@ -82,7 +82,7 @@ require (
 | 
			
		||||
	github.com/cenkalti/backoff/v4 v4.1.3 // indirect
 | 
			
		||||
	github.com/cespare/xxhash/v2 v2.1.2 // indirect
 | 
			
		||||
	github.com/cilium/ebpf v0.7.0 // indirect
 | 
			
		||||
	github.com/containernetworking/cni v1.1.0 // indirect
 | 
			
		||||
	github.com/containernetworking/cni v1.1.1 // indirect
 | 
			
		||||
	github.com/containers/ocicrypt v1.1.3 // indirect
 | 
			
		||||
	github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
 | 
			
		||||
	github.com/emicklei/go-restful v2.9.5+incompatible // indirect
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								go.sum
									
									
									
									
									
								
							@@ -236,8 +236,8 @@ github.com/containerd/go-cni v1.0.1/go.mod h1:+vUpYxKvAF72G9i1WoDOiPGRtQpqsNW/ZH
 | 
			
		||||
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.3/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA=
 | 
			
		||||
github.com/containerd/go-cni v1.1.5 h1:WUkuZ6kDkmECdd/qEPetq1czj6ivDkAoaOpL8yv8vO8=
 | 
			
		||||
github.com/containerd/go-cni v1.1.5/go.mod h1:Rf2ZrMycr1El589IyuRzn7RkfdRZVKaFGaxSDHVAjj0=
 | 
			
		||||
github.com/containerd/go-cni v1.1.6 h1:el5WPymG5nRRLQF1EfB97FWob4Tdc8INg8RZMaXWZlo=
 | 
			
		||||
github.com/containerd/go-cni v1.1.6/go.mod h1:BWtoWl5ghVymxu6MBjg79W9NZrCRyHIdUtk4cauMe34=
 | 
			
		||||
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=
 | 
			
		||||
@@ -280,8 +280,8 @@ github.com/containernetworking/cni v0.7.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ
 | 
			
		||||
github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
 | 
			
		||||
github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
 | 
			
		||||
github.com/containernetworking/cni v1.0.1/go.mod h1:AKuhXbN5EzmD4yTNtfSsX3tPcmtrBI6QcRV0NiNt15Y=
 | 
			
		||||
github.com/containernetworking/cni v1.1.0 h1:T00oIz4hef+/p9gpRZa57SnIN+QnbmAHBjbxaOSFo9U=
 | 
			
		||||
github.com/containernetworking/cni v1.1.0/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw=
 | 
			
		||||
github.com/containernetworking/cni v1.1.1 h1:ky20T7c0MvKvbMOwS/FrlbNwjEoqJEUUYfsL4b0mc4k=
 | 
			
		||||
github.com/containernetworking/cni v1.1.1/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw=
 | 
			
		||||
github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM=
 | 
			
		||||
github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8=
 | 
			
		||||
github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNBDZcxSOplJT5ico8/FLE=
 | 
			
		||||
 
 | 
			
		||||
@@ -145,7 +145,7 @@ github.com/containerd/continuity v0.2.2/go.mod h1:pWygW9u7LtS1o4N/Tn0FoCFDIXZ7rx
 | 
			
		||||
github.com/containerd/fifo v1.0.0 h1:6PirWBr9/L7GDamKr+XM0IeUFXu5mf3M/BPpH9gaLBU=
 | 
			
		||||
github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4=
 | 
			
		||||
github.com/containerd/go-cni v1.1.3/go.mod h1:Rflh2EJ/++BA2/vY5ao3K6WJRR/bZKsX123aPk+kUtA=
 | 
			
		||||
github.com/containerd/go-cni v1.1.5/go.mod h1:Rf2ZrMycr1El589IyuRzn7RkfdRZVKaFGaxSDHVAjj0=
 | 
			
		||||
github.com/containerd/go-cni v1.1.6/go.mod h1:BWtoWl5ghVymxu6MBjg79W9NZrCRyHIdUtk4cauMe34=
 | 
			
		||||
github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328/go.mod h1:PpyHrqVs8FTi9vpyHwPwiNEGaACDxT/N/pLcvMSRA9g=
 | 
			
		||||
github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok=
 | 
			
		||||
github.com/containerd/go-runc v1.0.0 h1:oU+lLv1ULm5taqgV/CJivypVODI4SUz1znWjv3nNYS0=
 | 
			
		||||
@@ -163,7 +163,7 @@ github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67 h1:rQvjv7gRi6
 | 
			
		||||
github.com/containerd/typeurl v1.0.3-0.20220422153119-7f6e6d160d67/go.mod h1:HDkcKOXRnX6yKnXv3P0QrogFi0DoiauK/LpQi961f0A=
 | 
			
		||||
github.com/containerd/zfs v1.0.0/go.mod h1:m+m51S1DvAP6r3FcmYCp54bQ34pyOwTieQDNRIRHsFY=
 | 
			
		||||
github.com/containernetworking/cni v1.0.1/go.mod h1:AKuhXbN5EzmD4yTNtfSsX3tPcmtrBI6QcRV0NiNt15Y=
 | 
			
		||||
github.com/containernetworking/cni v1.1.0/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw=
 | 
			
		||||
github.com/containernetworking/cni v1.1.1/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw=
 | 
			
		||||
github.com/containernetworking/plugins v1.1.1/go.mod h1:Sr5TH/eBsGLXK/h71HeLfX19sZPp3ry5uHSkI4LPxV8=
 | 
			
		||||
github.com/containers/ocicrypt v1.1.3/go.mod h1:xpdkbVAuaH3WzbEabUd5yDsl9SwJA5pABH85425Es2g=
 | 
			
		||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,11 @@ func (f *FakeCNIPlugin) Setup(ctx context.Context, id, path string, opts ...cni.
 | 
			
		||||
	return nil, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetupSerially sets up the network of PodSandbox without doing the interfaces in parallel.
 | 
			
		||||
func (f *FakeCNIPlugin) SetupSerially(ctx context.Context, id, path string, opts ...cni.NamespaceOpts) (*cni.Result, error) {
 | 
			
		||||
	return nil, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Remove teardown the network of PodSandbox.
 | 
			
		||||
func (f *FakeCNIPlugin) Remove(ctx context.Context, id, path string, opts ...cni.NamespaceOpts) error {
 | 
			
		||||
	return nil
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								vendor/github.com/containerd/go-cni/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/containerd/go-cni/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -31,12 +31,10 @@ help: ## this help
 | 
			
		||||
test: ## run tests, except integration tests and tests that require root
 | 
			
		||||
	$(Q)go test -v -race $(EXTRA_TESTFLAGS) -count=1 ./...
 | 
			
		||||
 | 
			
		||||
integration: ## run integration test
 | 
			
		||||
integration: bin/integration.test ## run integration test
 | 
			
		||||
	$(Q)bin/integration.test -test.v -test.count=1 -test.root $(EXTRA_TESTFLAGS) -test.parallel $(TESTFLAGS_PARALLEL)
 | 
			
		||||
 | 
			
		||||
FORCE:
 | 
			
		||||
 | 
			
		||||
bin/integration.test: FORCE ## build integration test binary into bin
 | 
			
		||||
bin/integration.test: ## build integration test binary into bin
 | 
			
		||||
	$(Q)cd ./integration && go test -race -c . -o ../bin/integration.test
 | 
			
		||||
 | 
			
		||||
clean: ## clean up binaries
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										30
									
								
								vendor/github.com/containerd/go-cni/cni.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								vendor/github.com/containerd/go-cni/cni.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -33,6 +33,8 @@ import (
 | 
			
		||||
type CNI interface {
 | 
			
		||||
	// Setup setup the network for the namespace
 | 
			
		||||
	Setup(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*Result, error)
 | 
			
		||||
	// SetupSerially sets up each of the network interfaces for the namespace in serial
 | 
			
		||||
	SetupSerially(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
 | 
			
		||||
@@ -165,6 +167,34 @@ func (c *libcni) Setup(ctx context.Context, id string, path string, opts ...Name
 | 
			
		||||
	return c.createResult(result)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetupSerially setups the network in the namespace and returns a Result
 | 
			
		||||
func (c *libcni) SetupSerially(ctx context.Context, id string, path string, opts ...NamespaceOpts) (*Result, error) {
 | 
			
		||||
	if err := c.Status(); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	ns, err := newNamespace(id, path, opts...)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	result, err := c.attachNetworksSerially(ctx, ns)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return c.createResult(result)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *libcni) attachNetworksSerially(ctx context.Context, ns *Namespace) ([]*types100.Result, error) {
 | 
			
		||||
	var results []*types100.Result
 | 
			
		||||
	for _, network := range c.Networks() {
 | 
			
		||||
		r, err := network.Attach(ctx, ns)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		results = append(results, r)
 | 
			
		||||
	}
 | 
			
		||||
	return results, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type asynchAttachResult struct {
 | 
			
		||||
	index int
 | 
			
		||||
	res   *types100.Result
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										45
									
								
								vendor/github.com/containernetworking/cni/pkg/invoke/exec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								vendor/github.com/containernetworking/cni/pkg/invoke/exec.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -16,6 +16,7 @@ package invoke
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"os"
 | 
			
		||||
 | 
			
		||||
@@ -33,6 +34,43 @@ type Exec interface {
 | 
			
		||||
	Decode(jsonBytes []byte) (version.PluginInfo, error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Plugin must return result in same version as specified in netconf; but
 | 
			
		||||
// for backwards compatibility reasons if the result version is empty use
 | 
			
		||||
// config version (rather than technically correct 0.1.0).
 | 
			
		||||
// https://github.com/containernetworking/cni/issues/895
 | 
			
		||||
func fixupResultVersion(netconf, result []byte) (string, []byte, error) {
 | 
			
		||||
	versionDecoder := &version.ConfigDecoder{}
 | 
			
		||||
	confVersion, err := versionDecoder.Decode(netconf)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var rawResult map[string]interface{}
 | 
			
		||||
	if err := json.Unmarshal(result, &rawResult); err != nil {
 | 
			
		||||
		return "", nil, fmt.Errorf("failed to unmarshal raw result: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Manually decode Result version; we need to know whether its cniVersion
 | 
			
		||||
	// is empty, while built-in decoders (correctly) substitute 0.1.0 for an
 | 
			
		||||
	// empty version per the CNI spec.
 | 
			
		||||
	if resultVerRaw, ok := rawResult["cniVersion"]; ok {
 | 
			
		||||
		resultVer, ok := resultVerRaw.(string)
 | 
			
		||||
		if ok && resultVer != "" {
 | 
			
		||||
			return resultVer, result, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// If the cniVersion is not present or empty, assume the result is
 | 
			
		||||
	// the same CNI spec version as the config
 | 
			
		||||
	rawResult["cniVersion"] = confVersion
 | 
			
		||||
	newBytes, err := json.Marshal(rawResult)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", nil, fmt.Errorf("failed to remarshal fixed result: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return confVersion, newBytes, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// For example, a testcase could pass an instance of the following fakeExec
 | 
			
		||||
// object to ExecPluginWithResult() to verify the incoming stdin and environment
 | 
			
		||||
// and provide a tailored response:
 | 
			
		||||
@@ -84,7 +122,12 @@ func ExecPluginWithResult(ctx context.Context, pluginPath string, netconf []byte
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return create.CreateFromBytes(stdoutBytes)
 | 
			
		||||
	resultVersion, fixedBytes, err := fixupResultVersion(netconf, stdoutBytes)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return create.Create(resultVersion, fixedBytes)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ExecPluginWithoutResult(ctx context.Context, pluginPath string, netconf []byte, args CNIArgs, exec Exec) error {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							@@ -104,7 +104,7 @@ github.com/containerd/continuity/testutil/loopback
 | 
			
		||||
# github.com/containerd/fifo v1.0.0
 | 
			
		||||
## explicit; go 1.13
 | 
			
		||||
github.com/containerd/fifo
 | 
			
		||||
# github.com/containerd/go-cni v1.1.5
 | 
			
		||||
# github.com/containerd/go-cni v1.1.6
 | 
			
		||||
## explicit; go 1.17
 | 
			
		||||
github.com/containerd/go-cni
 | 
			
		||||
# github.com/containerd/go-runc v1.0.0
 | 
			
		||||
@@ -128,7 +128,7 @@ github.com/containerd/typeurl
 | 
			
		||||
## explicit; go 1.16
 | 
			
		||||
github.com/containerd/zfs
 | 
			
		||||
github.com/containerd/zfs/plugin
 | 
			
		||||
# github.com/containernetworking/cni v1.1.0
 | 
			
		||||
# github.com/containernetworking/cni v1.1.1
 | 
			
		||||
## explicit; go 1.14
 | 
			
		||||
github.com/containernetworking/cni/libcni
 | 
			
		||||
github.com/containernetworking/cni/pkg/invoke
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user