plugins.git
9 years agopkg/ipam{,test}: improve error handling and tests
Stefan Junker [Tue, 21 Jun 2016 23:28:38 +0000 (16:28 -0700)]
pkg/ipam{,test}: improve error handling and tests

* _suite.go and _test.go file should be in the same package, using the
  _test package for that, which requires some fields and methods to be
  exported
* Introduce error type for cleaner error handling
* test adaptions for error type checking

9 years agoadd tests for generateHardwardAddr
Minhan Xia [Tue, 3 May 2016 22:47:28 +0000 (15:47 -0700)]
add tests for generateHardwardAddr

9 years agoconfigure mac address based on assigned ip
Minhan Xia [Tue, 3 May 2016 19:03:05 +0000 (12:03 -0700)]
configure mac address based on assigned ip

9 years agoplugins: adds new no-op plugin that may be used as a test-double
Gabe Rosenhouse [Thu, 14 Jul 2016 20:59:10 +0000 (13:59 -0700)]
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.

9 years agomisc: fix up copyright dates
Gabe Rosenhouse [Thu, 14 Jul 2016 23:09:27 +0000 (16:09 -0700)]
misc: fix up copyright dates

9 years agopkg/skel: improve error message for missing CNI_COMMAND env var
Gabe Rosenhouse [Thu, 14 Jul 2016 02:54:22 +0000 (22:54 -0400)]
pkg/skel: improve error message for missing CNI_COMMAND env var

This makes the error message for missing CNI_COMMAND consistent with
that of other required environment variables.

9 years agopkg/skel: missing env var log lines appear in stderr
Gabe Rosenhouse [Thu, 14 Jul 2016 02:24:34 +0000 (22:24 -0400)]
pkg/skel: missing env var log lines appear in stderr

Previously, the log lines appeared in stdout before the JSON encoding of
the error message.  That would break JSON parsing of stdout.  Instead, we use
stderr for these unstructured logs, consistent with the CNI spec.

9 years agopkg/skel: refactor to use dependency injection
Gabe Rosenhouse [Thu, 14 Jul 2016 02:12:06 +0000 (22:12 -0400)]
pkg/skel: refactor to use dependency injection

Extract dependencies on os to enable more complete unit test coverage

9 years agopkg/ns: fix misspelling in comment
Pengfei Ni [Tue, 14 Jun 2016 16:52:58 +0000 (00:52 +0800)]
pkg/ns: fix misspelling in comment

9 years agopkg/types: cover string for unmarshal tests
Stefan Junker [Mon, 6 Jun 2016 17:50:42 +0000 (19:50 +0200)]
pkg/types: cover string for unmarshal tests

9 years agopkg/types: Add UnmarshallableString type
Tom Denham [Wed, 1 Jun 2016 00:12:40 +0000 (17:12 -0700)]
pkg/types: Add UnmarshallableString type

Allow strings to be unmarshalled for CNI_ARGS

CNI_ARGS uses types.LoadArgs to populate a struct.
The fields in the struct must meet the TextUnmarshaler interface.

This code adds a UnmarshallableString type to assist with this.

9 years agopkg/ns: introduce error types indicate NS verification
Stefan Junker [Fri, 27 May 2016 09:52:44 +0000 (11:52 +0200)]
pkg/ns: introduce error types indicate NS verification

9 years agoskel/test: add case for empty NETNS
Stefan Junker [Fri, 27 May 2016 10:26:42 +0000 (12:26 +0200)]
skel/test: add case for empty NETNS

9 years agoplugins: don't require CNI_NETNS for DEL command
Stefan Junker [Fri, 27 May 2016 08:57:39 +0000 (10:57 +0200)]
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.

9 years agopkg/skel: allow arg requriements specified by CMD
Stefan Junker [Fri, 27 May 2016 08:56:24 +0000 (10:56 +0200)]
pkg/skel: allow arg requriements specified by CMD

9 years agopkg/ns: consider PROCFS during NS verification
Stefan Junker [Wed, 25 May 2016 21:49:25 +0000 (23:49 +0200)]
pkg/ns: consider PROCFS during NS verification

