Commit Graph

50 Commits

Author SHA1 Message Date
Daniel J Walsh a10366adef Drop depracated warnings to debug
Currently podman ships with libpod.conf,  We need to remove the noice
for these warnings from buildah for the time being.  We can fix this
once podman is shipping without libpod.conf.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-10 10:35:33 -04:00
Daniel J Walsh 357a5402c6 NewConfig(): passed-in configuration file should matter most
In NewConfig(), settings in the file whose name we're passed should
matter more than the hardwired default files, or the file named in the
CONTAINERS_CONF environment variable.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-09 17:29:26 -04:00
Qi Wang eee0f4f7f8 remove CgroupsAndAdjust from NewConfig
Export CheckCgroupsAndAdjustConfig() as global function and remove it from NewConfig(). So we can handle it in libpod and avoid Buildah to display cgroup warning message when reading containers.conf.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-03-09 15:18:15 -04:00
Qi Wang 0c613a6abe Support and prefer libpod.conf if exists
During the transision period of replacing libpod.conf with containers.conf, pkg/config should also read the libpod.conf if it exist.
This patch reads the libpod.conf in NewConfig() and converts the configurations to ContainersConfig Struct.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-03-09 14:37:19 -04:00
Qi Wang bec93b6703 Add pull_policy to LibpodConfig
pull_policy is the same as podman run --pull option to determin whether to pull a new image when running a container.
Accepted "always", "missing", and "never". Default value is "missing".

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-03-03 11:13:38 -05:00
Daniel J Walsh 112e5a7b20 list of label specification for required capabilties
These labels allows users to specify the list of capabilities required
to run their container image.

Setting a image/container label "io.containers.capabilities=setuid,setgid"
will tell container engines that the contained image should work fine withi
just these two capabilties, instead of running with the default capabilities,

Defined as a list, since this has not been standardized yet, we want to make
this a standard, and the standard label might be different then the label we
choose, so eventually we might need to add a standard label.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-23 06:19:35 -05:00
Daniel J Walsh 00b0aae703 Add StopTimeout for podman
Allow users to modify the default ammount of time to wait to send SIGKILL
after you tell a container to stop with a SIGINT.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-21 11:32:16 -05:00
Daniel J Walsh 3d6b785749 CgroupManager should belong to libpod not containers
CgroupManager is defined for managing containers, it is not defined
per container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-20 10:27:47 -05:00
Daniel J Walsh 8bd736f5cc Merge pull request #69 from giuseppe/add-setfcap
config: add CAP_SETFCAP to the default capabilities
2020-02-20 09:39:18 -05:00
Giuseppe Scrivano b1841747ed config: add CAP_SETFCAP to the default capabilities
it is needed by Buildah to set file capabilities.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-02-20 09:49:01 +01:00
Daniel J Walsh ad4b16c9d2 Remove additional_ adjective from containers.conf
Additional is implied, so should not be stated.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-19 09:48:11 -05:00
Daniel J Walsh 862583d397 Merge pull request #63 from ArangoGutierrez/issue_62
Add annotations into containers.conf file
2020-02-18 14:30:43 -05:00
Valentin Rothberg 130c712a05 pkg/capabilities
Replace pkg/caps with pkg/capabilities (from libpod).  It's also a fork
from Docker but attributes its origing with copyright notes and has a
trimmed down (and faster) API.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-18 15:58:19 +01:00
Carlos Eduardo Arango Gutierrez a93c9e5022 fix typo on var declaration
Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2020-02-18 07:19:27 -05:00
Carlos Eduardo Arango Gutierrez 3e885a69c4 Add annotations into containers.conf file
Closes #62

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2020-02-17 19:42:11 -05:00
Carlos Eduardo Arango Gutierrez 0d15312d27 Fix lint on default.go
Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2020-02-17 18:18:14 -05:00
Carlos Eduardo Arango Gutierrez be1f3f6caa fix gofmt on file config_test.go
apply `gofmt -s -w config_test.go`

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2020-02-17 18:13:03 -05:00
Carlos Eduardo Arango Gutierrez 6309277061 Fix misspell on config.go
Line 255:"guarantess" is a misspelling of "guarantees" (misspell)
Line 292:"guarantess" is a misspelling of "guarantees" (misspell)
rm some double spaces

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2020-02-17 18:10:26 -05:00
Daniel J Walsh a0f632a9d3 Use slirp4netns for default network when in rootless mode
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-12 21:11:56 -05:00
Daniel J Walsh 4fa425fe38 Add Default function to read containers config
This function should be called to return a default config to be used
by callers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-10 08:21:07 -05:00
Daniel J Walsh aaaac87784 Don't up the default number of open files, just processes.
Python call to Popen attempt to close all open file descriptors by looking at
the maximum number of open file descripors defined in ulimits.  If we set
this to a huge number by default Popen will run much slower since it will
attempt to close the total number of FDs one by one.

We should just use the default that the calling process had unless the user
overrides the default in containers.conf.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-05 10:46:28 -05:00
Daniel J Walsh 46d6f01773 Merge pull request #52 from rhatdan/version
Setup default ulimits to nproc & nofile of current process
2020-02-04 07:02:06 -05:00
Sascha Grunert 38c952b22d Fix 32bit build by using unix.CGROUP2_SUPER_MAGIC
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-02-04 11:30:40 +01:00
Daniel J Walsh 8241546743 Setup default ulimits to nproc & nofile of current process
In root running containers we want to approach the MAX  Number of processes and
open files, so that services running Podman will work when they have lots of open
files or processes.  In rootless containers this number can not be changed.  This
patch will only increase the numbers if the process is allowed.

