73 Commits
Author SHA1 Message Date
Dimitri John Ledkov 5774390b2d Refactor stage1/init to source most of options from manifest, rather than flavor/stampfile-based.
This refactor will make it easier to integrate lkvm support, and also
brings other benefits.

Specifically, with this refactor almost all functionality of stage1
init is flavor independent and can be fully controlled via a manifest
and uses as little hard coded paths as possible.

Thus, e.g. distribution packagers, can create package which will only
have rkt/stage1 provided binaries (gc, waiter, init, etc.) and specify
the rest of things in the manifest (path to nspawn, ld.so, LD LIBRARY
PATH, libfakesdbooted.so, etc). And create fully free-standing
stage1.aci by simply creating basic distribution chroot with
distro-native tools and supplying a matching/correct aci-manifest. By
fully free-standing, I mean similar to current coreos flavor, which is
completely independent of the host OS binaries & load paths and is
truly run everywhere.

Many of these refactors will be useful for future lkvm integration,
e.g. reusing ld.so load paths and similar.
2015-06-09 10:47:56 +01:00
Alban Crequy ae9cdf168e stage1: refresh systemd patches for v219
With this change, the only patches applied on v219 are backports from systemd upstream:

https://github.com/systemd/systemd/commit/4f923a1984476de3441922ee5bf7102ebdd250ef
https://github.com/systemd/systemd/commit/47bc12e1ba35d38edda737dae232088d6d3ae688
https://github.com/systemd/systemd/commit/54b4755f15438c86991d5a4eaadc47150f7e5a84
https://github.com/systemd/systemd/commit/875e1014dd9d55cd0692dcce843598cffb2d09b0
https://github.com/systemd/systemd/commit/6b7d2e9ea4cdb4cfa1512d37548a1a967623d7f2

The patches in stage1/rootfs/usr_from_src/patches/v219/ have been tagged
with the "Origin" URL.

stage1/init/init.go is modified accordingly to avoid --keep-fd.

Fixes: #998
2015-06-08 18:26:56 +02:00
Iago López Galeiras 819d3d3f81 stage1: add halt.target
When systemd-nspawn receives a TERM signal it will send it to systemd in
stage1 which will try to run the halt.target. This target was not
present in the current stage1 so the container was not being shut down.

Fix this by adding halt.target which calls reaper.service to shut down
the container cleanly.
2015-06-08 14:23:46 +02:00
Alban Crequy 2824964937 stage1: add RKT_STAGE1_USR_FROM=usr-from-host 2015-06-04 16:33:45 +02:00
Iago López Galeiras 67c6c73a9e stage1: create cgroups before calling systemd-nspawn
To allow systemd inside stage1 to set resource limits for apps we mount
the cgroup controllers hierarchy in rkt. We need this because
systemd-nspawn mounts cgroup controllers as read-only.

We mimic systemd-nspawn cgroup mounts with the difference that we
bind-mount the apps' subdirectories over themselves so they stay
read-write. We leave the mounting of systemd's cgroup hierarchy to
nspawn.
2015-06-03 14:28:14 +02:00
Alban Crequy 2c25275523 stage1: remove --pid-file patches from systemd-nspawn
Instead of asking systemd-nspawn to write its "pid" file, rkt can write
the parent pid "ppid". Then, update getPID() to get the pid file from
/proc/$ppid/task/$ppid/children. In this way, we don't need to patch
systemd-nspawn.

getPID() is able to read both the "pid" file and the "ppid" file, in
order to work with alternative stage1s which choose to implement one or
the other method.

coreos/rkt#910
2015-06-03 12:58:09 +02:00
Alban Crequy be40b0eb67 documentation: stage1 ABI for enter 2015-06-03 10:52:06 +02:00
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
Alban Crequy a07bdc34b9 version: bump to v0.5.6 2015-05-28 17:27:21 +02:00
Iago López Galeiras 910881404d stage1: write prepare-app service programmatically
In prepare-app we depend on systemd-journal.service only if journal
linking is supported by systemd in stage1.

