121 Commits

Author SHA1 Message Date
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
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
Yifan Gu ec28872afe rkt: add --pod-manifest to support user specified pod manifest. 2015-04-21 14:04:33 -07:00
Jonathan Boulle 906702e1e6 Merge pull request #774 from endocode/iaguis/fix-gc
rkt: fix gc when using overlay
2015-04-17 11:53:37 -07:00
Iago López Galeiras 863c231a46 rkt: fix gc when using overlay
When using overlay, the stage1 filesystem is mounted in a separate mount
namespace, rkt can't access the gc binary.

We now get the gc binary from the tree cache, using the stagee1 image
the user specified when preparing/running the container.
2015-04-16 20:23:40 +02:00
Iago López Galeiras 83a4d69db9 rkt: use entrypoint annotation to resolve enter
d12615f hard-coded the enter binary to accomodate overlayfs, this goes
back to using the entrypoint annotation.
2015-04-16 20:22:14 +02:00
Vito Caputo 9bca87021e rkt: propagate and skip gc on stage0 gc entrypoint error 2015-04-15 13:09:00 -07:00
Eugene Yakubovich bf33546a2d net: stage1 gc will clean up networking 2015-04-14 17:03:03 -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 9fb485a9ec Merge pull request #364 from endocode/krnowak/config-and-auth
fetch: add config and authentication for remotes
2015-04-08 14:12:56 -07:00
Eugene Yakubovich f4c3acd7e5 Merge pull request #737 from eyakubovich/remove-spawn-metadatasvc
rkt: remove --spawn-metadata-svc option from run cmd
2015-04-08 13:01:53 -07:00
Eugene Yakubovich d86dc77ce8 Merge pull request #731 from eyakubovich/extra-log-lines
stage1: discard logger output if no --debug is present
2015-04-08 10:18:01 -07:00
Eugene Yakubovich 025c967762 rkt: remove --spawn-metadata-svc option from run cmd
Also remove --no-idle from metadata-service since it
is no longer required. It was really only useful with
--spawn-metadata-svc but also racy.

Fixes #724
2015-04-08 09:54:53 -07:00
Krzesimir Nowak 095bddcc93 docs, stage0: Replace [Rr]ocket with rkt 2015-04-08 10:12:33 +02:00
Jesse Dubay 99218f8676 cas: rename to store
The cas package implements more than just a CAS, so this patch gives it
a suitably generic name.

Fixes #707
2015-04-07 18:05:03 -07:00
Eugene Yakubovich e01d4f2e02 stage1: discard logger output if no --debug is present
Also cleans up log.SetOutput handling in stage0 to only
do it once in main based on --debug.

Fixes #709
2015-04-06 13:09:25 -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
Vito Caputo fa961be38f rkt/stage0: pass *apps.Apps from rkt to stage0.Prepare()
Next move all the env/mounts/volumes into apps.Apps and add the
positional flag setters for the cli.
2015-04-02 13:11:24 -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
Iago López Galeiras d929b96516 rkt: add --no-overlay option
Adds an option to not disable overlay filesystem.
2015-03-30 13:16:37 +02:00
Iago López Galeiras 3fd836874a rkt: fix enter when running without overlay fs
When not using overlay fs, the tree cache was not getting populated.
Since we now take the enter binary from the tree cache, this was
breaking rkt enter.

We now populate stage1's tree cache in every case. We don't do it for
the app images because it can add a significant amount of time in the
first run if the image is big and it's not needed unless you use overlay
fs.
2015-03-27 11:22:35 +01:00
Eugene Yakubovich 4fcbe4f074 Merge pull request #637 from eyakubovich/metadata-unixsock
mdsvc: use Unix socket for registration
2015-03-26 12:00:10 -07:00
Eugene Yakubovich f030f05f02 mdsvc: use Unix socket for registration
Using allows Unix socket allows for limiting who can
register/unregister containers by setting proper
permissions on the socket.

Fixes #437
2015-03-26 11:39:19 -07:00
Iago López Galeiras 43d860e9f9 stage0: fix overlay dir permissions 0700 -> 0755
Having the permissions of overlay, upper and work dirs set to 0700 makes
"/" in the container have 0700 permissions, which breaks images that try
to execute files as different users.
2015-03-26 16:05:47 +01:00
Eugene Yakubovich d06e5eb6f6 Merge pull request #673 from eyakubovich/appc-vendor
spec: bump to 0.5.0+git; UUID removed from pod
2015-03-25 17:30:12 -07:00
Eugene Yakubovich 554ab1a270 re-vendor appc/spec; fixup pod related changes
* UUID is no longer part of manifest
* Metadata URLs changed
2015-03-25 16:47:55 -07:00
Iago López Galeiras 3fe5e18ad2 rkt: fix status with overlay
When using overlay fs rkt status stopped working because it searched for
the status file in the stage1 rootfs, which is either in a different
mount namespace or unmounted.

