50 Commits

Author SHA1 Message Date
Eugene Yakubovich 2440b4a54d Merge pull request #960 from steveeJ/private-net-selection2
networking: allow network selection with private-net (2nd impl.)
2015-05-29 17:42:47 -07:00
Stefan Junker c65f7aa31f networking: allow network selection with private-net
This commit adds the possiblity of passing a comma separated list of network
names to the '-private-net' argument. Only networks with their names specified
are loaded in the pods network stack.

The network documentation has been updated accordingly.
2015-05-29 17:21:53 -07:00
Eugene Yakubovich 6c3f1e34c2 Merge pull request #963 from steveeJ/acmetadataurl-env
networking: populate AC_METADATA_URL correctly
2015-05-29 13:41:18 -07:00
Stefan Junker 299a0ee6ad networking: populate AC_METADATA_URL correctly
This commit allows the mentioned environment var to be populated correctly.
On the way some error handling for involved code was added.
2015-05-29 11:35:09 -07:00
Eugene Yakubovich fd91916f2f networking: fix gc cleaning up networks
This also undoes the temporary work around
of using absolute paths for pod directories.

Fixes #953
2015-05-29 10:06:51 -07:00
Eugene Yakubovich 03a907b587 networking: hanlde error json from plugin
When plugins exit with non-zero code, they now
print a JSON with the error info to stdout. This
will parse this output and report that error.

Partly fixes #953
2015-05-28 16:48:26 -07:00
Alban Crequy cb524d42e4 Merge pull request #860 from steveeJ/podenv-usernets-parse
networking: load only *.conf files
2015-05-20 10:19:11 +02:00
Jonathan Boulle 9685f37575 *: adjust copyright header
Inspired by a similar change in the Kubernetes project [1], this changes
the copyright header to the more generic "The rkt Authors" rather than
"CoreOS, Inc.", which is only sometimes correct.

https://github.com/GoogleCloudPlatform/kubernetes/commit/6b3a6e6b983f967c88d14d26542ec6e30c49ebd3
2015-05-03 14:29:15 -07:00
Stefan Junker ddef17cf67 networking: load only *.conf files
All files found in UserNetPath that don't match the suffix '.conf' will be
ignored as a network configuration file.

Fixes #859.
2015-05-02 21:47:53 -07:00
Jonathan Boulle e1e407f836 networking: make netns path absolute for CNI plugins
As discovered in #851 - some of the CNI plugins (for example, veth)
relies on the supplied `CNI_NETNS` as a source of uniqueness for things
like entropy. In theory this is reasonable because network namespace
paths should be unique per-pod. However, in rkt, the stage1 init (which
executes the plugins) was passing a relative path from its cwd, rather
than an absolute path - for example, "netns" rather than
"/var/lib/rkt/pods/<uuid>/netns".

As a consequence of this, every network plugin was executed with the
same value for `CNI_NETNS`. This results in conflicts when e.g. every
veth plugin attempts to create an interface by the same name, since they
do a straightforward hash of `CNI_NETNS` to generate interface names.

This should be considered an interim solution until this is definitively
answered in the upstream CNI specification.

https://github.com/appc/cni/issues/5
2015-05-01 18:53:33 -07:00
Jonathan Boulle ce47f2db66 networking: podRoot -> rktRoot
rktRoot is misleading as the directory is really the root of a specific
pod. Also add a TODO note that this is currently only ever set to cwd
(i.e. "."), and hence necessitates relative paths.
2015-05-01 16:29:01 -07:00
Eugene Yakubovich 7abd8f3b84 net: switch to using CNI plugins 2015-04-27 14:43:25 -07:00
Eugene Yakubovich bf33546a2d net: stage1 gc will clean up networking 2015-04-14 17:03:03 -07:00
Eugene Yakubovich 1a8c30b1f2 net: bug fix: suppress errors printed out if no ports were exposed
If no ports are exposed, no corresponding iptables rules get installed.
Unfortunately, on the teardown path, there's no good way to test for
that or issue deletes that succeed if there's nothing to do. Therefore
it's better to just ignore these errors on the cleanup path.
2015-04-07 16:18:44 -07:00
Eugene Yakubovich dbc1f0f238 net: add option to expose ports on hosts
Ports that were defined in app manifest can be
exposed via --port=name:host-port option on cmd line.
For example, given app manifest with ports entry:
{
    "name": "http",
    "port": 80,
    "protocol": "tcp"
}