This commit generates prepare-app@.service so we can add this dependency
only when it's supported.
2015-05-28 16:12:39 +02:00
Iago López Galeiras acdde8a34e stage1: link journal only on systemd v219, v220 and master
If we enable journal linking, there's a race in systemd v215 that makes
(very) short-lived containers not show their output in stdout, making
tests fail. Since the CoreOS image will be updated soon we don't bother
investigating this issue and just disable journal linking in old
versions of systemd
2015-05-28 12:32:30 +02:00
Iago López Galeiras 21e1615f32 stage1: require systemd-journald before prepare-app 2015-05-28 10:22:59 +02:00
Alban Crequy 586c0af7ec usr_from_coreos: add journald files 2015-05-28 10:22:59 +02:00
Alban Crequy e33a1143cd stage1: fixes compilation on systemd-v220 (flavor=src)
This fixes the compilation for:
  RKT_STAGE1_USR_FROM=src RKT_STAGE1_SYSTEMD_VER=v220

By copying the patch from:
stage1/rootfs/usr_from_src/patches/master/0001-nspawn-add-pid-file.patch
to:
stage1/rootfs/usr_from_src/patches/v220/0001-nspawn-add-pid-file.patch

There is ongoing work to build stage1 without patches on systemd but
it's not ready yet.

The ./build script still use v219 by default.
2015-05-26 11:05:05 +02:00
Iago López Galeiras e23c6ecdc9 stage1: rebase add-pid patch to latest systemd master 2015-05-21 17:04:33 +02:00
Alban Crequy 0a268c8850 stage1: rebase pid-file patch against systemd-git-master
Because of the last changes in systemd git master, our --pid-file patch
conflicts.
2015-05-20 15:17:01 +02:00
Alban Crequy f4b72c1c5b stage1: remove keep-fd patch when built against systemd git master
Because of the last changes in systemd git master, our --keep-fd patch
is not needed anymore.
2015-05-20 15:17:01 +02:00
Alban Crequy 0ed3d37677 stage1: systemd: update build option
- remove --disable-readahead
- remove --disable-multi-seat-x
- add --disable-selinux

Also, write one option per line for better readability.

I kept the configure --help output order.
2015-05-12 10:03:39 +02:00
Jonathan Boulle 4c64fa6e93 Merge pull request #861 from jonboulle/copyright
*: adjust copyright header + remove NOTICE
2015-05-07 14:38:45 -07: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
Brandon Philips 40ced98c32 version: bump to v0.5.5 2015-05-01 19:16:44 -04:00
Alban Crequy f183907d9c build: systemd: add patches for systemd-master 2015-04-28 17:24:52 +02:00
Alban Crequy b0b22a6606 build: systemd v219: add new patches 2015-04-28 17:24:52 +02:00
Alban Crequy a5274f92b4 build: ability to choose a different systemd version
When building stage1 from sources with RKT_STAGE1_USR_FROM=src,
it is now possible to choose which systemd tag or branch should be
built:

  $ export RKT_STAGE1_USR_FROM=src
  $ export RKT_STAGE1_SYSTEMD_SRC=git://anongit.freedesktop.org/systemd/systemd
  $ export RKT_STAGE1_SYSTEMD_VER=v215
  $ ./build

By default, it still fetch the upstream git repository with tag v215 as
before. So defining the new variables is not necessary.

It is also possible to build against a local systemd repository:

  $ export RKT_STAGE1_USR_FROM=src
  $ export RKT_STAGE1_SYSTEMD_SRC=/home/user/git/systemd
  $ export RKT_STAGE1_SYSTEMD_VER=HEAD
  $ ./build

This should help developers to test newer systemd versions.

The patches in stage1/rootfs/usr_from_src/patches/ are versioned: the
subdirectory used is defined by $RKT_STAGE1_SYSTEMD_VER. If "HEAD" is
used, the master patchset will be selected.
2015-04-28 17:24:52 +02:00
Eugene Yakubovich 89558960a5 Merge pull request #827 from eyakubovich/cni-intg
CNI integration
2015-04-27 15:03:10 -07:00
Eugene Yakubovich 7abd8f3b84 net: switch to using CNI plugins 2015-04-27 14:43:25 -07:00
Vito Caputo f445d37892 rkt/enter: use pod.getPID() to get container's pid race-free
- Fixup pod.getPID() to cover race between xToRun() and stage1 getting
  around to writing the pid file.

- Rework `rkt enter` to retrieve the pid in rkt/stage0 and supply it to
  stage1 enter.

- Rework stage1 enter to consume pid from argv instead of opening it
  itself, so as to not have to duplicate the same race coverage.

- Some stage1 enter code cleanups thrown in for good measure, particularly
  around the argv forwarding copy which started simple had become unwieldy.