If the container uses overlay fs, we now search in its upper layer,
which is accessible outside the mount namespace or when the filesystem
is not mounted.
2015-03-25 18:57:55 +01:00
Jonathan Boulle 56530ef74e *: update to 0.5.0 spec 2015-03-24 18:49:50 -07:00
Jonathan Boulle aba92a8e2d stage0: change default perms to 0755 2015-03-24 14:53:00 -07:00
Iago López Galeiras d12615f462 rkt: fix enter
When using overlay, the stage1 filesystem is mounted in a separate mount
namespace, rkt can't access the enter binary.

We now get the enter binary from the tree cache, using the stage1 image
the user specified when preparing/running the container.
2015-03-24 10:12:13 +01:00
Iago López Galeiras a128256bb9 rkt: support overlay filesystem
This mounts stage1 and the application images as an overlay filesystem
using each ACI's cached tree as the lower filesystem.

Also, the mounts are done in a separate mount namespace so they will be
unmounted when the container exits and they're not visible by the rest
of the system.

Systems that don't support overlay fall back to plain copying.
2015-03-24 10:12:13 +01:00
Eugene Yakubovich 41c6ed0d01 Merge pull request #628 from eyakubovich/close-on-exec
net: set FD_CLOEXEC on RktLock prior to fork/exec
2015-03-19 17:50:38 -07: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
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
Jonathan Boulle 9e4b4194f9 stage0: simplify image rendering invocation 2015-03-16 10:22:21 -07:00
Simone Gotti 356dd8188f stage0: Use ACI Renderer library. 2015-03-16 10:01:09 +01:00
Iago López Galeiras 19b1d2414d stage1: support interactive containers
By using systemd's Standard{Input,Output,Error} options we set
/dev/console in stage1 as the tty for the app (see systemd.exec(5)).
This makes interactive executables like bash work with rkt run (or
prepare+run-prepared).

This is only supported if the container has only one app.
2015-03-12 20:22:01 +01:00
Vito Caputo ea62a77080 rkt: add --set-env to rkt run and rkt prepare
Also renamed --inherit-environment to --inherit-env, the former is too
verbose for consistent use with --set-env considering --set-env is to be
used repeatedly for multiple variables, abbreviate both uniformly.

This incarnation of --set-env applies set variables globally to all apps,
it seems desirable to be able to specify target apps for the variables.
Limiting inheritance to specific apps may also be useful.
2015-03-11 12:34:49 -07:00
Jonathan Boulle 63bb0846c3 rkt: metadatasvc -> metadata-service 2015-03-11 11:37:29 -07:00
Simone Gotti 3642118762 cas: satisfy acirenderer.ACIProvider interface. 2015-03-10 10:54:55 +01:00
Vito Caputo 8e7f0e08eb rkt: implement --inherit-environment in rkt run and rkt prepare
When enabled the caller's environment is used to set variables not set by
the app images.

Fixes #565
2015-03-08 04:32:25 -04:00
Vito Caputo 9ce3c4d37a rkt: support passing arguments to apps on the cli
`rkt run` and `rkt prepare` can now receive arguments on the commandline
which get appended to the default exec arguments of the preceding app
image.

Examples:

 Append --foo=bar to the second aci in a two aci invocation:
  `rkt run bar.aci foo.aci -- --foo=bar`

 Append options to both acis:
  `rkt run bar.aci -- --foobar --- foo.aci -- --woot`
  or if preparing:
  `rkt prepare bar.aci -- --foobar --- foo.aci -- --woot`

Also lays groundwork for general support of CRM overrides, though only argument
appending has been plumbed to the rkt commandline.

Fixes #564

Conflicts:
	stage0/run.go
2015-03-08 04:32:17 -04:00
Brandon Philips b6f95744a8 rkt: updates based on appc spec changes
- Use the new object based isolators
- Update to the RuntimeImage schema change
2015-03-08 04:14:02 -04:00
Vito Caputo 598665ac66 rkt: introduce rkt prepare and rkt run-prepared
`rkt prepare` does the "prepare" portion of `rkt run`, outputting a uuid:
$ rkt prepare imgs/pauser.aci
23def438-d2ad-401e-8b52-6ebc49813180
$

