121 Commits

Author SHA1 Message Date
Dan Williams
d5acb127b8 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
b0b896f79a plugins/flannel: organize test JSON alphabetically
Otherwise the test fails, since Go's JSON marshaller prints
dict items alphabetically in its String() call.
2017-01-25 11:31:18 -06:00
Dan Williams
ad2a5ccb61 macvlan/ipvlan: use common RenameLink method 2017-01-25 11:31:18 -06:00
Dan Williams
befb95977c types: make Result an interface and move existing Result to separate package 2017-01-25 11:31:18 -06:00
Dan Williams
cb4cd0e12c testutils: pass netConf in for version operations; pass raw result out for tests 2017-01-25 11:31:18 -06:00
Dan Williams
0c2a034f01 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
0a1b48f520 noop: allow specifying debug file in config JSON
Chaining sends different config JSON to each plugin, but the same
environment, and if we want to test multiple noop plugin runs in
the same chain we need a way of telling each run to use a different
debug file.
2017-01-19 09:56:42 -06:00
Casey Callendrello
5cde14cd7b ipam/host-local: add ResolvConf argument for DNS configuration
This adds the option `resolvConf` to the host-local IPAM configuration.
If specified, the plugin will try to parse the file as a resolv.conf(5)
type file and return it in the DNS response.
2017-01-11 18:48:35 +01:00
André Martins
f60111b093 ipam/host-local: Move allocator and config to backend
Signed-off-by: André Martins <aanm90@gmail.com>
2016-12-21 04:43:21 +00:00
Gabe Rosenhouse
652bae1deb Merge pull request #314 from rosenhouse/noop-helpful-message
plugins/noop: return a helpful message for test authors
2016-12-15 18:35:43 -08:00
Gabe Rosenhouse
1c1cf2faf7 Merge branch 'master' into interface-checks 2016-12-15 18:20:34 -08:00
Gabe Rosenhouse
ef00f717a6 Merge pull request #341 from dcbw/host-local-trim
host-local: trim whitespace from container IDs and disk file contents
2016-12-15 18:18:25 -08:00
Dan Williams
5852c60bc4 all: assert internal objects implement interfaces 2016-12-14 17:09:01 -06:00
Dan Williams
76028d7f8c host-local: trim whitespace from container IDs and disk file contents
It doesn't seem like container IDs should really have whitespace or
newlines in them.  As a complete edge-case, manipulating the host-local
store's IP reservations with 'echo' puts a newline at the end, which
caused matching to fail in ReleaseByID().  Don't ask...
2016-12-09 18:16:38 -06:00
VZ Cambria
2ba6d20007 Fix README.md host-local IPAM range start/end typo 2016-12-06 10:40:55 -05:00
Konstantinos Karampogias
accac60053 plugins/noop: return a helpful message for test authors
Signed-off-by: Gabe Rosenhouse <grosenhouse@pivotal.io>
2016-12-02 15:04:01 -08:00
Dan Williams
de002ff25a Merge pull request #322 from cf-container-networking/flannel-cni-stateDir
Allow flannel CNI plugin stateDir to be configurable
2016-11-18 15:27:35 -06:00
Mark St.Godard
6eac0ee904 flannel: rename stateDir to dataDir
Rename StateDir to DataDir for flannel CNI plugin
2016-11-17 15:54:29 -06:00
Gabe Rosenhouse
ba6c5af5dc Merge pull request #327 from dcbw/host-local-tests
host-local: add DataDir IPAM conf option and use it for testcases
2016-11-14 08:17:40 -08:00
Mark St.Godard
15de81eac6 flannel: updated flannel test to use pkg/testutils
reworked the flannel test to use testutils CmdAddWithResult and
CmdDelWithResult
2016-11-13 12:16:32 -06:00
Mark St.Godard
48d3b46eb2 noop plugin: support multiple CNI_ARGS
Updated noop plugin to parse the CNI_ARGS pairs, to allow more than just
the DEBUG arg.
2016-11-10 16:04:42 -06:00
Dan Williams
e085226f82 host-local: add DataDir IPAM conf option and use it for testcases
Add an e2e host-local plugin testcase, which requires being able
to pass the datadir into the plugin so we can erase it later.
We're not always guaranteed to have access to the default data
dir location, plus it should probably be configurable anyway.
2016-11-10 12:12:16 -06:00
Mark St.Godard
f0daefa63d flannel: add unit tests for config loading
backfill unit tests to add coverage for loadFlannelNetConf and
loadFlannelSubnetEnv
2016-11-05 23:27:14 -05:00
Lincoln Stoll
9201f3f1d9
ipvlan: Support ipvlan l3s mode.
This landed in kernel in 4fbae7d
2016-11-05 13:41:07 -07:00
Mark St.Godard
fa264e6e36 flannel: add integration test suite
add new test for flannel plugin that delegates to the noop plugin and
validates that 'storeDir' can be configurable
2016-11-05 10:47:07 -05:00
Mark St.Godard
b463642ac0 Allow flannel CNI plugin stateDir to be configurable
- Add optional 'stateDir' to flannel NetConf, if not present default to
/var/lib/cni/flannel