This is an attempt to bring compatibility with Kernel <3.19, where NSFS
where PROCFS was used for network namespaces.

9 years agopkg/ns: test IsNSFS()
Stefan Junker [Tue, 24 May 2016 20:30:01 +0000 (22:30 +0200)]
pkg/ns: test IsNSFS()

9 years agopkg/ns: test case for rejecting a non-ns nspath
Stefan Junker [Tue, 24 May 2016 20:21:57 +0000 (22:21 +0200)]
pkg/ns: test case for rejecting a non-ns nspath

9 years agopkg/ns: verify netns when initialized with GetNS
Stefan Junker [Tue, 24 May 2016 16:16:34 +0000 (18:16 +0200)]
pkg/ns: verify netns when initialized with GetNS

9 years agopkg/ns: add tests cases for Close()'d NS
Stefan Junker [Tue, 24 May 2016 18:48:12 +0000 (20:48 +0200)]
pkg/ns: add tests cases for Close()'d NS

9 years agopkg/ns: don't allow operations after Close()
Stefan Junker [Tue, 24 May 2016 18:27:18 +0000 (20:27 +0200)]
pkg/ns: don't allow operations after Close()

9 years agotestutils: add e2e testing helper code
Dan Williams [Tue, 29 Mar 2016 22:45:46 +0000 (17:45 -0500)]
testutils: add e2e testing helper code

9 years agons: add interface, use it, and fix thread-related namespace switch issues
Dan Williams [Tue, 5 Apr 2016 16:10:31 +0000 (11:10 -0500)]
ns: add interface, use it, and fix thread-related namespace switch issues

Add a namespace object interface for somewhat cleaner code when
creating and switching between network namespaces.  All created
namespaces are now mounted in /var/run/netns to ensure they
have persistent inodes and paths that can be passed around
between plugin components without relying on the current namespace
being correct.

Also remove the thread-locking arguments from the ns package
per https://github.com/appc/cni/issues/183 by doing all the namespace
changes in a separate goroutine that locks/unlocks itself, instead of
the caller having to track OS thread locking.

9 years agoMerge pull request #199 from dcbw/fix-bridge-tx-queue-length
Stefan Junker [Thu, 19 May 2016 21:05:08 +0000 (23:05 +0200)]
Merge pull request #199 from dcbw/fix-bridge-tx-queue-length

bridge: leave TX queue length as kernel default, not 0

9 years agoMerge pull request #200 from squaremo/simplify-readme
Michael Bridgen [Thu, 19 May 2016 12:21:40 +0000 (13:21 +0100)]
Merge pull request #200 from squaremo/simplify-readme

Simplify README preamble

9 years agopkg/ns: evaluate syscall number at compile-time
Angus Lees [Fri, 13 May 2016 07:32:40 +0000 (17:32 +1000)]
pkg/ns: evaluate syscall number at compile-time

Previously this code used a run-time map lookup keyed by
runtime.GOOS/GOARCH.  This version uses conditional compilation to make
this choice at compile time, giving immediate feedback for unsupported
platforms.

9 years agopkg/ns: use correct syscall number on arm
Angus Lees [Fri, 13 May 2016 07:18:39 +0000 (17:18 +1000)]
pkg/ns: use correct syscall number on arm

9 years ago*: appc/cni -> containernetworking/cni
Stefan Junker [Wed, 4 May 2016 14:06:05 +0000 (16:06 +0200)]
*: 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.

9 years agopkg/utils: add functions to work with sysctl
Piotr Skamruk [Mon, 7 Mar 2016 15:40:27 +0000 (16:40 +0100)]
pkg/utils: add functions to work with sysctl

9 years agoDocument use of goroutine and lockosthread in test helpers
Gabe Rosenhouse [Mon, 18 Apr 2016 03:27:02 +0000 (20:27 -0700)]
Document use of goroutine and lockosthread in test helpers

9 years agons: fix reading net namespace in multi-threaded processes
Dan Williams [Wed, 6 Apr 2016 16:03:31 +0000 (11:03 -0500)]
ns: fix reading net namespace in multi-threaded processes