rkt run --private-net --port=http:8888 myapp.aci
will forward traffic from host's tcp port 8888 to
container's port 80.

Fixes #624
2015-04-03 17:24:02 -07:00
Jonathan Boulle 79753c9b19 *: rocket -> rkt 2015-03-31 16:31:21 -07:00
Jonathan Boulle 3fd0303076 *: global containers -> pods rename 2015-03-31 15:55:06 -07:00
Eugene Yakubovich ebdc1503df mdsvc: no more 169.254.196.255 address
Since the spec requires AC_METADATA_URL env var,
well known IP is no longer needed. This removes
the iptables manipulation. Instead the IP address of the
host is passed in the AC_METADATA_URL. This host IP
is the address of the host end of the default veth.
2015-03-30 16:04:56 -07:00
Simone Gotti deea994424 lock: convert DirLock to handle also locks on regular files.
This patch renames DirLock to FileLock (where a file can be a regular file or a
directory), adds a new LockType type to specify if the lock must be on a
directory or on a regular file and checks if the file is valid for the
requested type.
2015-03-26 14:09:10 +01:00
Eugene Yakubovich 0b935f467f net: set FD_CLOEXEC on RktLock prior to fork/exec
When launching metadata service and net plugins,
set the close-on-exec flag so the child processes
don't end up holding the lock.
2015-03-19 17:14:31 -07:00
Eugene Yakubovich 83cc67037e net: rkt list supports displaying container's IP addrs
Fixes #593
2015-03-18 14:06:04 -07:00
Eugene Yakubovich b82c4dc4d3 net: bug fix: don't use hard coded path to container dir
Containers not migrate thru state directories so hard
coded path was broken
2015-03-12 17:38:13 -07:00
Eugene Yakubovich 9a8233e24a Merge pull request #595 from eyakubovich/dup-nets
net: allow overriding default net
2015-03-11 17:42:31 -07:00
Jonathan Boulle 90a6410b4f *: s/-/_/ in go filenames 2015-03-11 13:09:37 -07:00
Eugene Yakubovich c10b0fda3a net: allow overriding default net
If a user supplies a net with name "default", rkt will not
instantiate its default net. Also warn and ignore duplicate
nets.
2015-03-10 16:15:33 -07:00
Eugene Yakubovich 2e09dc9ce4 Merge pull request #525 from endocode/alban/withNetNS
net: withNetNS: attempt to revert net ns in case of error
2015-03-05 17:32:22 -08:00
Eugene Yakubovich d19364433b net: added macvlan plugin
macvlan uses the specified host's interface to send the
packets. However macvlan will have its own MAC address
(randomly generated by the kernel) making it look like
yet another interface on the link.

Fixes #478
2015-03-03 10:51:12 -08:00
Eugene Yakubovich c10213f9dd net: fix names of JSON config keys 2015-02-25 12:27:31 -08:00
Eugene Yakubovich 2fb775de2c net: factor out plugin main
main function of plugins is very boilerplate with
all the env var extraction and error checking.
Factor it out into util.
2015-02-18 15:01:26 -08:00
Jonathan Boulle 17a3e8e8a7 Merge pull request #524 from endocode/alban/netns-error
net: fix error management
2015-02-13 09:15:32 -08:00
Alban Crequy ba154ffbe7 net: withNetNS: attempt to revert net ns in case of error
Before this patch, when withNetNS() returns with an error, the current
net namespace is undefined. In order to make the API more readable,
withNetNS() should always at least attempt to return in a defined
namespace used before being called, even in case of errors.

