plugins.git
8 years agotestutils: pass netConf in for version operations; pass raw result out for tests
Dan Williams [Tue, 22 Nov 2016 16:02:39 +0000 (10:02 -0600)]
testutils: pass netConf in for version operations; pass raw result out for tests

8 years agoskel: adds PluginMainWithError which returns a *types.Error
Gabe Rosenhouse [Mon, 23 Jan 2017 00:39:15 +0000 (16:39 -0800)]
skel: adds PluginMainWithError which returns a *types.Error

Enables plugins to do their own error-handling and cleanup logic

8 years agoapi,libcni: add network config list-based plugin chaining
Dan Williams [Sat, 17 Dec 2016 00:56:39 +0000 (18:56 -0600)]
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.

9 years agoall: assert internal objects implement interfaces
Dan Williams [Wed, 14 Dec 2016 23:09:01 +0000 (17:09 -0600)]
all: assert internal objects implement interfaces

9 years agoExpand description of goroutine+netns problems
Bryan Boreham [Thu, 17 Nov 2016 15:45:38 +0000 (15:45 +0000)]
Expand description of goroutine+netns problems

9 years agotesting: test invocation of newer plugins with an older libcni
Casey Callendrello [Fri, 14 Oct 2016 14:38:32 +0000 (16:38 +0200)]
testing: test invocation of newer plugins with an older libcni

9 years agoskel tests: correct name of CNI_CONTAINERID in tests of env vars
Gabe Rosenhouse [Mon, 17 Oct 2016 00:18:57 +0000 (17:18 -0700)]
skel tests: correct name of CNI_CONTAINERID in tests of env vars

9 years agotesting: adds basic test of backwards compatibility
Gabe Rosenhouse [Mon, 3 Oct 2016 04:43:51 +0000 (21:43 -0700)]
testing: adds basic test of backwards compatibility

9 years agoskel: use named constant for Incompatible CNI Version error code
Gabe Rosenhouse [Mon, 19 Sep 2016 20:14:02 +0000 (13:14 -0700)]
skel: use named constant for Incompatible CNI Version error code

9 years agoversioning: plugins require version match with config
Gabe Rosenhouse [Mon, 19 Sep 2016 20:00:49 +0000 (13:00 -0700)]
versioning: plugins require version match with config

infer version 0.1.0 when config is missing an explicit "cniVersion" field

9 years agoversioning: add basic version decode for network config
Gabe Rosenhouse [Mon, 19 Sep 2016 04:56:17 +0000 (21:56 -0700)]
versioning: add basic version decode for network config

9 years agoskel: Plugins require a cniVersion in the NetConf
Gabe Rosenhouse [Wed, 7 Sep 2016 00:19:26 +0000 (20:19 -0400)]
skel: Plugins require a cniVersion in the NetConf

9 years agoversioning: revert spec version to 0.2.0
Gabe Rosenhouse [Tue, 6 Sep 2016 19:24:12 +0000 (15:24 -0400)]
versioning: revert spec version to 0.2.0

9 years agoversioning: misc cleanups
Gabe Rosenhouse [Tue, 6 Sep 2016 15:22:27 +0000 (11:22 -0400)]
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

9 years agoinvoke: better name and unit test coverage for GetVersionInfo
Gabe Rosenhouse [Fri, 2 Sep 2016 20:39:01 +0000 (16:39 -0400)]
invoke: better name and unit test coverage for GetVersionInfo

9 years agoinvoke: correctly infer version for 0.1.0-vintage plugins
Gabe Rosenhouse [Fri, 2 Sep 2016 20:01:22 +0000 (16:01 -0400)]
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.

9 years agoversioning: adds tooling to compile a program against a given old CNI version
Gabe Rosenhouse [Wed, 24 Aug 2016 05:57:00 +0000 (22:57 -0700)]
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

9 years agopkg/invoke: refactor plugin exec and backfill unit tests
Gabe Rosenhouse [Fri, 2 Sep 2016 17:12:14 +0000 (13:12 -0400)]
pkg/invoke: refactor plugin exec and backfill unit tests