/proc/self/ns/net gives the main thread's namespace, not necessarily
the namespace of the thread that's running the testcases.  This causes
sporadic failures of the tests.

For example, with a testcase reading inodes after switching netns:

/proc/27686/task/27689/ns/net 4026532565
/proc/self/ns/net 4026531969
/proc/27686/task/27689/ns/net 4026532565

See also:
https://github.com/vishvananda/netns/commit/008d17ae001344769b031375bdb38a86219154c6

Running Suite: pkg/ns Suite
===========================
Random Seed: 1459953577
Will run 6 of 6 specs

• Failure [0.028 seconds]
Linux namespace operations
/cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:167
  WithNetNS
  /cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:166
    executes the callback within the target network namespace [It]
    /cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:97

    Expected
        <uint64>: 4026531969
    to equal
        <uint64>: 4026532565

    /cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:96
------------------------------
•••••

Summarizing 1 Failure:

[Fail] Linux namespace operations WithNetNS [It] executes the callback within the target network namespace
/cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:96

Ran 6 of 6 Specs in 0.564 seconds
FAIL! -- 5 Passed | 1 Failed | 0 Pending | 0 Skipped --- FAIL: TestNs (0.56s)
FAIL

9 years agoFix issues with MakeNetworkNS test helper
Gabe Rosenhouse [Mon, 18 Apr 2016 02:44:00 +0000 (19:44 -0700)]
Fix issues with MakeNetworkNS test helper

9 years agoAdd basic unit tests of testhelpers
Gabe Rosenhouse [Mon, 18 Apr 2016 01:48:50 +0000 (18:48 -0700)]
Add basic unit tests of testhelpers

9 years agoExtract inode inspection functions into testhelpers
Gabe Rosenhouse [Mon, 18 Apr 2016 01:35:49 +0000 (18:35 -0700)]
Extract inode inspection functions into testhelpers

9 years agoExtract testhelpers from loopback test suite
Gabe Rosenhouse [Mon, 18 Apr 2016 01:28:10 +0000 (18:28 -0700)]
Extract testhelpers from loopback test suite

9 years ago*: appc/cni -> containernetworking/cni
Stefan Junker [Wed, 4 May 2016 14:06:05 +0000 (16:06 +0200)]
*: 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.

9 years agoMerge pull request #187 from appc/v0.3.0
Stefan Junker [Fri, 22 Apr 2016 17:25:54 +0000 (19:25 +0200)]
Merge pull request #187 from appc/v0.3.0

merge unneeded branch v0.3.0 into master

9 years agoMerge pull request #182 from rosenhouse/document-lockosthread
Zach Gershman [Mon, 18 Apr 2016 17:45:46 +0000 (10:45 -0700)]
Merge pull request #182 from rosenhouse/document-lockosthread

Document use of goroutine and LockOSThread in test helpers

9 years agons: fix reading net namespace in multi-threaded processes
Dan Williams [Wed, 6 Apr 2016 16:03:31 +0000 (11:03 -0500)]
ns: fix reading net namespace in multi-threaded processes

/proc/self/ns/net gives the main thread's namespace, not necessarily
the namespace of the thread that's running the testcases.  This causes
sporadic failures of the tests.

For example, with a testcase reading inodes after switching netns:

/proc/27686/task/27689/ns/net 4026532565
/proc/self/ns/net 4026531969
/proc/27686/task/27689/ns/net 4026532565

See also:
https://github.com/vishvananda/netns/commit/008d17ae001344769b031375bdb38a86219154c6

Running Suite: pkg/ns Suite
===========================
Random Seed: 1459953577
Will run 6 of 6 specs

• Failure [0.028 seconds]
Linux namespace operations
/cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:167
  WithNetNS
  /cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:166
    executes the callback within the target network namespace [It]
    /cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:97

    Expected
        <uint64>: 4026531969
    to equal
        <uint64>: 4026532565

    /cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:96
------------------------------
•••••

Summarizing 1 Failure:

[Fail] Linux namespace operations WithNetNS [It] executes the callback within the target network namespace
/cni/gopath/src/github.com/appc/cni/pkg/ns/ns_test.go:96