In practice, the only caller of withNetNS will handle the error case
correctly by calling Teardown() so there should be no functional changes
with this patch.
2015-02-13 16:54:16 +01:00
Alban Crequy b843ce369b net: fix error management 2015-02-13 16:10:13 +01:00
Eugene Yakubovich facff5ed44 net: copy netconf files into container dir
The user might modify or delete the net config
files while the container is running. This will
mess up the plugins on the teardown path. Copying
them into a the container directory and using them
from there should guard against that. It also lays
the foundation for GC to process unremoved files.
2015-02-12 17:34:48 -08:00
Eugene Yakubovich 2352950ba6 net: add support for MTU config 2015-02-09 12:41:44 -08:00
Eugene Yakubovich 356555864a net: added IP masquerade support 2015-02-06 16:08:39 -08:00
Eugene Yakubovich 68ee69aa42 net: ignore dup route errors; better handling of gw in bridge 2015-02-05 16:48:06 -08:00
Jonathan Boulle 72395d1ffa *: vendor appc spec
Take two at getting the spec vendored into Rocket with Godep.
Since actool is used during the construction of the stage1.aci, it
really needs to be vendored too to prevent any unexpected divergence
between whatever version the user happens to have in their PATH. Thus,
we introduce a silly dummy package (stage1/dummy.go) to coerce Godep
into vendoring actool. This also requires a slight rearrangement of the
appc repo, moving some functionality from actool itself into the aci
package.
2015-02-05 14:36:40 +01:00
Eugene Yakubovich a9c8cf4b45 net: call ipam plugin on container shutdown
- Fixes bugs in ipam/static release path
- veth and bridge plugins invoke ipam plugin during DEL cmd
2015-02-04 14:04:35 -08:00
Eugene Yakubovich 630beda3ae net: cnvt ipmanager to ipam plugin; make use of ipam plugins
- Convert ipamanager into IPAM plugin (static) that uses env
variables instead of cmd line args
- Make bridge and veth plugins call out to IPAM plugin
- Refacor code around the new IPAM plugins
2015-02-02 18:15:51 -08:00
Jonathan Boulle d5669c9582 *: move rktpath/metadata into single "common" pkg 2015-01-26 11:36:36 -08:00
Jonathan Boulle 6d58c1fd17 *: add missing godocs and copyright headers
Also moves pkg/util/aci.go -> pkg/aci/aci.go for simplicity and
consistency with the other pkgs.
2015-01-24 19:03:56 -08:00
Eugene Yakubovich 25ecad8162 Integrate metadata service
- Move metadatasvc into rkt as a subcommand
- Add option to spawn metadatasvc from rkt run
- Register container with metadatasvc
- Removes anti-spoofing logic -- this belongs in the network plugin

Fixes #33
2015-01-23 13:25:46 -08:00
Eugene Yakubovich ba9b6bc82a net: use env vars for plugin params; use stage1 rootfs for builtins
Simplifying the plugin interface. No more HTTP interface and plugin
configs. Plugin type maps to executable name in stage1 rootfs or
on host in a well known dir. Env vars are used for parameter passing
to the plugin. Also, default net conf is kept in stage1 rootfs to make
private networking work "out of the box".
2015-01-22 15:17:51 -08:00
Peter Bourgon c4183a7af5 networking: go vet and golint fixes
- Fix several Printf argument errors
- Fix exported symbols without comments
- Fix existing comments to abide proper style
- Fix struct declarations that use unkeyed fields
2015-01-22 17:19:01 +01:00
Eugene Yakubovich 696faf67b1 net: Give the host end of veth an IP
The scheme of having a host veth not have an IP
and not be plugged into bridge does not work in
practice. This creates a true point-to-point link
between the container and the host.
2015-01-21 12:58:02 -08:00
Eugene Yakubovich b267c9d751 net: minimal support for routes
This also sorts nets on filename during load so routes
get installed in well defined order. Additionally, it
no longer hard codes default net and assumes something
like 99-network.conf present to define default network.
2015-01-16 10:53:16 -08:00
Eugene Yakubovich 8ab28709c4 net: make bridge plugin use ipam module; bug fixes 2015-01-14 16:42:56 -08:00
Eugene Yakubovich 5d35b5a6be invoke net plugins from stage1 -- disabled for now 2015-01-13 12:02:18 -08:00
Eugene Yakubovich a4dec0aded add copyright notice and rename module 2015-01-12 16:58:03 -08:00
Eugene Yakubovich cda3e42555 incorporating code review feedback 2015-01-12 16:58:03 -08:00