Signed-off-by: Jay Dunkelberger <ldunkelberger@pivotal.io>
2016-11-03 17:10:13 -05:00
Dan Williams
a29fc24f11 Merge pull request #296 from rosenhouse/plugins-require-versioned-config
Plugins validate cniVersion of NetConf
2016-09-22 17:11:34 -05:00
Minhan Xia
52e4358cbd host-local: fix allocation of last address in a /30 2016-09-21 13:10:05 -07:00
Gabe Rosenhouse
0135e2751e versioning: ipam config is not versioned 2016-09-19 13:25:28 -07:00
Gabe Rosenhouse
fd150a4c97 skel: Plugins require a cniVersion in the NetConf 2016-09-18 21:30:57 -07:00
Gabe Rosenhouse
56032390fe Merge pull request #287 from rosenhouse/multi-version
Plugins report a list of supported versions
2016-09-12 13:44:14 -07:00
Gabe Rosenhouse
7958b9f0cc versioning: revert spec version to 0.2.0 2016-09-06 15:37:42 -04:00
Gabe Rosenhouse
d5e2e375d4 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
Dan Williams
95a9ea0bd2 host-local: don't allocate the broadcast address or allow invalid networks
There aren't any IPs to allocate in /32 or /31 networks, so don't allow them.
2016-09-02 17:20:09 -05:00
Dan Williams
959af1e6ab host-local: ensure requested IPs are within the given range
And also make sure that RangeStart and RangeEnd are sane.
2016-09-02 16:52:29 -05:00
Dan Williams
dfc4f7cd2a host-local: don't allocate past RangeEnd
When RangeEnd is given, a.end = RangeEnd+1.

If when getSearchRange() is called and lastReservedIP equals
RangeEnd, a.nextIP() only compares lastReservedIP (which in this
example is RangeEnd) against a.end (which in this example is
RangeEnd+1) and they clearly don't match, so a.nextIP() returns
start=RangeEnd+1 and end=RangeEnd.

Get() happily allocates RangeEnd+1 because it only compares 'cur'
to the end returned by getSearchRange(), not to a.end, and thus
allocates past RangeEnd.

Since a.end is inclusive (eg, host-local will allocate a.end) the
fix is to simply set a.end equal to RangeEnd.
2016-09-02 16:37:34 -05:00
Gabe Rosenhouse
536cb5b99b 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
d3ecadb860 invoke: backfill tests for plugin execution 2016-08-30 23:52:47 -04:00
Tom Denham
5a67f5d6fb Merge pull request #273 from zreigz/reconfigure-bridge-ip
Reconfigure bridge IP address
2016-08-12 15:04:22 -07:00
Lukasz Zajaczkowski
d09b18dac4 plugins: reconfigure bridge IP address
Add possibility to reconfigure bridge IP address when there is a new value.
New boolean flag added to net configuration to force IP change if it is need.
Otherwise code behaves as previously and throws error
2016-08-02 07:33:17 +02:00
Stefan Junker
054fa9e42d ipam/host-local/allocator tests: cover requested IP
Further:
* improve error handling
2016-08-01 18:13:15 -07:00
Stefan Junker
5a52316ab5 plugins/{bridge,macvlan} test: ensure hardware addr
* bridge: Test the following interface's hardware address for the CNI specific
prefix:
  - bridge with IP address
  - container veth
* plugins/macvlan test: ensure hardware addr
2016-07-22 15:40:00 -07:00
Stefan Junker
55fd81f775 plugins/ptp: set the host veth hwaddr correctly 2016-07-22 15:34:54 -07:00
Stefan Junker
7d19c01818 pkg/ip: use iface name in SetHWAddrByIP 2016-07-22 15:34:53 -07:00
Stefan Junker
924b30b57d plugins: set MAC addresses based on IP
This will give deterministic MAC addresses for all interfaces CNI
creates and manages the IP for:
* bridge: container veth and host bridge
* macvlan: container veth
* ptp: container veth and host veth
2016-07-22 15:34:53 -07:00
Gabe Rosenhouse
c657c61767 plugins: cleanup tests of no-op plugin 2016-07-22 13:30:55 -07:00
Gabe Rosenhouse
5835c2bbb1 plugins: adds new no-op plugin that may be used as a test-double
Plugin can be configured to record all inputs and to respond with
arbitrary stdout or error message.  Will support upcoming integration
testing.
2016-07-15 12:48:02 -07:00
Pengfei Ni
cd14fc0e06 plugins/main/ptp: add functional tests 2016-07-11 09:25:36 +08:00
Minhan Xia
2445a960a9 plugins/ipam: round robin ip allocation for host-local ipam
This changes the ip allocation logic to round robin. Before this, host-local IPAM searched for available IPs from start of subnet. Hence it tends to allocate IPs that had been used recently. This is not ideal since it may cause collisions.
2016-06-02 20:37:05 +02:00
Stefan Junker
72337159c1 plugins: don't require CNI_NETNS for DEL command
This will allow to free up the IPAM allocations when the caller doesn't
have access to the network namespace anymore, e.g. due to a reboot.
2016-05-27 10:57:39 +02:00