91 Commits

Author SHA1 Message Date
Tom Denham
13824487c6
plugins/*: Don't error if the device doesn't exist
I wasn't able to test or update the dhcp plugin but from a code read it
should be fine. All the other plugins are tested and fixed
2017-03-22 08:52:29 -07:00
Tang Le
1b65890795 Validate rangeStart and rangeEnd specified in conf
Signed-off-by: Tang Le <tangle3@wanda.cn>
2017-03-10 12:51:05 +08:00
Gabe Rosenhouse
4ce9b019aa Merge pull request #366 from ehazlett/ipam-host-local-initial-reserved-ip
Do not error if last reserved not found after initial creation
2017-03-06 07:13:06 -08:00
Evan Hazlett
ac50624393
fix unrelated failing tests
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2017-03-02 15:37:43 -05:00
Evan Hazlett
2678be24d0
add test for ensuring initial subnet creation does not contain an error
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2017-03-02 15:16:09 -05:00
Evan Hazlett
474ba16901 do not error if last_reserved_ip is missing for host local ipam
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2017-03-02 13:59:21 -05:00
Tang Le
1003822e53 Check n.IPAM before use it in LoadIPAMConfig function
Signed-off-by: Tang Le <tangle3@wanda.cn>
2017-03-02 10:25:19 +08:00
Gabe Rosenhouse
eb2ff7fe57 docs: consolidate host-local documentation
- remove the README.md in the plugins/ipam/host-local (no other plugin
  has this)
- merge that info into the main Documentation/host-local.md
2017-02-15 15:20:13 -08:00
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
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
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
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
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
Minhan Xia
52e4358cbd host-local: fix allocation of last address in a /30 2016-09-21 13:10:05 -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
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
Stefan Junker
054fa9e42d ipam/host-local/allocator tests: cover requested IP
Further:
* improve error handling
2016-08-01 18:13:15 -07: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
ed5f8dfeb2 *: appc/cni -> containernetworking/cni
The project has been moved so internally we simply rename everything.
Consumers are recommended to update their vendored version of cni.
2016-05-06 16:40:27 +02:00
Stefan Junker
5a39a168f7 pkg/types: add IgnoreUnknown arg and logic
This commit adds a struct type CommonArgs that is to be embedded in
every plugin's argument struct. It contains a field named
"IgnoreUnknown" which will be parsed as a boolean and can be provided to
ignore unknown arguments passed to the plugin.
2016-03-21 20:36:05 +01:00
Stefan Junker
05c5aea77b plugins/host-local: only call LoadArgs() once 2016-03-21 20:17:47 +01:00
Abhishek Chanda
9b2f3380c1 Fix govet warnings 2016-03-16 16:25:41 -07:00
André Martins
33b2de44af fixed ipam host-local IP json tag
Signed-off-by: André Martins <aanm90@gmail.com>
2016-01-31 03:14:53 +00:00
Stefan Junker
753b10503c host-local: detect missing subnet and error out 2015-11-25 21:18:48 +01:00
Eugene Yakubovich
0becca2e96 Change copyright from CoreOS to CNI authors
CNI is developed by more than just CoreOS, Inc
and the copyright is retained by all CNI
contributors (for their respective contributed code).
2015-09-29 11:51:33 -07:00
Eugene Yakubovich
60be55a7d1 remove host-local-ptp plugin 2015-09-23 11:04:38 +02:00
Michael Bridgen
b88f173c43 Factor an API out into a module
This takes some of the machinery from CNI and from the rkt networking
code, and turns it into a library that can be linked into go apps.

Included is an example command-line application that uses the library,
called `cnitool`.

Other headline changes:

 * Plugin exec'ing is factored out

The motivation here is to factor out the protocol for invoking
plugins. To that end, a generalisation of the code from api.go and
pkg/plugin/ipam.go goes into pkg/invoke/exec.go.

 * Move argument-handling and conf-loading into public API

The fact that the arguments get turned into an environment for the
plugin is incidental to the API; so, provide a way of supplying them
as a struct or saying "just use the same arguments as I got" (the
latter is for IPAM plugins).
2015-09-16 10:14:39 +01:00
Stefan Junker
1d398af124 host-local: allow ip request via CNI_ARGS
A specific IP can now be requested via the environment variable CNI_ARGS, e.g.
`CNI_ARGS=ip=1.2.3.4`.
The plugin will try to reserve the specified IP.
If this is not successful the execution will fail.
2015-09-04 01:38:22 +02:00
Stefan Junker
d961f6cd39 host-local: fix routes in README examples 2015-08-03 15:37:14 +02:00
Eugene Yakubovich
33a575f49d Propagate json error object to the caller
When plugin errors out, it prints out a JSON object to stdout
describing the failure. This object needs to be propagated out
through the plugins and to the container runtime. This change
also adds Print method to both the result and error structs
for easy serialization to stdout.
2015-06-09 10:46:28 -07:00
Eugene Yakubovich
b2d9801b25 Do not use netns as ID or for entropy
ContainerID is now required so use that
or generate random bytes.

Fixes #5
2015-05-08 15:02:23 -07:00
Eugene Yakubovich
88377fa346 Add plugin code
This adds basic plugins.
"main" types: veth, bridge, macvlan
"ipam" type: host-local

The code has been ported over from github.com/coreos/rkt project
and adapted to fit the CNI spec.
2015-04-27 14:14:29 -07:00