65 Commits

Author SHA1 Message Date
Casey Callendrello
72f2a1ffd4 plugins: correctly output build version, cosmetic cleanups
Now that libcni has the ability to print a version message, plumb it
through correctly.

While we're at it,
- fix import paths
- run gofmt
- add some more comments to sample
- add container runtime swappability for release
2019-04-15 16:52:07 +02:00
Michael Cambria
74a2596573 Add check support for: bridge, ipvlan, macvlan, p2p, vlan and host-device main plugins
host-local and static ipam plugins
  tuning, bandwidth and portmap meta plugins

  Utility functions created for common PrevResult checking

  Fix windows build
2019-04-03 13:08:07 -04:00
Nguyen Quang Huy
4bca3e76bf Fix redundant import alias
Because these package names are short and they are unique, it can not conflict. So the import aliases that can be omitted and we should remove them.
2019-02-20 16:58:45 +07:00
bingshen.wbs
59a746bd52 remove gateway check
Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
2018-11-29 12:59:38 +08:00
Michael Cambria
75e35b6c01 Added new test cases.
Add two interfaces (e.g. eth0, eth1) to the same container.
Ensure each file now has ContainerID and ifname.
Delete one, ensure that the right file was deleted.

Add an interface using just ContainerID in the file.
Delete to verify we are still backwards compatible with any
files created using earlier verison of host-local plugin.
2018-10-09 13:13:36 -04:00
Michael Cambria
37715a0f87 Moved directory walk, compare file code to it's own function 2018-10-09 13:13:36 -04:00
Michael Cambria
a17cadda88 Handle the case of a Delete for a reservation stored with just ContainerID without the interface 2018-10-09 13:13:36 -04:00
Michael Cambria
1e8f9525a6 Obtain ifname from CmdArgs and pass to backend Add ifname to second line of file tracking the IP address used by ContainerID
Update host-local tests to use ifname along with ContainerID
in store file

Signed-off-by: Michael Cambria <mcambria@redhat.com>
2018-10-09 13:13:36 -04:00
Neil Wilson
b2fc336833 plugins/host-local: ensure subnet is a network address
Allocation code assumes the specified subnet is a clean network address
prefix, so check that is the case and throw an error otherwise

Fixes #161
2018-06-18 10:13:34 +01:00
Casey Callendrello
68b4efb405 plugins/* stub-out GET functions so plugins build with v0.7 2018-06-15 15:28:53 +02:00
Dan Williams
731298003c plugins/testutils: pass CNI_CONTAINERID to plugins in testcases
Recent CNI specification changes require the container ID on ADD/DEL,
which the testcases were not providing.  Fix that up so things work
when this repo gets CNI revendored.
2018-04-26 11:24:30 -05:00
Casey Callendrello
aade7b93ee build: some small improvements; bump to go1.10
- bump to go 1.10
- Add a linker tag with the build version
- Remove fastbuild, go builds are cached now
- Use better ginkgo suite names
2018-04-12 16:59:51 +02:00
Casey Callendrello
b03d23a4fa ipam/host-local: Accept ip ranges as a runtime argument
This allows for the runtime to dynamically request IP ranges.

Fixes: #95
2017-12-11 13:51:01 +01:00
Rakesh Kelkar
47668f6d64 host-local: Update host-local IPAM to support Windows 2017-11-11 15:17:45 -08:00
Gabriel Rosenhouse
99f6be0319 Enable Windows CI (Appveyor)
- start list of linux_only plugins; ignore them when testing on Windows
- Isolate linux-only code by filename suffix
- Remove stub (NotImplemented) functions
- other misc. fixes for Windows compatibility
2017-11-10 08:09:29 -08:00
Gabe Rosenhouse
2f957864ea host-local disk backend store uses FileLock by reference
- this change fixes go vet warnings for the package
2017-08-30 06:52:29 -07:00
Casey Callendrello
27d027a6d3 ipam/host-local: support sets of disjoint ranges
In real-world address allocations, disjoint address ranges are common.
Therefore, the host-local allocator should support them.

This change still allows for multiple IPs in a single configuration, but
also allows for a "set of subnets."

Fixes: #45
2017-08-09 19:02:08 +02:00
Dan Williams
0da6780449 pkg,plugins: update for Result struct Interface index changes
It's a pointer now, so we need to use the helper function to set
the field and also test for nil before accessing it.
2017-06-29 13:40:36 -05:00
Casey Callendrello
2e9e87732f ipam/host-local: support multiple IP ranges
This change allows the host-local allocator to allocate multiple IPs.
This is intended to enable dual-stack, but is not limited to only two
subnets or separate address families.
2017-06-12 21:14:44 +02:00
Casey Callendrello
3c436520be move most of cni/pkg to plugins/pkg: delete code staying in cni/pkg
This moves the following packages to this repository:
* ip
* ipam
* ns
* testutils
* utils
2017-05-23 16:12:49 +02:00
Casey Callendrello
9f52fc0374 Move documentation folder to individual READMEs 2017-05-16 16:46:15 +02:00
Dan Williams
d2792f264e plugins: add plugins from containernetworking/cni
Plugins prepared from the containernetworking/cni repo as follows:

1) git reset --hard 1a9288c3c09cea4e580fdb1a636f1c5e185a391f
2) git remove everything not in plugins/
3) git remove plugins/test
4) git merge into containernetworking/plugins repo
5) adjust import paths for containernetworking/cni -> containernetworking/plugins
2017-05-14 23:12:45 -05:00
Dan Williams
21d96393ea Merge pull request #391 from tangle329/master
Validate rangeStart and rangeEnd specified in conf
2017-04-24 22:00:07 -05:00
Dan Williams
9445711fa5 spec/plugins: fix 'ip'->'ips' in the spec, bump to 0.3.1 2017-04-05 12:46:24 -05:00
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