The prepared container is displayed in `rkt list`:
$ rkt list
UUID                                    ACI     STATE
23def438-d2ad-401e-8b52-6ebc49813180    pauser  prepared
$

Instantly run the prepared container passing the uuid to `rkt run-prepared`:
$ rkt --debug run-prepared 23def
2015/03/06 19:54:23 Pivoting to filesystem /var/lib/rkt/containers/run/23def438-d2ad-401e-8b52-6ebc49813180
2015/03/06 19:54:23 Execing /init
Spawning container rootfs on /var/lib/rkt/containers/run/23def438-d2ad-401e-8b52-6ebc49813180/stage1/rootfs.
Press ^] three times within 1s to kill container.
...

Once run via `rkt run-prepared`, the behavior of a prepared container is
identical to that of the usual `rkt run` container.

--volume flags you would normally supply to `rkt run` to influence the
behavior of the container are instead supplied to `rkt prepare`, since
these are applied in the prepare phase.  --spawn-metadata and
--private-net continue to be specified at run(-prepared) time.

The flags split may change, this is just the natural fit at the moment.

Fixes #550
2015-03-07 17:40:17 -08:00
Vito Caputo e124eec699 *: refactor container lifecycle to be more granular/comprehensive
Introduces new states for a container directory, now:

 embryo:		containers/embryo/$uuid
 prepare:		containers/prepare/$uuid & x-locked
 prepare-failed:	containers/prepare/$uuid & unlocked
 prepared:		containers/prepared/$uuid
 running:		containers/run/$uuid & x-locked
 exited:		containers/run/$uuid
 exited-garbage:	containers/exited-garbage/$uuid & unlocked
 exited-deleting:	containers/exited-garbage/$uuid & x-locked
 garbage:		containers/garbage/$uuid & unlocked
 deleting:		containers/garbage/$uuid & x-locked

 Some of these states overlap, exited-garbage and exited-deleting for
 example both imply exited.

 For a simple `rkt run` invocation, the container never enters the prepared
 state, instead it directly transitions from preparing to running.

 For the split `rkt prepare` and `rkt run-prepared` invocation the
 container enters the prepared state between the two.

 When a container is first created, it starts in the embryo/ directory.

 This allows us to acquire the x-lock before renaming it into prepare/, so
 it's _always_ x-locked when in the preparing state in the prepare/
 directory, making it safe to treat any unlocked directory within prepare/
 as failed/aborted (for gc purposes).  embryo/ is effectively a stage where
 the directory is created in isolation, locked, then brought into the world
 via rename into prepare/.

 The prepared/ directory is where perfectly good container directories,
 successfully prepared, await for their run-prepared.  When eventually run,
 we acquire the exclusive lock here where the lock has no significance,
 before renaming into run/ where everything must be locked or it's eligible
 for gc (exited).

 What used to be garbage/ is now exited-garbage/.  garbage/ is now the
 garbage directory without the exited implication for gc of prepare-failed
 and abandoned prepared containers.  They're both serviced by `rkt gc`.

UUID and container directory generation has been moved out of stage0/run.go
and into rkt/containers.go, including the lock acquisition for `rkt run`.

This has mostly been done to facilitate the split prepare and run-prepared
feature, fixing holes in the container creation lock coverage (embryo
required) while at it.

See Documentation/container-lifecycle.md for more complete details.
2015-03-07 17:40:17 -08:00
Vito Caputo 797baa098c *: rename stage1 entrypoint annotation from init->run
Currently the annotation "coreos.com/rocket/stage1/init" represents the stage1
entrypoint used by `rkt run`.  Renaming to "coreos.com/rocket/stage1/run" is
more consistent and self-documenting, aligning with the `rkt enter` entrypoint
annotation "coreos.com/rocket/stage1/enter".
2015-02-09 13:45:31 -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 389bd29b72 metadatasvc: process --spawn-metadata-svc in stage0
--spawn-metadata-svc is just a helper to launch another
program. It's not stage1 specific and stage0 feels like
a better place for it.
2015-02-04 17:29:36 -08:00
Vito Caputo bae52e60ae *: switch stage1 to aci image format
One may now specify an alternative stage1 in a style like run and fetch:
rkt run --stage1-image foo.com/rocket/stage1 app

--stage1-image defaults to "stage1.aci" within the same directory as the rkt
binary.  This is discovered at runtime via "/proc/self/exe"; as long as the rkt
executable and stage1.aci share a directory it should "just work" regardless of
the directory's location and where rkt is executed from.
2015-01-30 10:51:15 -08:00