Commit Graph

52 Commits

Author SHA1 Message Date
Chetan Giradkar 41f0492c7f Add configurability to Netavark firewall driver
closes #1338

Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
2023-11-28 12:51:21 +00:00
Valentin Rothberg cd2797eb34 pkg/config: use NewSlice, Get and Set where possible
To improve the code and reduce memory allocations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 10:04:20 +02:00
Valentin Rothberg f4afa37c23 pkg/config: turn PastaOptions into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 67a73c7cc6 pkg/config: turn CNIPluginDirs into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 89b8572671 pkg/config: turn AddCompression into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg ddf52636dd pkg/config: turn engine Env into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg 499d0a683e pkg/config: turn ComposeProviders into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg a86cc6fc42 pkg/config: turn Ulimites into attributedstring.Slice
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg b8c3014c2a pkg/config: turn devices into attributedstring.Slice
The tests are messy and should be turned into table-driven tests but I
do not have time at the moment.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 09:17:22 +02:00
Valentin Rothberg b103cb9e93 containers.conf: appendable string arrays, Part 1
Commit 395ba05c44 implemented a POC to allow for changing the behavior
when loading multiple container.conf files in sequence.  By default, the
TOML encoder will override existing data/fields with the one specified
in the loaded file.  The POC has demonstrated how this behavior can be
changed to append string slices instead of overriding/replacing them
entirely.

This change is the first step of integrating these appendable string
arrays into containers.conf and starts with enabling the `Env`,
`Mounts`, and `Volumes` fields in the `[Containers]` table.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-24 11:47:46 +02:00
Ashley Cui 14bd78db61 Default machine CPUs to Cores/2
1 CPU core typically is not enough for most use cases, so we default to available cores/2 for new machines.

Signed-off-by: Ashley Cui <acui@redhat.com>
2023-09-20 15:10:16 -04:00
Valentin Rothberg d0c26c9cf3 linters: enable missspell
No rockt science but good hygiene.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:29:49 +02:00
Aditya R 359ff162d0 containers.conf: add field for AddCompression to Engine table
Allows users to set default value of `AddCompression` to Engine table so
users can use https://github.com/containers/buildah/pull/4912 by
default.

Closes: https://github.com/containers/buildah/pull/4912#issuecomment-1661105029

Signed-off-by: Aditya R <arajan@redhat.com>
2023-08-24 17:10:06 +05:30
Valentin Rothberg 9e659206ec pkg/config: add a new API to create a Config
Add `New()` function to create a Config and deprecate `NewConfig` which is
a) not extensible and b) broken in the sense that no external caller was
actually using the argument.