Ran 6 of 6 Specs in 0.564 seconds
FAIL! -- 5 Passed | 1 Failed | 0 Pending | 0 Skipped --- FAIL: TestNs (0.56s)
FAIL

9 years agoDocument use of goroutine and lockosthread in test helpers
Gabe Rosenhouse [Mon, 18 Apr 2016 03:27:02 +0000 (20:27 -0700)]
Document use of goroutine and lockosthread in test helpers

9 years agoFix issues with MakeNetworkNS test helper
Gabe Rosenhouse [Mon, 18 Apr 2016 02:44:00 +0000 (19:44 -0700)]
Fix issues with MakeNetworkNS test helper

9 years agoAdd basic unit tests of testhelpers
Gabe Rosenhouse [Mon, 18 Apr 2016 01:48:50 +0000 (18:48 -0700)]
Add basic unit tests of testhelpers

9 years agoExtract inode inspection functions into testhelpers
Gabe Rosenhouse [Mon, 18 Apr 2016 01:35:49 +0000 (18:35 -0700)]
Extract inode inspection functions into testhelpers

9 years agoExtract testhelpers from loopback test suite
Gabe Rosenhouse [Mon, 18 Apr 2016 01:28:10 +0000 (18:28 -0700)]
Extract testhelpers from loopback test suite

9 years agopkg/utils: add functions to work with sysctl
Piotr Skamruk [Mon, 7 Mar 2016 15:40:27 +0000 (16:40 +0100)]
pkg/utils: add functions to work with sysctl

9 years ago*: add missing license headers + check
Jonathan Boulle [Fri, 1 Apr 2016 13:35:21 +0000 (15:35 +0200)]
*: add missing license headers + check

9 years agopkg/utils: correct the test's expected chain names
Stefan Junker [Thu, 31 Mar 2016 15:11:11 +0000 (17:11 +0200)]
pkg/utils: correct the test's expected chain names

9 years ago*: add comment to iptables rules for ipmasq
Stefan Junker [Thu, 31 Mar 2016 13:44:54 +0000 (15:44 +0200)]
*: add comment to iptables rules for ipmasq

9 years agopkg/utils: remove unneeded condition in tests
Stefan Junker [Thu, 31 Mar 2016 09:55:46 +0000 (11:55 +0200)]
pkg/utils: remove unneeded condition in tests

9 years agopkg/utils: fix docstring
Stefan Junker [Thu, 31 Mar 2016 09:50:18 +0000 (11:50 +0200)]
pkg/utils: fix docstring

9 years agopkg/utils: split and unexport constants
Stefan Junker [Thu, 31 Mar 2016 08:08:52 +0000 (10:08 +0200)]
pkg/utils: split and unexport constants

9 years agopkg/utils: fix docstring
Stefan Junker [Wed, 30 Mar 2016 17:40:31 +0000 (19:40 +0200)]
pkg/utils: fix docstring

9 years agopkg/utils: use constant for chain prefix
Stefan Junker [Wed, 30 Mar 2016 17:40:20 +0000 (19:40 +0200)]
pkg/utils: use constant for chain prefix

9 years agopkg/utils: use name+id for hash and extend tests
Stefan Junker [Wed, 30 Mar 2016 17:17:37 +0000 (19:17 +0200)]
pkg/utils: use name+id for hash and extend tests

9 years agopkg: add a function to generate chain names
Abhishek Chanda [Wed, 23 Mar 2016 00:16:59 +0000 (17:16 -0700)]
pkg: add a function to generate chain names

Adds a function to generate chain names for use in iptables and
ports all drivers to use that function. Also adds tests for the
said function.

9 years agopkg/types: add tests for args
Stefan Junker [Thu, 17 Mar 2016 13:09:54 +0000 (14:09 +0100)]
pkg/types: add tests for args

9 years agopkg/types: add IgnoreUnknown arg and logic
Stefan Junker [Thu, 17 Mar 2016 13:08:29 +0000 (14:08 +0100)]
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.

9 years agopkg/skel: add rudimentary unit tests
Stefan Junker [Fri, 18 Mar 2016 21:28:14 +0000 (22:28 +0100)]
pkg/skel: add rudimentary unit tests