9 years agoversioning: document meaning of 'Legacy' version support
Gabe Rosenhouse [Mon, 29 Aug 2016 23:20:18 +0000 (19:20 -0400)]
versioning: document meaning of 'Legacy' version support

9 years agoversioning: plugins report a list of supported versions
Gabe Rosenhouse [Mon, 22 Aug 2016 06:48:04 +0000 (23:48 -0700)]
versioning: plugins report a list of supported versions

Further progress on versioning support (Issue #266).
Bump CNI spec version to 0.3.0

9 years agoMerge pull request #293 from rosenhouse/backfill-invoke-exec-tests
Gabe Rosenhouse [Thu, 1 Sep 2016 00:49:08 +0000 (20:49 -0400)]
Merge pull request #293 from rosenhouse/backfill-invoke-exec-tests

Backfill tests for plugin execution

9 years agoMerge pull request #290 from asridharan/dcos
Dan Williams [Wed, 31 Aug 2016 23:19:02 +0000 (18:19 -0500)]
Merge pull request #290 from asridharan/dcos

Fixed the check for network namespace path.

9 years agopkg/ns: fixed the check for network namespace path.
Avinash Sridharan [Wed, 24 Aug 2016 23:49:50 +0000 (23:49 +0000)]
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

9 years agopkg/ip: Ensure that SetupVeth returns correct hostVeth
Tom Denham [Mon, 29 Aug 2016 21:10:36 +0000 (14:10 -0700)]
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.

9 years agoinvoke: backfill tests for plugin execution
Gabe Rosenhouse [Wed, 31 Aug 2016 03:52:47 +0000 (23:52 -0400)]
invoke: backfill tests for plugin execution

9 years agoMerge pull request #267 from rosenhouse/version-cmd
Tom Denham [Fri, 12 Aug 2016 22:06:22 +0000 (15:06 -0700)]
Merge pull request #267 from rosenhouse/version-cmd

Adds VERSION command

9 years agopkg/ip: Return correct error if container name provided exists, and test cases
Prateek Gogia [Sun, 7 Aug 2016 19:24:56 +0000 (19:24 +0000)]
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

9 years agopkg/utils/hwaddr tests: cover v4 in v6 addr
Stefan Junker [Mon, 1 Aug 2016 23:50:40 +0000 (16:50 -0700)]
pkg/utils/hwaddr tests: cover v4 in v6 addr

9 years agopkg/ip link_test: ensure SetHWAddrByIP has an effect
Stefan Junker [Wed, 29 Jun 2016 19:13:37 +0000 (12:13 -0700)]
pkg/ip link_test: ensure SetHWAddrByIP has an effect

9 years agopkg/ip: use iface name in SetHWAddrByIP
Stefan Junker [Wed, 29 Jun 2016 19:13:05 +0000 (12:13 -0700)]
pkg/ip: use iface name in SetHWAddrByIP

9 years agopkg/ip tests: cover SetupVeth and DelLinkByName*
Stefan Junker [Wed, 29 Jun 2016 02:52:08 +0000 (19:52 -0700)]
pkg/ip tests: cover SetupVeth and DelLinkByName*

9 years agoplugins: set MAC addresses based on IP
Stefan Junker [Wed, 29 Jun 2016 00:46:17 +0000 (17:46 -0700)]
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

9 years agopkg/utils/hwaddr: migrate code from IPAM pkg
Stefan Junker [Tue, 28 Jun 2016 19:51:58 +0000 (12:51 -0700)]
pkg/utils/hwaddr: migrate code from IPAM pkg

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: plugins now respond to VERSION command
Gabe Rosenhouse [Thu, 14 Jul 2016 03:50:54 +0000 (23:50 -0400)]
pkg/skel: plugins now respond to VERSION command

To support CNI spec versioning, plugins must be able to report version
information to container runtimes.

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.