2393 Commits

Author SHA1 Message Date
3e60de629d Merge pull request #1912 from baude/prune
Add ability to prune containers and images
2018-12-06 08:31:20 -08:00
99bbbeb746 Merge pull request #1887 from mheon/rm_sync
Add --sync option to podman rm
2018-12-06 08:11:51 -08:00
5a07644646 Merge pull request #1944 from giuseppe/update-tutorial
tutorial: add ostree dependency
2018-12-06 07:20:40 -08:00
e04871b13c Merge pull request #1946 from rhatdan/vendor
Vendor in latest containers/storage
2018-12-06 07:01:42 -08:00
e5335fd74c Remove --sync flag from podman rm
Per discussion with Dan, it would be better to automatically
handle potential runtime errors by automatically syncing if they
occur. Retaining the flag for `ps` makes sense, as we won't even
be calling the OCI runtime and as such won't see errors if the
state desyncs, but rm can be handled automatically.

The automatic desync handling code will take some additional work
so we'll land this as-is (sync on ps is enough to solve most
desync issues).

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-06 09:10:45 -05:00
b945d9128a Add locking to Sync() on containers
Previously not needed as it only worked inside of Batch(), but
now that it can be called anywhere we need to add mutual
exclusion on its config changes.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-06 09:10:45 -05:00
28bead8be8 Add --sync flag to podman ps
The previous commit added support for --sync to podman rm to
ensure state inconsistencies would not prevent containers from
being removed.

Add the flag to podman ps as well, so that all containers can be
forcibly synced and all state inconsistencies resolved.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-06 09:10:45 -05:00
a0c9be2061 Add --sync option to podman rm
With the changes made recently to ensure Podman does not hit the
OCI runtime as often to sync state, we can find ourselves in a
situation where the runtime's state does not match ours.

Add a --sync flag to podman rm to ensure we can still remove
containers when this happens.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-06 09:10:45 -05:00
0a838fc239 tutorial: add ostree dependency
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-06 11:13:56 +01:00
fe7f3e4094 Merge branch 'vendor' of github.com:rhatdan/libpod into vendor 2018-12-06 03:20:31 -05:00
40678b119c Merge branch 'master' of github.com:containers/libpod into vendor 2018-12-06 03:20:16 -05:00
e037427035 Add ability to prune containers and images
Allow user to prune unused/unnamed images, the layer images from building,
via podman rmi --prune.

Allow user to prune stopped/exiuted containers via podman rm --prune.

This should resolve #1910

Signed-off-by: baude <bbaude@redhat.com>
2018-12-05 19:57:54 -06:00
75b19ca8ab Merge pull request #1945 from jwhonce/bug/1929
Invert tlsverify default in API
2018-12-05 17:20:17 -08:00
6bb56a1c97 Merge pull request #1924 from baude/mroevarlinkendpoints
Adding more varlink endpoints
2018-12-05 14:55:27 -08:00
7c7231ce01 Invert tlsverify default in API
Fixes #1929

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2018-12-05 15:42:33 -07:00
bbcbf03f73 Merge pull request #1947 from baude/f28runc
set .54 version for f28 due to memory error
2018-12-05 14:36:38 -08:00
ab4a3ece40 set .54 version for f28 due to memory error
Signed-off-by: baude <bbaude@redhat.com>
2018-12-05 15:18:29 -06:00
5f480f5f75 Vendor in latest containers/storage
This should improve performance on vfs images on top of xfs/reflink drives.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-05 15:56:04 -05:00
be74acee1c Merge pull request #1940 from wking/numeric-gid
libpod/container_internal_linux: Allow gids that aren't in the group file
2018-12-05 08:09:58 -08:00
50e754cd57 Merge pull request #1918 from mheon/use_db_paths
Use paths written in DB instead if they differ from our defaults
2018-12-05 00:55:48 -08:00
39df2093e8 pkg/lookup: Return ID-only pointers on ErrNo*Entries
Callers that only care about the IDs should try to convert the
identifier to an integer before calling the Get* functions, so they
can save the cost of hitting the filesystem and maybe or maybe not
finding the other fields (User.Name, etc.).  But callers that *want*
the other fields but only actually need the ID can, with this commit,
just call the Get* function and ignore ErrNo*Entries responses:

  user, err := lookup.GetUser(mount, userIDorName)
  if err != nil && err != ErrNoPasswdEntries {
    return err
  }