This is an attempt to testing the PluginMain() function of the skel pkg.
We should be able to do better by using a mockable interface for the
plugins, but this is a start.

9 years agoUpdate docstring on WithNetNS
Gabe Rosenhouse [Tue, 15 Mar 2016 15:37:00 +0000 (08:37 -0700)]
Update docstring on WithNetNS

9 years agoWithNetNS restores original namespace when callback errors
Gabe Rosenhouse [Tue, 15 Mar 2016 01:57:16 +0000 (18:57 -0700)]
WithNetNS restores original namespace when callback errors

- adds test coverage of WithNetNS in BDD-style

9 years agoAdd invoke.Delegate{Add,Del} for use by meta-plugins
Michael Bridgen [Wed, 2 Mar 2016 17:02:52 +0000 (17:02 +0000)]
Add invoke.Delegate{Add,Del} for use by meta-plugins

The 'flannel' meta plugin delegates to other plugins to do the actual
OS-level work. It used the ipam.Exec{Add,Del} procedures for this
delegation, since those do precisely what's needed.

However this is a bit misleading, since the flannel plugin _isn't_
doing this for IPAM, and the ipam.Exec* procedures aren't doing
something specific to IPAM plugins.

So: anticipating that there may be more meta plugins that want to
delegate in the same way, this commit moves generic delegation
procedures to `pkg/invoke`, and makes the `pkg/ipam` procedures (still
used, accurately, in the non-meta plugins) shims.

9 years agoMerge pull request #120 from zachgersh/find-better-error
Stefan Junker [Wed, 2 Mar 2016 10:14:50 +0000 (11:14 +0100)]
Merge pull request #120 from zachgersh/find-better-error

Better error messages when plugin is not found

9 years agoadded the String method to Result type
André Martins [Sun, 31 Jan 2016 03:18:33 +0000 (03:18 +0000)]
added the String method to Result type

Signed-off-by: André Martins <aanm90@gmail.com>
9 years agoBetter error message when plugin cannot be found
Zachary Gershman [Wed, 10 Feb 2016 21:42:10 +0000 (13:42 -0800)]
Better error message when plugin cannot be found

9 years ago*: reflect SPEC's DNS changes in implementation
Stefan Junker [Wed, 27 Jan 2016 11:12:16 +0000 (12:12 +0100)]
*: reflect SPEC's DNS changes in implementation

* DNS is now a type which will result in a JSON dictionary in
  configurations and results
* Minor refactoring, making use of type embedding

9 years ago*: add "dns" field to the configuration
Alban Crequy [Tue, 26 Jan 2016 17:54:56 +0000 (18:54 +0100)]
*: add "dns" field to the configuration

appc/cni#76 added a "dns" field in the result JSON. But before this
patch, the plugins had no way of knowing which name server to return.

There could be two ways of knowing which name server to return:
1. add it as an extra argument ("CNI_ARGS")
2. add it in the network configuration as a convenience (received via
   stdin)

I chose the second way because it is easier. In the case of rkt, it
means the user could just add the DNS name servers in
/etc/rkt/net.d/mynetwork.conf.

10 years agopkg/ip: fix typo in error message, s/iptabes/iptables/
Derek Gonyeo [Wed, 16 Dec 2015 21:20:19 +0000 (13:20 -0800)]
pkg/ip: fix typo in error message, s/iptabes/iptables/

10 years agoChange copyright from CoreOS to CNI authors
Eugene Yakubovich [Tue, 29 Sep 2015 18:51:33 +0000 (11:51 -0700)]
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).

10 years agolink: switch to host netns to set up host veth end
Stefan Junker [Thu, 24 Sep 2015 16:27:41 +0000 (18:27 +0200)]
link: switch to host netns to set up host veth end

10 years agoRevert "plugins/ptp: allow host veth to be UP"
Stefan Junker [Thu, 24 Sep 2015 16:28:14 +0000 (18:28 +0200)]
Revert "plugins/ptp: allow host veth to be UP"

