139 Commits

Author SHA1 Message Date
Gabe Rosenhouse
bb322572eb pkg/ip: improve docstring for SetupVeth 2017-03-13 11:27:12 -07:00
Gabe Rosenhouse
71d96ea91c pkg/ip: SetupVeth returns net.Interface 2017-03-10 09:49:46 -08:00
Jay Dunkelberger
b07d768f12 pkg/ip: do not leak types from vendored netlink package
The exported function SetupVeth now returns a package-defined type.

Signed-off-by: Gabe Rosenhouse <grosenhouse@pivotal.io>
2017-03-09 13:55:15 -08:00
Dan Williams
9b8a0e0c64 spec,libcni: add support for injecting runtimeConfig into plugin stdin data
Add a new CapabilityArgs member to the RuntimeConf struct which runtimes can
use to pass arbitrary capability-based keys to the plugin.  Elements of this
member will be filtered against the plugin's advertised capabilities (from
its config JSON) and then added to a new "runtimeConfig" top-level map added
to the config JSON sent to the plugin on stdin.

Also "runtime_config"->"runtimeConfig" in CONVENTIONS.md to make
capitalization consistent with other CNI config keys like "cniVersion".
2017-03-01 10:49:40 -06:00
Dan Williams
0b1b85413e Merge pull request #383 from dcbw/test-fixes
tests: misc test fixes
2017-02-27 16:13:45 -06:00
Dan Williams
2f1bfcee63 pkg/types: misc current types testcase cleanups 2017-02-27 13:28:07 -06:00
Dan Williams
2a6d12b206 pkg/testutils: return errors after restoring stdout
Ensures Ginkgo is able to print detailed failure messages instead
of them being captured by the pipe.
2017-02-27 13:27:19 -06:00
Aithal
7d5619d277 pkg/ip: refactored so that builds succeed on non-linux platforms
moved functions that depend on linux packages into a separate file and added
nop methods with a build tag for non-linux platforms in a new file.
2017-02-23 09:52:13 -08:00
Aithal
46deb7b708 pkg/ns, pkg/types: refactored non linux build fix code to
Make GetCurrentNS platform specific instead of getCurrentThreadNetNSPath
2017-02-23 09:50:48 -08:00
Aithal
dff808c98e pkg/ns: refactored so that builds succeed on non-linux platforms
moved functions that depend on linux packages (sys/unix) into a separate file
and added nop methods with a build tag for non-linux platforms in a new file.
2017-02-20 10:00:55 -08:00
Gabe Rosenhouse
970de4b9e3 Merge pull request #361 from ofiliz/issue-360
invoke: Enable plugin file names with extensions
2017-02-08 10:15:49 -08:00
Onur Filiz
a35f8ae914 invoke: Enable plugin file names with extensions
A CNI network configuration file contains the plugin's executable file name.
Some platforms like Windows require a file name extension for executables.
This causes unnecessary burden on admins as they now have to maintain two
versions of each type of netconfig file, which differ only by the ".exe"
extension. A much simpler design is for invoke package to also look for
well-known extensions on platforms that require it. Existing tests are
improved and new tests are added to cover the new behavior.

Fixes #360
2017-02-04 12:01:47 -08:00
Paulo Pires
2e90a8cc33 pkg/utils/sysctl/sysctl_linux.go: fix typo. 2017-02-03 05:39:04 +00:00
Paulo Pires
162b73e44f pkg/utils/sysctl/sysctl_linux.go: fix build tag. 2017-02-03 05:38:53 +00:00
Onur
46e17b26ff spec, libcni, pkg/invoke: Use OS-agnostic separator when parsing CNI_PATH
Hardcoding the list separator character as ":" causes CNI to fail when parsing
CNI_PATH on other operating systems. For example, Windows uses ";" as list
separator because ":" can legally appear in paths such as "C:\path\to\file".
This change replaces use of ":" with OS-agnostic APIs or os.PathListSeparator.

Fixes #358
2017-01-28 16:47:58 -08:00
Dan Williams
06b397912b spec/plugins: return interface details and multiple IP addresses to runtime
Updates the spec and plugins to return an array of interfaces and IP details
to the runtime including:

- interface names and MAC addresses configured by the plugin
- whether the interfaces are sandboxed (container/VM) or host (bridge, veth, etc)
- multiple IP addresses configured by IPAM and which interface they
have been assigned to

