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.
This commit adds memory and cpu isolators to test we don't break
anything. The next step is adding a functional test that actually checks
the isolators are respected.
Since commit 76ed159 ("functional tests: TestFailure: don't rely on
systemd debug logs"), TestExitCode didn't test anything and always
passed.
Fortunately, there was no regression bugs introduced in rkt. So no harm
done. But let's fix the test to catch potential future regression bugs.
Don't rely on systemd debug logs: this can change from one version to
another and this can be redirected to the journal.
Instead, use commands like "rkt list" and "rkt status" to find the
status of the pod. Moreover, this tests more rkt commands too.
this introduces tar extraction inside a chroot. This is done spawning a
new process. Instead of creating a new executable (difficult to find,
package etc...) it adds the concept of a multicall process (like busybox).
Now a new multicall command "extracttar" is added.
tar.ExtractTar executes this new command passing a pipe to send the
filesMap and the tar contents to stdin.
The incomplete "insecure link" checks are removed from the the tar
functions. Additionally these functions are now not exported and the
extraction directory is always the root directory.
By now only the treestore isn't removed if an image is referenced by
some pod.
This brings the need of a store gc to remove the rendered images in
the treestore when they aren't referenced anymore. This is difficult to
coordinate and is an extra work that can be avoided simply not removing
also the image from the store (store.RemoveACI) if the image is
referenced. IMHO it's also more consistent as the image doesn't
disappear from the `rkt images` output.
Since systemd commit f2341e ("core,network: major per-object logging rework"),
systemd does not log "main process exited" but "Main process exited" (notice
the uppercase).
Improve the test to accept both strings.
Avoid child.Close(), prefer child.Wait()
Depending on the kernel version, it's not allowed to delete a directory
if it is a mount point, even in another mount namespace.
Create just one context for the test and reset it after each
iteration, so unused directories are removed immediately instead of
during deferred cleanup.
This context manages rkt's data directory, local and system
configuration directories. They are by default placed somewhere in
/tmp dir. The context also provides basic rkt command to call, so rkt
uses those directories instead of default ones.
With this context tests do not have to be destructive - they can be
self-contained.
The functional tests use sudo because the tests need to be run as root.
Sudo does not preserve $PATH. When the user use a home-built go, it
might have a different version thatn the system-wide installed go. It
causes problems when linking the tests with github.com/coreos/rkt/common
This patch fixes the issue by using the go environment of the user.