2707 Commits

Author SHA1 Message Date
9c359a31d5 create pod on the fly
when a user specifies --pod to podman create|run, we should create that pod
automatically.  the port bindings from the container are then inherited by
the infra container.  this signicantly improves the workflow of running
containers inside pods with podman.  the user is still encouraged to use
podman pod create to have more granular control of the pod create options.

Signed-off-by: baude <bbaude@redhat.com>
2018-12-03 15:49:17 -06:00
a4b483c848 libpod/container_internal: Deprecate implicit hook directories
Part of the motivation for 800eb863 (Hooks supports two directories,
process default and override, 2018-09-17, #1487) was [1]:

> We only use this for override. The reason this was caught is people
> are trying to get hooks to work with CoreOS. You are not allowed to
> write to /usr/share... on CoreOS, so they wanted podman to also look
> at /etc, where users and third parties can write.

But we'd also been disabling hooks completely for rootless users.  And
even for root users, the override logic was tricky when folks actually
had content in both directories.  For example, if you wanted to
disable a hook from the default directory, you'd have to add a no-op
hook to the override directory.

Also, the previous implementation failed to handle the case where
there hooks defined in the override directory but the default
directory did not exist:

  $ podman version
  Version:       0.11.2-dev
  Go Version:    go1.10.3
  Git Commit:    "6df7409cb5a41c710164c42ed35e33b28f3f7214"
  Built:         Sun Dec  2 21:30:06 2018
  OS/Arch:       linux/amd64
  $ ls -l /etc/containers/oci/hooks.d/test.json
  -rw-r--r--. 1 root root 184 Dec  2 16:27 /etc/containers/oci/hooks.d/test.json
  $ podman --log-level=debug run --rm docker.io/library/alpine echo 'successful container' 2>&1 | grep -i hook
  time="2018-12-02T21:31:19-08:00" level=debug msg="reading hooks from /usr/share/containers/oci/hooks.d"
  time="2018-12-02T21:31:19-08:00" level=warning msg="failed to load hooks: {}%!(EXTRA *os.PathError=open /usr/share/containers/oci/hooks.d: no such file or directory)"

With this commit:

  $ podman --log-level=debug run --rm docker.io/library/alpine echo 'successful container' 2>&1 | grep -i hook
  time="2018-12-02T21:33:07-08:00" level=debug msg="reading hooks from /usr/share/containers/oci/hooks.d"
  time="2018-12-02T21:33:07-08:00" level=debug msg="reading hooks from /etc/containers/oci/hooks.d"
  time="2018-12-02T21:33:07-08:00" level=debug msg="added hook /etc/containers/oci/hooks.d/test.json"
  time="2018-12-02T21:33:07-08:00" level=debug msg="hook test.json matched; adding to stages [prestart]"
  time="2018-12-02T21:33:07-08:00" level=warning msg="implicit hook directories are deprecated; set --hooks-dir="/etc/containers/oci/hooks.d" explicitly to continue to load hooks from this directory"
  time="2018-12-02T21:33:07-08:00" level=error msg="container create failed: container_linux.go:336: starting container process caused "process_linux.go:399: container init caused \"process_linux.go:382: running prestart hook 0 caused \\\"error running hook: exit status 1, stdout: , stderr: oh, noes!\\\\n\\\"\""

(I'd setup the hook to error out).  You can see that it's silenly
ignoring the ENOENT for /usr/share/containers/oci/hooks.d and
continuing on to load hooks from /etc/containers/oci/hooks.d.

When it loads the hook, it also logs a warning-level message
suggesting that callers explicitly configure their hook directories.
That will help consumers migrate, so we can drop the implicit hook
directories in some future release.  When folks *do* explicitly
configure hook directories (via the newly-public --hooks-dir and
hooks_dir options), we error out if they're missing:

  $ podman --hooks-dir /does/not/exist run --rm docker.io/library/alpine echo 'successful container'
  error setting up OCI Hooks: open /does/not/exist: no such file or directory

I've dropped the trailing "path" from the old, hidden --hooks-dir-path
and hooks_dir_path because I think "dir(ectory)" is already enough
context for "we expect a path argument".  I consider this name change
non-breaking because the old forms were undocumented.

Coming back to rootless users, I've enabled hooks now.  I expect they
were previously disabled because users had no way to avoid
/usr/share/containers/oci/hooks.d which might contain hooks that
required root permissions.  But now rootless users will have to
explicitly configure hook directories, and since their default config
is from ~/.config/containers/libpod.conf, it's a misconfiguration if
it contains hooks_dir entries which point at directories with hooks
that require root access.  We error out so they can fix their
libpod.conf.

[1]: https://github.com/containers/libpod/pull/1487#discussion_r218149355

Signed-off-by: W. Trevor King <wking@tremily.us>
2018-12-03 12:54:30 -08:00
795fbba769 Revert changes to GetDefaultStoreOptions
We don't need this for anything more than rootless work in Libpod
now, but Buildah still uses it as it was originally written, so
leave it intact as part of our API.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-03 15:48:20 -05:00
5f6ad82524 Merge pull request #1913 from baude/podexists
podman pod exists
2018-12-03 12:21:44 -08:00
7c575bdce2 Fix libpod static dir selection when graphroot changed
When graphroot is set by the user, we should set libpod's static
directory to a subdirectory of that by default, to duplicate
previous behavior.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-03 15:13:07 -05:00
318bf7017b podman pod exists
like containers and images, users would benefit from being able to check
if a pod exists in local storage.  if the pod exists, the return code is 0.
if the pod does not exists, the return code is 1.  Any other return code
indicates a real errors, such as permissions or runtime.

Signed-off-by: baude <bbaude@redhat.com>
2018-12-03 12:00:18 -06:00
03aafff4ef Merge pull request #1923 from giuseppe/rootless-no-newuidmap-installed
rootless: raise error if newuidmap/newgidmap are not installed
2018-12-03 09:25:36 -08:00
5c02dda869 Adding more varlink endpoints
* runlabel
* checkpoint
* restore
* container|image exists
* mount
* unmount

Signed-off-by: baude <bbaude@redhat.com>
2018-12-03 10:56:07 -06:00
677c444463 Ensure directory where we will make database exists
Ensure that the directory where we will create the Podman db
exists prior to creating the database - otherwise creating the DB
will fail.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-03 11:10:02 -05:00
ea13264958 Fix typo
Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-03 10:48:33 -05:00
727b6a78ee rootless: raise error if newuidmap/newgidmap are not installed
it was reported on IRC that Podman on Ubuntu failed as
newuidmap/newgidmap were not installed by default.

Raise an error if we are not allowing single mappings (used only by
the tests suite) and any of the binaries is not present.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-03 16:45:44 +01:00
32fc865b6d Add better descriptions for validation errors in DB
When validating fields against the DB, report more verbosely the
name of the field being validated if it fails. Specifically, add
the name used in config files, so people will actually know what
to change it errors happen.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-03 10:38:32 -05:00
5bb66a47a4 Merge pull request #1914 from baude/logslatest
Add short-option handling to logs
2018-12-03 06:27:02 -08:00
b104a45f35 Fix gofmt and lint
Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 16:53:15 -05:00
69ed2ccc54 Make locks dir in unit tests
Ensure we don't break the unit tests by creating a locks
directory (which, prior to the last commit, would be created by
BoltDB state init).

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 16:53:15 -05:00
03229239b0 Do not initialize locks dir in BoltDB
We already create the locks directory as part of the libpod
runtime's init - no need to do it again as part of BoltDB's init.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 15:32:06 -05:00
562fa57dc9 Move rootless storage config into libpod
Previous commits ensured that we would use database-configured
paths if not explicitly overridden.

However, our runtime generation did unconditionally override
storage config, which made this useless.

Move rootless storage configuration setup to libpod, and change
storage setup so we only override if a setting is explicitly
set, so we can still override what we want.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 15:21:35 -05:00
92ff83f5b9 Set default paths from DB if not explicitly overridden
If the DB contains default paths, and the user has not explicitly
overridden them, use the paths in the DB over our own defaults.

The DB validates these paths, so it would error and prevent
operation if they did not match. As such, instead of erroring, we
can use the DB's paths instead of our own.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 14:21:22 -05:00
aa7ce33b7a Add a struct indicating if some Runtime fields were set
To configure runtime fields from the database, we need to know
whether they were explicitly overwritten by the user (we don't
want to overwrite anything that was explicitly set). Store a
struct containing whether the variables we'll grab from the DB
were explicitly set by the user so we know what we can and can't
overwrite.

This determines whether libpod runtime and static dirs were set
via config file in a horribly hackish way (double TOML decode),
but I can't think of a better way, and it shouldn't be that
expensive as the libpod config is tiny.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 14:06:33 -05:00
137e0948ae Make DB config validation an explicit step
Previously, we implicitly validated runtime configuration against
what was stored in the database as part of database init. Make
this an explicit step, so we can call it after the database has
been initialized. This will allow us to retrieve paths from the
database and use them to overwrite our defaults if they differ.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 13:38:36 -05:00
b0f79ff4df Move DB configuration up in runtime setup
When we configure a runtime, we now will need to hit the DB early
on, so we can verify the paths we're going to use for c/storage are correct.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 13:38:36 -05:00
6e16702947 Add ability to retrieve runtime configuration from DB
When we create a Libpod database, we store a number of runtime
configuration fields in it. If we can retrieve those, we can use
them to configure the runtime to match the DB instead of inbuilt
defaults, helping to ensure that we don't error in cases where
our compiled-in defaults changed.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-02 13:38:36 -05:00
87df1ce01f Add short-option handling to logs
podman logs already supports the latest command line switch.  users should be able
to use the short-options combined (i.e. podman logs -lf).

Signed-off-by: baude <bbaude@redhat.com>
2018-12-01 19:09:40 -06:00
41f250c486 Merge pull request #1903 from giuseppe/fix-rootless-tests
tests: fix rootless tests on Ubuntu
2018-12-01 06:36:51 -08:00
deeb3eaf7d tests: always install runc on Ubuntu
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-01 06:46:24 +01:00
babb7c248b cirrus: update ubuntu image
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-30 22:45:56 +01:00
2842b8ad40 cirrus: make apt noninteractive
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-30 22:45:56 +01:00
2dfb7c02b1 Dockerfile, .cirrus.yml: update runc commit
we need to inherit this change from runc.

commit 869add33186caff4a22e3e11a7472a2d48d77889:

rootless: fix running with /proc/self/setgroups set to deny

    This is a regression from 06f789cf26774dd64cb2a9cc0b3c6a6ff832733b
    when the user namespace was configured without a privileged helper.
    To allow a single mapping in an user namespace, it is necessary to set
    /proc/self/setgroups to "deny".

    For a simple reproducer, the user namespace can be created with
    "unshare -r".

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-30 22:45:55 +01:00
1d2e1eece5 rootless: propagate XDG_RUNTIME_DIR to the OCI runtime
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-30 22:37:09 +01:00
d837dd3e2a Update ubuntu VM image w/ newer runc
Signed-off-by: Chris Evich <cevich@redhat.com>
2018-11-30 22:37:08 +01:00
6b8f89d074 Merge pull request #1896 from ypu/mount-create-test
Add create test with --mount flag
2018-11-30 11:37:00 -08:00
5b738ea7ff Merge pull request #1886 from edsantiago/pypod_run_args
pypod run: ignore args intended for container command
2018-11-30 11:09:56 -08:00
b504623a11 Merge pull request #1317 from rhatdan/privileged
Disable mount options when running --privileged
2018-11-30 11:09:51 -08:00
36364b18a9 Merge pull request #1777 from rhatdan/shm
/dev/shm should be mounted even in rootless mode.
2018-11-30 09:06:06 -08:00
96c4dd7302 Merge pull request #1906 from baude/addpsp
add pod short option to ps
2018-11-30 07:49:27 -08:00
82bcef3895 add pod short option to ps
podman ps has a flag --pod; simply adding a short option of -p

Signed-off-by: baude <bbaude@redhat.com>
2018-11-30 09:15:11 -06:00
e5518e268d Add create test with --mount flag
Signed-off-by: Yiqiao Pu <ypu@redhat.com>
2018-11-29 19:01:22 +08:00
57f7b79400 Only include container SizeRootFs when requested
* API always returns value, so we remove it if not asked for

Fixes #1876

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2018-11-28 15:44:46 -07:00
3af62f620a Merge pull request #1890 from baude/disablecheckpointtests
disable checkpoint tests on f29
2018-11-28 13:31:40 -08:00
4f8ea99603 Merge pull request #1714 from giuseppe/fix-rootless-tests
tests: fix rootless tests with an updated runc
2018-11-28 13:19:04 -08:00
39a8cc7558 Merge pull request #1852 from rhatdan/completions
Cleaning up completions.
2018-11-28 13:02:48 -08:00
a5be3ffa4d /dev/shm should be mounted even in rootless mode.
Currently we are mounting /dev/shm from disk, it should be from a tmpfs.
User Namespace supports tmpfs mounts for nonroot users, so this section of
code should work fine in bother root and rootless mode.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-11-28 15:48:25 -05:00
dd81a8fe7d disable checkpoint tests on f29
temporarily disabling checkpoint tests on f29 as they don't currently pass.

Signed-off-by: baude <bbaude@redhat.com>
2018-11-28 14:39:47 -06:00
6e04ec783b test, rootless: specify USER env variable
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-28 21:31:28 +01:00
87bf117417 Revert "downgrade runc due a rootless bug"
This reverts commit 803efd4d380f091c85cd45e0b3c35cf6333d47b7.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-28 21:31:27 +01:00
4bb2fdeebc Merge pull request #1888 from baude/hidekube
hide kube command for now
2018-11-28 11:08:34 -08:00
6e0f10f19b Fix completions to work with podman run command
Also add missing --help  and -h and add some consistency to the
usage of boolean_options.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-11-28 14:05:33 -05:00
8e30d685b7 hide kube command for now
until the kube commands are ironed out, we dont want it drawing
attention in any release

Signed-off-by: baude <bbaude@redhat.com>
2018-11-28 12:30:53 -06:00
3d0cdd898c pypod create/run: ignore args for container command
Don't try to argparse command-line arguments on the right-hand
side of the image; those are intended for the container command:

   pypodman create fedora ls -l
   pypodman run fedora find / -name foo
   pypodman run fedora bash -c 'echo hi'

If/when `pypodman exec` gets implemented, it should use this too.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2018-11-28 11:27:52 -07:00
d3bc70d5d0 Merge pull request #1851 from jwhonce/wip/cmd
Add support for --all in pypodman ps command
2018-11-28 09:27:11 -08:00