Returning interface details is useful for runtimes, as well as allowing
more flexible chaining of CNI plugins themselves.  For example, some
meta plugins may need to know the host-side interface to be able to
apply firewall or traffic shaping rules to the container.
2017-01-25 11:31:18 -06:00
Dan Williams
b89b56dc97 pkg/ipam: add testcases 2017-01-25 11:31:18 -06:00
Dan Williams
e6adfe939a macvlan/ipvlan: use common RenameLink method 2017-01-25 11:31:18 -06:00
Dan Williams
0d19b79260 types: make Result an interface and move existing Result to separate package 2017-01-25 11:31:18 -06:00
Dan Williams
dae1177b53 testutils: pass netConf in for version operations; pass raw result out for tests 2017-01-25 11:31:18 -06:00
Gabe Rosenhouse
2515b8c712 skel: adds PluginMainWithError which returns a *types.Error
Enables plugins to do their own error-handling and cleanup logic
2017-01-22 16:57:42 -08:00
Dan Williams
13534e505c api,libcni: add network config list-based plugin chaining
Using a new ".configlist" file format that allows specifying
a list of CNI network configurations to run, add new libcni
helper functions to call each plugin in the list, injecting
the overall name, CNI version, and previous plugin's Result
structure into the configuration of the next plugin.
2017-01-19 22:28:21 -06:00
Dan Williams
06fd1369aa all: assert internal objects implement interfaces 2016-12-14 17:09:01 -06:00
Bryan Boreham
44ef109483 Expand description of goroutine+netns problems 2016-11-17 15:45:38 +00:00
Casey Callendrello
61d3f4515a testing: test invocation of newer plugins with an older libcni 2016-10-25 16:33:35 +02:00
Gabe Rosenhouse
cfb2ff3dcd skel tests: correct name of CNI_CONTAINERID in tests of env vars 2016-10-16 17:18:57 -07:00
Gabe Rosenhouse
b07b226c97 testing: adds basic test of backwards compatibility 2016-10-02 22:18:53 -07:00
Gabe Rosenhouse
f721eaf6ed skel: use named constant for Incompatible CNI Version error code 2016-09-19 13:25:33 -07:00
Gabe Rosenhouse
04ba7c7761 versioning: plugins require version match with config
infer version 0.1.0 when config is missing an explicit "cniVersion" field
2016-09-19 13:00:49 -07:00
Gabe Rosenhouse
1e4e8fdb5d versioning: add basic version decode for network config 2016-09-19 12:57:08 -07:00
Gabe Rosenhouse
921292ff77 skel: Plugins require a cniVersion in the NetConf 2016-09-18 21:30:57 -07:00
Gabe Rosenhouse
de91f31ae7 versioning: revert spec version to 0.2.0 2016-09-06 15:37:42 -04:00
Gabe Rosenhouse
bf6948da19 versioning: misc cleanups
highlights:
 - NetConf struct finally includes cniVersion field
 - improve test coverage of current version report behavior
 - godoc a few key functions
 - allow tests to control version list reported by no-op plugin
2016-09-06 15:35:58 -04:00
Gabe Rosenhouse
2f97407396 invoke: better name and unit test coverage for GetVersionInfo 2016-09-02 16:39:01 -04:00
Gabe Rosenhouse
f467134838 invoke: correctly infer version for 0.1.0-vintage plugins
Older plugins return a known error when issued the VERSION command.
Capture this error and report it as a 0.1.0 version plugin.
2016-09-02 16:02:07 -04:00
Gabe Rosenhouse
2142c076ab versioning: adds tooling to compile a program against a given old CNI version
Allows us to write tests that cover interactions between components of
differing versions
2016-09-02 16:02:02 -04:00
Gabe Rosenhouse
bd3ade0c54 pkg/invoke: refactor plugin exec and backfill unit tests 2016-09-02 15:59:25 -04:00
Gabe Rosenhouse
383c84031e versioning: document meaning of 'Legacy' version support 2016-09-02 11:26:17 -04:00
Gabe Rosenhouse
b1e254d901 versioning: plugins report a list of supported versions
Further progress on versioning support (Issue #266).
Bump CNI spec version to 0.3.0
2016-09-02 11:26:17 -04:00
Gabe Rosenhouse
63ace9e496 Merge pull request #293 from rosenhouse/backfill-invoke-exec-tests
Backfill tests for plugin execution
2016-08-31 20:49:08 -04:00
Dan Williams
26241a517a Merge pull request #290 from asridharan/dcos
Fixed the check for network namespace path.
2016-08-31 18:19:02 -05:00
Avinash Sridharan
1ce5e54e99 pkg/ns: fixed the check for network namespace path.
The expectation on older kernels (< 3.19) was to have the network
namespace always be a directory. This is not true if the network
namespace is bind mounted to a file, and will make the plugin fail
erroneously in such cases. The fix is to remove this assumption
completely and just do a basic check on the file system types being
returned.

Fixes #288
2016-08-31 21:41:00 +00:00
Tom Denham
31ef82276a pkg/ip: Ensure that SetupVeth returns correct hostVeth
The veth is moved from the container NS to the host NS.
This is handled by the code that sets the link to UP but the wrong
hostVeth is returned to the calling code.
2016-08-31 14:17:25 -07:00
Gabe Rosenhouse
0e675fa14f invoke: backfill tests for plugin execution 2016-08-30 23:52:47 -04:00
Tom Denham
415d707faf Merge pull request #267 from rosenhouse/version-cmd
Adds VERSION command
2016-08-12 15:06:22 -07:00
Prateek Gogia
3c1d4581c4 pkg/ip: Return correct error if container name provided exists, and test cases
If interface name for a container provided by a user is already present,
Veth creation fails with incorrect error.
If os.IsExist error is returned by makeVethPair:
* Check for peer name, if exists generate another random peer name,
* else, IsExist error is due to container interface present, return error.

Fixes #155
2016-08-11 18:51:03 +00:00
Stefan Junker
22a0ddc906 pkg/utils/hwaddr tests: cover v4 in v6 addr 2016-08-01 16:50:40 -07:00
Stefan Junker
00f27577d5 pkg/ip link_test: ensure SetHWAddrByIP has an effect 2016-07-22 15:34:54 -07:00
Stefan Junker
c317888ac5 pkg/ip: use iface name in SetHWAddrByIP 2016-07-22 15:34:53 -07:00
Stefan Junker
1a04d9abba pkg/ip tests: cover SetupVeth and DelLinkByName* 2016-07-22 15:34:53 -07:00