This reverts commit 231d2d5a27f3ba54219c3f0b1c8ef2c5dab4faaf.

10 years agoplugins/ptp: allow host veth to be UP
Stefan Junker [Wed, 23 Sep 2015 09:03:22 +0000 (11:03 +0200)]
plugins/ptp: allow host veth to be UP

10 years agobug fix: exec of DEL cmd caused JSON decode error
Eugene Yakubovich [Fri, 18 Sep 2015 17:30:10 +0000 (10:30 -0700)]
bug fix: exec of DEL cmd caused JSON decode error

When plugin is executed with a DEL command, it does not
print result to stdout unless there is an error. Therefore
it stdout bytes should not be passed to json.Unmarshal.

10 years agoFactor an API out into a module
Michael Bridgen [Fri, 7 Aug 2015 15:27:52 +0000 (16:27 +0100)]
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).

10 years agoplugin/ipam: correct formatting of error message
Neil Wilson [Tue, 8 Sep 2015 03:20:11 +0000 (03:20 +0000)]
plugin/ipam: correct formatting of error message

10 years agoIPAM plugin: improve error messages
Neil Wilson [Mon, 7 Sep 2015 15:15:23 +0000 (15:15 +0000)]
IPAM plugin: improve error messages

Make it more clear that we failed to find an IPAM plugin.
Check for a missing plugin name and issue a more helpful error.

10 years agoplugin/ipam: fix typo in error message
Jonathan Boulle [Mon, 7 Sep 2015 22:43:34 +0000 (15:43 -0700)]
plugin/ipam: fix typo in error message

10 years agoCNI_ARGS: use ';' to split args as documented
Stefan Junker [Sat, 5 Sep 2015 16:58:58 +0000 (18:58 +0200)]
CNI_ARGS: use ';' to split args as documented

10 years agohost-local: allow ip request via CNI_ARGS
Stefan Junker [Sun, 16 Aug 2015 00:30:04 +0000 (02:30 +0200)]
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.

10 years agoenable net.ipv4.ip_forward in plugins that need it
Eugene Yakubovich [Mon, 13 Jul 2015 22:41:02 +0000 (15:41 -0700)]
enable net.ipv4.ip_forward in plugins that need it

10 years agoNo more path rewriting
Eugene Yakubovich [Fri, 12 Jun 2015 19:15:11 +0000 (12:15 -0700)]
No more path rewriting

Path rewriting causes too many problems when vendoring
vendored code. When CNI code is vendored into rkt,
godep has problems code already vendored by CNI.

10 years agoPropagate json error object to the caller
Eugene Yakubovich [Tue, 2 Jun 2015 00:34:00 +0000 (17:34 -0700)]
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.

10 years agoadd DHCP IPAM plugin
Eugene Yakubovich [Tue, 19 May 2015 19:02:41 +0000 (12:02 -0700)]
add DHCP IPAM plugin

The plugin binary actually functions in two modes. The first mode
is a regular CNI plugin. The second mode (when stared with "daemon" arg)
runs a DHCP client daemon. When executed as a CNI plugin, it issues
an RPC request to the daemon for actual processing. The daemon is
required since a DHCP lease needs to be maintained by periodically
renewing it. One instance of the daemon can server arbitrary number
of containers/leases.

10 years agoMerge pull request #9 from eyakubovich/errors
Eugene Yakubovich [Fri, 8 May 2015 22:08:03 +0000 (15:08 -0700)]
Merge pull request #9 from eyakubovich/errors

report errors via JSON

10 years agoreport errors via JSON
Eugene Yakubovich [Thu, 30 Apr 2015 00:52:41 +0000 (17:52 -0700)]
report errors via JSON

This reflects the latest SPEC draft.

10 years agoDo not use netns as ID or for entropy
Eugene Yakubovich [Tue, 5 May 2015 20:35:20 +0000 (13:35 -0700)]
Do not use netns as ID or for entropy

ContainerID is now required so use that
or generate random bytes.

Fixes #5

10 years agoAdd plugin code
Eugene Yakubovich [Wed, 15 Apr 2015 22:35:02 +0000 (15:35 -0700)]
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.