Many call sites use `Default()` which now has improved documentation and
allows for interacting with `New().  Most call sites just need to access
a pro-loaded config (via `Default()`).  This config can overridden by
`New()` if the caller sets the specific option - a requirement for an
upcoming feature for Podman allowing to load user-specified configs via
CLI flags.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-14 09:40:27 +02:00
Valentin Rothberg 961863eab1 pkg/config: tests: do not load default config before each test
It's wasteful and `sut` was not a name I would now understand. Change
the tests that need a default config.  The diff also shows that the
tests would benefit a lot from a rewrite into a table-driven form but I
do not want to shave the entire Yak.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-14 09:40:27 +02:00
Daniel J Walsh cdb801ec18 We don't want TERM environment turned on by default
This should only be done in container-engines that are using a
terminal.

Reverts: https://github.com/containers/common/pull/267

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-31 11:33:28 -04:00
danishprakash 877c1f0d34 config: rm cni plugins dir check
This check as part of validation errors out in conditions where
Netavark is used instead of CNI which is rather misleading. Removing
this check from Validation (early on) and expecting it to fail
closer to time-of-use.

Signed-off-by: danishprakash <danish.prakash@suse.com>
2023-07-25 17:41:37 +05:30
Valentin Rothberg 0ce0a1367c containers.conf: add new `compose_providers` option
Specify one or more external providers for the compose command.  The
first found provider is used for execution. Can be an absolute path or a
(file) name. Relative names are invalid.  File names are evaluated via
$PATH look ups.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-07-24 15:53:17 +02:00
Valentin Rothberg dc08c0598b containers.conf: add new `compose_warnings_logs` option
Emit logs on each invocation of the compose command indicating that an
external compose provider is being executed.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-07-24 10:06:41 +02:00
Paul Holzinger c0a7616486 pkg/config: add default_rootless_network_cmd field
Add a new field to the network section to allow users to set the default
network program which is used when running rootless containers.
This should be used when you run something like --network private or
--network default as rootless user.

The current default is slirp4netns so we keep that for now. Once I
integrate pasta in the rootless netns then we can consider switching the
default to pasta.

This setting will also be useful then for distros who may not ship pasta
so that they could set it back to slirp if needed.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-23 13:40:23 +02:00
Paul Holzinger 2b8784dad0 pkg/config: add pasta_options field
Users way wish to configure a set of default options that should be used
when running pasta. Options that are given on the cli will be appended,
however the implementation of this needs to happen in podman.

For slirp4netns we already support the network_cmd_options field.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-23 13:40:22 +02:00
Valentin Rothberg e17483b871 bump to golangci-lint v1.50.0
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-17 15:03:07 +02:00
Daniel J Walsh 3196de901c Add support for returning image path with ARCH and OS Substitutions
Allow distributions to specify the location of the podman image VM
images in the form of URIs with $ARCH and $OS specified.  This would
allow a distribution to pull the image based on the current OS and Arch.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-22 07:17:58 -04:00
Dominique Martinet 2e8943d3f7 add network dns_bind_port setting and set NETAVARK_DNS_PORT from it
This commit allows using aardvark with an alternate port as per
implementation in containers/netavark#323

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
2022-07-08 09:45:15 +09:00
Kir Kolyshkin b951b72412 Gofumpt the code
gofumpt is a stricter version of gofmt, basically making the code more
readable, and fixing the gocritic's octalLiterar warnings like this one:

	pkg/util/util_supported.go:26:17: octalLiteral: use new octal literal style, 0o722 (gocritic)
		return (perm & 0722) == 0700
			       ^

Generated by gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-04-09 16:50:11 -07:00
Sascha Grunert a6b63a5c47 Switch to ginkgo/v2
Update ginkgo to the next major version which has been released a while
ago.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-03-30 10:03:17 +02:00
Valentin Rothberg 095aded91c go fmt: use go 1.18 conditional-build syntax
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-18 11:04:40 +01:00
Paul Holzinger b76062811b pkg/config: add new default_subnet_pools field
Add a new field to set the default subnet pools. They can be used to
change the subnet which is automatically allocated by podman network
create.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-02-15 15:29:19 +01:00
Paul Holzinger 4eb265ce95 remove rootless_networking field from containers.conf
This field was only needed for machine to force cni, however you can set
netns="bridge" in the config to have the same effect. This is already
done in the machine setup.

The field was more of a hack and just creates confusion for users so we
remove it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-20 16:23:12 +01:00
OpenShift Merge Robot a17d7ed71f Merge pull request #833 from vrothberg/compat-registry
containers.conf: add option to enforce docker.io for compat API
2021-11-22 21:40:31 +01:00
OpenShift Merge Robot aeadc7f2af Merge pull request #830 from rhatdan/network
Set netns to default to private like other namespaces
2021-11-19 17:34:16 +01:00
Valentin Rothberg c9748ff5ad containers.conf: add option to enforce docker.io for compat API
Add an option to containers.conf as a knob to enforce short-name
resolution to Docker Hub in Podman's compatibility REST API.

By popular request, turn it on by default.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-19 16:44:56 +01:00
Valentin Rothberg 1d98659f5a increase default machine vm size to 100GiB
Context: containers/podman/issues/11712
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-19 07:49:53 +01:00
Daniel J Walsh 4249000f56 Set netns to default to private like other namespaces
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-18 10:42:47 -05:00
Daniel J Walsh 6d6fe11781 Set the environment variables for the engine
The Engine.Env needs to be set very early in the setup process
to make sure no one attempts to use the environment.

Fixes: https://github.com/containers/podman/issues/12296

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-15 12:03:40 -05:00
Ashley Cui bb2b17e7da Add machine table to containers.conf
Add machine teable to configure podman machine options. Move machine_image to the machine table, and add cups, disk size, and memory to the machine table.

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-09-23 17:03:12 -04:00
Ashley Cui 927da0ce99 Add machine_image to containers.conf
Signed-off-by: Ashley Cui <acui@redhat.com>
2021-08-09 15:37:06 -04:00
Ashley Cui 9fa534c40a Allow /etc/containers/containers.conf to be read by non-root
If a root user writes to a config using Write(), and there is not already an /etc/containers/containers.conf, Write() will create it. This config file also needs to be read by non-root podman.

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-06-22 09:52:09 -04:00
Tino Rusch 5ec160696b add 'secret' section to the containers.conf struct. 2021-06-10 14:04:32 +02:00
OpenShift Merge Robot d99e42a59c Merge pull request #590 from rhatdan/systemd
Tests are writing customer config to host machine
2021-05-31 09:48:33 +02:00
Paul Holzinger 79bec2ae80 Do not set the default netns
The default netns must be empty. Podman should decide what the default
option is. While podman also defaults to slirp4netns as rootless and
bridge as root, there are also other defaults for `podman run --pod ...`
and `podman pod create --infra=false` where it defaults to the pods
netns. This config field was always ignored by podman and trying to
make it work requires this patch since the default values are incorrect
for podman.

Buildah does not seem to use it either.

Also move the rootless_networking field in the default config file to
the correct containers stanza.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-05-28 16:33:03 +02:00
Daniel J Walsh 71403e2e9a Tests are writing customer config to host machine
[NO TESTS NEEDED]

the config.Write() command looks for the CONTAINERS_CONF setting,
since we were resetting it back to default, it was mistakenly
overwriting the user executing the tests local containers.conf file.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-27 13:21:16 -04:00
Brent Baude cf1c43959f rootless networking
Set type of rootless networking with:

rootless_networking = "slirp4netns | cni"

slirp is the default

Signed-off-by: Brent Baude <bbaude@redhat.com>
2021-05-20 15:34:44 -05:00
Ashley Cui 24f4991dc1 Add support for machine_enabled in containers.conf
machine_enabled is a bool that indicates if Podman is running in a
podman-machine VM

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-04-23 14:37:18 -04:00
Daniel J Walsh 1ef1790040 Add TERM=xterm to default setting for env
We want to make sure that the TERM envionment variable is always
set.  TERM defaulted to ansi might be better, but we want to match
Docker defaults, so we will stick at xterm.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-18 11:37:15 -04:00
Ashley Cui 93a6847b2d Add support for Umask
Signed-off-by: Ashley Cui <acui@redhat.com>
2020-07-15 13:59:29 -04:00
Daniel J Walsh 560bd489ae Merge pull request #200 from ashley-cui/master
Add support for timezone
2020-06-30 17:07:39 -04:00
Ashley Cui bf1b8b15b6 Add support for timezone
Signed-off-by: Ashley Cui <acui@redhat.com>
2020-06-30 15:07:49 -04:00
Qi Wang 82a0ff9d5c Add container_engine_env for engine to use
Add container_env_var for setting envariables for engin to use.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-29 16:50:14 -04:00
Daniel J Walsh dd0b47bedf Fix testing to not race on containers.conf
Looks like the Write test has to run last.  Not sure why this is
crashing but this fixes the issue.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-25 06:04:39 -04:00