2015-04-24 17:29:30 -07:00
Vito Caputo aa4183a017 stage1/enter: use pexit_if() for errno-valid conditions
Also the capitalized error messages.
2015-04-24 13:46:49 -07:00
Alban Crequy d0d2396079 diagexec: non-root apps 2015-04-24 10:47:58 +02:00
Jonathan Boulle c8a7050a88 version: bump to v0.5.4 2015-04-23 10:39:30 -07:00
Eugene Yakubovich c59e150850 net: remove obsolete 169.254.169.255/32 route 2015-04-15 10:41:37 -07:00
Eugene Yakubovich 98e78d5f08 stage1: add stage1 gc entrypoint
Stage1 GC entrypoint is called as part of
"rkt gc", prior to recursively removing the
pod directory. This give the stage1 to do
any necessary cleanup.
2015-04-14 14:22:57 -07:00
Jonathan Boulle a8afce77b6 version: bump to v0.5.3 2015-03-31 20:38:54 -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
Jonathan Boulle 16bcfe9750 version: bump to v0.5.2 2015-03-30 23:10:05 -07:00
Jonathan Boulle d11d31d717 stage1: bump acVersion 2015-03-27 13:59:51 -07:00
Vito Caputo fdcd649471 stage1: add support for building stage1's usr from src
Currently only systemd is being built from source, toggled from the
top-level build script by setting RKT_STAGE1_USR_FROM=src, e.g:
RKT_STAGE1_USR_FROM=src ./build

The default stage1 continues to be coreos-derived, but may be explicitly
specified via:
RKT_STAGE1_USR_FROM=coreos ./build

The stage1 init program has been modified to introspect the "flavor" of
stage1 at runtime, which influences how it invokes systemd-nspawn.

A small series of patches are included to give systemd-nspawn the
functionalities enabled via LD_PRELOAD of the shim in the coreos-derived
stage1.

The systemd source is cloned at build time the first time an
RKT_STAGE1_USR_FROM=src build is performed, at this time the same version
as the coreos image provided is being used, but this can be bumped in the
future.
2015-03-23 19:08:20 -07:00
Vito Caputo 310d3ba4c2 stage1: rename rootfs/usr -> rootfs/usr_from_coreos 2015-03-23 18:56:06 -07:00
Vito Caputo 39f9230780 stage1: replace exit-watcher's sleep with small utility
Moving towards fewer external dependencies, aiming for only systemd being
external so it's the only complicated thing we need to do things like try
pulling from the host or building from source when not deriving stage1 from
a CoreOS image.
2015-03-23 18:56:06 -07:00
Iago López Galeiras 143fc96a37 stage1: prepare-app: unlink /dev/ptmx symlink when it exists 2015-03-23 17:00:21 +01:00
Iago López Galeiras ba2b1f52d9 stage1: prepare-app: prepare /dev/pts for apps
Interactive containers expect /dev/pts.

Also, make /dev/ptmx a symlink to /dev/pts/ptmx.
See https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
2015-03-23 12:58:57 +01:00
Iago López Galeiras 7e125c03ec stage1: prepare-app: refactor dir bind-mounts 2015-03-23 12:58:57 +01:00
Vito Caputo fe95c5daf2 stage1: create /tmp in prepare-app instead of stage0
Also clear umask in prepare-app so modes are used verbatim.
2015-03-19 13:31:08 -07:00
Alban Crequy 9ea9e365b6 stage1: prepare-app: fix volumes during the root bind-mount
The bind mount on / was introduced by
https://github.com/coreos/rocket/pull/626 to fix the "Docker inside
Rocket" use case in https://github.com/coreos/rocket/issues/638

But this introduced a regression on volume mounted via "rkt run
-volume". This patch fixes the regression.

Regression discovered by Iago when testing Flannel from
https://github.com/coreos/rocket/issues/389
2015-03-19 13:08:42 +01:00
Alban Crequy f70c4e8d07 stage1: prepare-app: unlink /dev/shm symlink when it exists 2015-03-17 12:03:45 +01:00
Alban Crequy cf0028c11f stage1: prepare-app: prepare /dev/shm for apps
Docker needs /dev/shm:
https://github.com/coreos/rocket/issues/506
2015-03-17 12:03:45 +01:00
Alban Crequy deb079a16e stage1: prepare-app: make stage2's root a mount point
It is needed to run Docker inside Rocket:
https://github.com/coreos/rocket/issues/506
2015-03-17 12:03:45 +01:00
Alban Crequy 5e6c303f9e stage1: prepare-app: prepare /sys for apps
https://github.com/coreos/rocket/issues/606
2015-03-17 12:03:45 +01:00