Previously, they'd have to perform their own integer-conversion
attempt in Get* error handling, with logic like:

  user, err := lookup.GetUser(mount, userIDorName)
  if err == ErrNoPasswdEntries {
    uuid, err := strconv.ParseUint(userIDorName, 10, 32)
    if err == nil {
      user.Uid = int(uuid)
    }
  } else if err != nil {
    return err
  }

Signed-off-by: W. Trevor King <wking@tremily.us>
2018-12-04 14:46:43 -08:00
320085a04d Merge pull request #1942 from baude/rmi_test
test for rmi with children
2018-12-04 13:13:57 -08:00
aba52cf588 Merge pull request #1939 from mheon/no_firewall_if_rootless
Don't initialize CNI when running as rootless
2018-12-04 12:55:40 -08:00
0cd83466db test for rmi with children
Signed-off-by: baude <bbaude@redhat.com>
2018-12-04 14:22:11 -06:00
b81f640bb5 Merge pull request #1920 from wking/explicit-hooks-dirs
libpod/container_internal: Deprecate implicit hook directories
2018-12-04 12:19:48 -08:00
a01a590ae8 Merge pull request #1933 from giuseppe/update-runc-again
test: update runc again
2018-12-04 12:08:20 -08:00
f1770ea0ef Merge pull request #1932 from giuseppe/vendor-storage
vendor: update containers/storage
2018-12-04 12:08:11 -08:00
650f95cb06 libpod/container_internal_linux: Allow gids that aren't in the group file
When an image config sets config.User [1] to a numeric group (like
1000:1000), but those values do not exist in the container's
/etc/group, libpod is currently breaking:

  $ podman run --rm registry.svc.ci.openshift.org/ci-op-zvml7cd6/pipeline:installer --help
  error creating temporary passwd file for container 228f6e9943d6f18b93c19644e9b619ec4d459a3e0eb31680e064eeedf6473678: unable to get gid 1000 from group file: no matching entries in group file

However, the OCI spec requires converters to copy numeric uid and gid
to the runtime config verbatim [2].

With this commit, I'm frontloading the "is groupspec an integer?"
check and only bothering with lookup.GetGroup when it was not.

I've also removed a few .Mounted checks, which are originally from
00d38cb3 (podman create/run need to load information from the image,
2017-12-18, #110).  We don't need a mounted container filesystem to
translate integers.  And when the lookup code needs to fall back to
the mounted root to translate names, it can handle erroring out
internally (and looking it over, it seems to do that already).

[1]: https://github.com/opencontainers/image-spec/blame/v1.0.1/config.md#L118-L123
[2]: https://github.com/opencontainers/image-spec/blame/v1.0.1/conversion.md#L70

Signed-off-by: W. Trevor King <wking@tremily.us>
2018-12-04 12:00:42 -08:00
32aa45e344 Don't initialize CNI when running as rootless
We don't use CNI to configure networks for rootless containers,
so no need to set it up. It may also cause issues with inotify,
so disabling it resolves some potential problems.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-04 14:57:06 -05:00
f31c1c8c09 Merge pull request #1938 from baude/rmichildren
correct algorithm for deleting all images
2018-12-04 11:50:15 -08:00
41a7bd9c9e correct algorithm for deleting all images
when deleting all images, we need to iterate all the images deleting on those who dont
have children first. And then reiterate until they are all gone.

This resolves #1926

Signed-off-by: baude <bbaude@redhat.com>
2018-12-04 13:13:54 -06:00
e3882cfa2d Use runtime lockDir in BoltDB state
Instead of storing the runtime's file lock dir in the BoltDB
state, refer to the runtime inside the Bolt state instead, and
use the path stored in the runtime.

This is necessary since we moved DB initialization very far up in
runtime init, before the locks dir is properly initialized (and
it must happen before the locks dir can be created, as we use the
DB to retrieve the proper path for the locks dir now).

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-04 13:58:51 -05:00
480a179f01 Merge pull request #1894 from jwhonce/bug/1876
Only include container SizeRootFs when requested
2018-12-04 08:16:15 -08:00
6c060b1ca4 Merge pull request #1907 from baude/createpodautomatically
create pod on the fly
2018-12-04 07:49:06 -08:00
a90f2218dc test: update runc again
the regression we noticed in runc was fixed upstream:

https://github.com/opencontainers/runc/pull/1943

so we can use again runc from master.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-04 16:29:11 +01:00
e378f7ae24 vendor: update containers/storage
inherit a change for rootless containers to ignore devices nodes
inside of images.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-04 16:29:01 +01:00
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