From 191dfca116a5a85de9b192dbc7f9b94e20771c00 Mon Sep 17 00:00:00 2001 From: Starnop Date: Fri, 28 Sep 2018 12:20:00 +0800 Subject: [PATCH] upgrade: upgrade CNI Signed-off-by: Starnop --- cri/ocicni/cni_manager.go | 20 +- .../cni/CODE-OF-CONDUCT.md | 4 + .../containernetworking/cni/CONTRIBUTING.md | 125 +++ .../containernetworking/cni/CONVENTIONS.md | 114 +++ vendor/github.com/containernetworking/cni/DCO | 36 + .../cni/Documentation/cnitool.md | 16 + .../cni/Documentation/spec-upgrades.md | 259 ++++++ .../containernetworking/cni/GOVERNANCE.md | 44 ++ .../containernetworking/cni/MAINTAINERS | 6 + .../containernetworking/cni/README.md | 198 +++++ .../containernetworking/cni/RELEASING.md | 34 + .../containernetworking/cni/ROADMAP.md | 23 + .../containernetworking/cni/SPEC.md | 739 ++++++++++++++++++ .../containernetworking/cni/Vagrantfile | 22 + .../containernetworking/cni/cnitool/README.md | 47 ++ .../cni/cnitool/cnitool.go | 135 ++++ .../containernetworking/cni/libcni/api.go | 315 +++++++- .../containernetworking/cni/logo.png | Bin 0 -> 11604 bytes .../cni/pkg/invoke/delegate.go | 42 +- .../cni/pkg/invoke/exec.go | 104 ++- .../cni/pkg/invoke/fakes/cni_args.go | 27 + .../cni/pkg/invoke/fakes/raw_exec.go | 52 ++ .../cni/pkg/invoke/fakes/version_decoder.go | 34 + .../cni/pkg/invoke/raw_exec.go | 4 + .../containernetworking/cni/pkg/skel/skel.go | 296 +++++++ .../cni/pkg/types/current/types.go | 6 +- .../cni/pkg/types/types.go | 10 +- .../legacy_examples/example_runtime.go | 219 ++++++ .../pkg/version/legacy_examples/examples.go | 143 ++++ .../cni/pkg/version/plugin.go | 59 ++ .../pkg/version/testhelpers/testhelpers.go | 156 ++++ .../cni/pkg/version/version.go | 4 +- .../cni/plugins/test/noop/debug/debug.go | 71 ++ .../cni/plugins/test/noop/main.go | 216 +++++ .../cni/scripts/docker-run.sh | 21 + .../cni/scripts/exec-plugins.sh | 45 ++ .../cni/scripts/priv-net-run.sh | 20 + .../cni/scripts/release.sh | 38 + .../containernetworking/cni/test.sh | 52 ++ .../cri-o/ocicni/pkg/ocicni/ocicni.go | 407 ++++++---- .../cri-o/ocicni/pkg/ocicni/types.go | 17 +- .../cri-o/ocicni/pkg/ocicni/types_unix.go | 10 + .../cri-o/ocicni/pkg/ocicni/types_windows.go | 10 + .../cri-o/ocicni/pkg/ocicni/util.go | 34 +- .../cri-o/ocicni/pkg/ocicni/util_linux.go | 71 ++ .../ocicni/pkg/ocicni/util_unsupported.go | 19 + vendor/vendor.json | 45 +- 47 files changed, 4074 insertions(+), 295 deletions(-) create mode 100644 vendor/github.com/containernetworking/cni/CODE-OF-CONDUCT.md create mode 100644 vendor/github.com/containernetworking/cni/CONTRIBUTING.md create mode 100644 vendor/github.com/containernetworking/cni/CONVENTIONS.md create mode 100644 vendor/github.com/containernetworking/cni/DCO create mode 100644 vendor/github.com/containernetworking/cni/Documentation/cnitool.md create mode 100644 vendor/github.com/containernetworking/cni/Documentation/spec-upgrades.md create mode 100644 vendor/github.com/containernetworking/cni/GOVERNANCE.md create mode 100644 vendor/github.com/containernetworking/cni/MAINTAINERS create mode 100644 vendor/github.com/containernetworking/cni/README.md create mode 100644 vendor/github.com/containernetworking/cni/RELEASING.md create mode 100644 vendor/github.com/containernetworking/cni/ROADMAP.md create mode 100644 vendor/github.com/containernetworking/cni/SPEC.md create mode 100644 vendor/github.com/containernetworking/cni/Vagrantfile create mode 100644 vendor/github.com/containernetworking/cni/cnitool/README.md create mode 100644 vendor/github.com/containernetworking/cni/cnitool/cnitool.go create mode 100644 vendor/github.com/containernetworking/cni/logo.png create mode 100644 vendor/github.com/containernetworking/cni/pkg/invoke/fakes/cni_args.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/invoke/fakes/raw_exec.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/invoke/fakes/version_decoder.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/skel/skel.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/version/legacy_examples/example_runtime.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/version/legacy_examples/examples.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/version/testhelpers/testhelpers.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/test/noop/debug/debug.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/test/noop/main.go create mode 100644 vendor/github.com/containernetworking/cni/scripts/docker-run.sh create mode 100644 vendor/github.com/containernetworking/cni/scripts/exec-plugins.sh create mode 100644 vendor/github.com/containernetworking/cni/scripts/priv-net-run.sh create mode 100644 vendor/github.com/containernetworking/cni/scripts/release.sh create mode 100644 vendor/github.com/containernetworking/cni/test.sh create mode 100644 vendor/github.com/cri-o/ocicni/pkg/ocicni/types_unix.go create mode 100644 vendor/github.com/cri-o/ocicni/pkg/ocicni/types_windows.go create mode 100644 vendor/github.com/cri-o/ocicni/pkg/ocicni/util_linux.go create mode 100644 vendor/github.com/cri-o/ocicni/pkg/ocicni/util_unsupported.go diff --git a/cri/ocicni/cni_manager.go b/cri/ocicni/cni_manager.go index 8884aab167..b01b76ad96 100644 --- a/cri/ocicni/cni_manager.go +++ b/cri/ocicni/cni_manager.go @@ -6,6 +6,7 @@ import ( "github.com/alibaba/pouch/cri/config" + cnicurrent "github.com/containernetworking/cni/pkg/types/current" "github.com/cri-o/ocicni/pkg/ocicni" "github.com/sirupsen/logrus" ) @@ -32,7 +33,7 @@ func NewCniManager(cfg *config.Config) (CniMgr, error) { } } - plugin, err := ocicni.InitCNI(networkPluginConfDir, networkPluginBinDir) + plugin, err := ocicni.InitCNI("", networkPluginConfDir, networkPluginBinDir) if err != nil { return nil, err } @@ -87,12 +88,25 @@ func (c *CniManager) GetPodNetworkStatus(netnsPath string) (string, error) { NetNS: netnsPath, } - ip, err := c.plugin.GetPodNetworkStatus(podNetwork) + var err error + results, err := c.plugin.GetPodNetworkStatus(podNetwork) if err != nil { return "", fmt.Errorf("failed to get pod network status: %v", err) } - return ip, nil + if len(results) > 0 { + // NOTE: only get the first IP of the first network at present + // TODO: support multiple network + if result, ok := results[0].(*cnicurrent.Result); ok { + if len(result.IPs) > 0 { + ip := result.IPs[0].Address.IP.String() + return ip, nil + } + return "", fmt.Errorf("failed to get pod network status for nil IP") + } + return "", fmt.Errorf("failed to get pod network status for wrong result: %+v", results[0]) + } + return "", fmt.Errorf("failed to get pod network status for nil result") } // Status returns error if the network plugin is in error state. diff --git a/vendor/github.com/containernetworking/cni/CODE-OF-CONDUCT.md b/vendor/github.com/containernetworking/cni/CODE-OF-CONDUCT.md new file mode 100644 index 0000000000..b6e32163ab --- /dev/null +++ b/vendor/github.com/containernetworking/cni/CODE-OF-CONDUCT.md @@ -0,0 +1,4 @@ +## Community Code of Conduct + +CNI follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). + diff --git a/vendor/github.com/containernetworking/cni/CONTRIBUTING.md b/vendor/github.com/containernetworking/cni/CONTRIBUTING.md new file mode 100644 index 0000000000..817f072afa --- /dev/null +++ b/vendor/github.com/containernetworking/cni/CONTRIBUTING.md @@ -0,0 +1,125 @@ +# How to Contribute + +CNI is [Apache 2.0 licensed](LICENSE) and accepts contributions via GitHub +pull requests. This document outlines some of the conventions on development +workflow, commit message formatting, contact points and other resources to make +it easier to get your contribution accepted. + +We gratefully welcome improvements to documentation as well as to code. + +# Certificate of Origin + +By contributing to this project you agree to the Developer Certificate of +Origin (DCO). This document was created by the Linux Kernel community and is a +simple statement that you, as a contributor, have the legal right to make the +contribution. See the [DCO](DCO) file for details. + +# Email and Chat + +The project uses the the cni-dev email list and IRC chat: +- Email: [cni-dev](https://groups.google.com/forum/#!forum/cni-dev) +- IRC: #[containernetworking](irc://irc.freenode.org:6667/#containernetworking) channel on freenode.org + +Please avoid emailing maintainers found in the MAINTAINERS file directly. They +are very busy and read the mailing lists. + +## Getting Started + +- Fork the repository on GitHub +- Read the [README](README.md) for build and test instructions +- Play with the project, submit bugs, submit pull requests! + +## Contribution workflow + +This is a rough outline of how to prepare a contribution: + +- Create a topic branch from where you want to base your work (usually branched from master). +- Make commits of logical units. +- Make sure your commit messages are in the proper format (see below). +- Push your changes to a topic branch in your fork of the repository. +- If you changed code: + - add automated tests to cover your changes, using the [Ginkgo](http://onsi.github.io/ginkgo/) & [Gomega](http://onsi.github.io/gomega/) style + - if the package did not previously have any test coverage, add it to the list + of `TESTABLE` packages in the `test.sh` script. + - run the full test script and ensure it passes +- Make sure any new code files have a license header (this is now enforced by automated tests) +- Submit a pull request to the original repository. + +## How to run the test suite +We generally require test coverage of any new features or bug fixes. + +Here's how you can run the test suite on any system (even Mac or Windows) using + [Vagrant](https://www.vagrantup.com/) and a hypervisor of your choice: + +```bash +vagrant up +vagrant ssh +# you're now in a shell in a virtual machine +sudo su +cd /go/src/github.com/containernetworking/cni + +# to run the full test suite +./test.sh + +# to focus on a particular test suite +cd plugins/main/loopback +go test +``` + +# Acceptance policy + +These things will make a PR more likely to be accepted: + + * a well-described requirement + * tests for new code + * tests for old code! + * new code and tests follow the conventions in old code and tests + * a good commit message (see below) + +In general, we will merge a PR once two maintainers have endorsed it. +Trivial changes (e.g., corrections to spelling) may get waved through. +For substantial changes, more people may become involved, and you might get asked to resubmit the PR or divide the changes into more than one PR. + +### Format of the Commit Message + +We follow a rough convention for commit messages that is designed to answer two +questions: what changed and why. The subject line should feature the what and +the body of the commit should describe the why. + +``` +scripts: add the test-cluster command + +this uses tmux to setup a test cluster that you can easily kill and +start for debugging. + +Fixes #38 +``` + +The format can be described more formally as follows: + +``` +: + + + +