Docker set the limit to 2**20 (1048576), it looks like this was the max for RHEL5 OS.
So we fall back to attempt to set this limit if the MAC_PROC limit is not allowed.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-03 13:50:28 -05:00
Daniel J Walsh 95fb926363 Stop validating networkconfig by default
This is causing issues in rootless and remote mode.  We should not be creating
directories on the fly.
Also stop exporting functions that are not used by Buildah and Podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-29 06:10:15 -05:00
Daniel J Walsh aa32712804 Fix a couple of defaults
The default alternative path for seccomp.json should be /etc/containers/seccomp.json

The DefaultNetwork in network config should be bridge

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-27 04:05:25 +01:00
Daniel J Walsh f6044d41ef Merge pull request #46 from giuseppe/unshare-cgo
unshare: add getenv from cgo
2020-01-20 22:40:12 -05:00
Giuseppe Scrivano 758b4e2730 unshare: add getenv from cgo
if CGO is enabled, make sure to use C.getenv instead of os.Getenv to
read environment variables.  It is required since rootless libpod
joins the user namespace through Cgo.

The variables set via C.setenv are not visible through os.Getenv, as
the latter uses sync.Once to read the variables once.

Requires: https://github.com/containers/libpod/pull/4911

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-20 15:53:55 +01:00
Daniel J Walsh b3d6ec550e Fix definitions for cross compilers
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-16 16:58:38 -05:00
Giuseppe Scrivano 990e0fc7c3 pkg/cgroups: delete it
at the moment the cgroups package is used only by Podman and by CRI-O
(that is already vendoring libpod).  So let's simplify and not have a
duplicate here.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-09 08:45:00 +01:00
Daniel J Walsh 789d9a515f Run code through codespell
Fix spelling mistakes found using codespell.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-08 08:56:50 -05:00
Daniel J Walsh 3e1c3932bf Add new Capability function to parse Capabiltiies
The Capability check handles merging of Default capabiltiies along
with user specified add and drop capabilities.

Fork docker/docker/oci/caps file to prevent a huge vendor

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-07 17:57:04 -05:00
Daniel J Walsh 5760a49664 HooksDir should be in LibpodConfig
This field is owned by libpod and is not part of containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-07 17:53:02 -05:00
Daniel J Walsh 2603f5de14 Fix handling of SELinux labeling
Also re-add DefaultMountsFile since we need a holding place to be
used in libpod.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-04 05:45:17 -05:00
Daniel J Walsh 74d7f91c66 Update/Fix man page and fix several bugs in definition.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-03 13:57:01 -05:00
Daniel J Walsh b406a112e1 Add new fields to containers.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-28 07:22:07 -05:00
Daniel J Walsh c4d2aafd65 Add missing fields to be used with podman
We also want to be able to default namespaces to host, so that HPC
machines can default to not using most of the namespaces by default.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-28 07:19:15 -05:00
Daniel J Walsh 60644e7a72 Comment out all fields in containers.conf by default
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-11 08:26:52 -05:00
Daniel J Walsh 67213c41a3 Remove merge code and optional handling
Fix handling of toml files

No longer need merge, since we can specify a default conf for each toml file.
The toml code will retain the previous defaults and only use the newly specified
values.

This greatly simplifies the code.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-11 08:26:52 -05:00
Daniel J Walsh 547b101e3e Change optional bools to be private options
We want to hide Optional Bools from the default configuration.  Callers should only have to deal with boolean
fields and not deal with optionals.

Add accessor functions for all optional bools, easier.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-09 12:01:43 -05:00
Daniel J Walsh dfb351a9da Add support for CONTAINERS_CONF environment variable
This is needed to help in CI/CD systems to use an alternative containers.conf file for testing.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-07 06:20:27 -05:00
Qi Wang 894913abdf add libpod.conf to containers.conf
Add configurations from libpod.conf to containers.conf.Use merge code from libpod to read and merge configurations from file.

Add unshare_linux for build linux: HomeDir should buildah not only for linux. so add unshare_linux for linux and unshare.go for other

convert bool to optinalbool:Use OptionalBool for on-disk configurations so we can distinguish field is undefined  vs. user set to false.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-12-06 15:55:47 -05:00
Qi Wang aab667743b move cgroups pkg from libpod
move cgroups package from libpod so can be shared by Buildah and Podman.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-12-05 12:09:11 -05:00
Valentin Rothberg 66d9591d6f unshare.HomeDir: get home dir of current user
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-11-22 11:18:27 +01:00
Qi Wang 023822b7b0 turn off the check of the hook directory
Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-11-09 13:05:58 -05:00
Qi Wang 64705d1f72 Fix tests failure #11
tests failures should be fixed since #11 add hooksdir to default config.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-11-04 10:28:56 -05:00
Qi Wang 760d4a30a0 change default value of pidslimit and hooksdir
Change default value of pidslimit and hooksdir.
Add hooksdir to default config.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-11-01 10:46:12 -04:00
Qi Wang 542afa60a4 add selinux unsupported
Add unsupported file for non linux.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-10-22 13:51:22 -04:00
Qi Wang 676d4298d3 move pkg/unshare from buildah
move the buildah/pkg/unshare into containers/common

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-10-10 22:35:31 -04:00
Qi Wang 9bb8e7e62b Add config package for containers.conf
This PR adds a package config for reading configurations from the containers.conf into the go struct.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-10-07 13:38:17 -04:00