Commit Graph

67 Commits

Author SHA1 Message Date
Paul Holzinger 32003de258 pkg/config: fix verify getDefaultEnv test flake
Do not use Default() in unit tests, that caches the config in a global
var so it conflicts with other tests also calling it.

Now only the Reload test should test that. The Default() call got broken
by commit c2dee68766 because now the test only unsets the env after the
last Reload() call which should already use the actual default.

Fixes: c2dee68766 ("*_test.go: use t.TempDir, t.Setenv")

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-04-23 13:58:24 +02:00
Kir Kolyshkin a8b49e830a Use t.TempDir for tests
Instead of using os.MkdirTemp in tests, use t.TempDir.

In a few places where the parent directory is already create by t.TempDir,
replace os.MkdirTemp with os.Mkdir.

While at it, make sure to not a leak opened file descriptor returned by
os.CreateTemp.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-14 11:16:55 -07:00
Kir Kolyshkin c2dee68766 Use t.Setenv in tests
Using os.Setenv in tests is problematic, because the change is
process-wise and other tests running in parallel might be affected.
Also, a somewhat complicated cleanup is needed.

Both issues are solved by using t.Setenv.

This commit also uses t.TempDir, t.Cleanup, and t.Helper when it makes
sense.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-14 11:16:55 -07:00
Nalin Dahyabhai 0734e48c4a Update some tests to make the linter happy
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-04-01 09:19:43 -04:00
Micah Chambers (eos) acddeb0689 feat: add a config to set in cdi directories
Adds config to pass CDI spec directory, so that it can be overridden.
The enables rootless containers since otherwise users have to write to
one of the shared, usually only root writeable paths at in /etc or /var.

Signed-off-by: Micah Chambers <micahc.vt@gmail.com>
Signed-off-by: Micah Chambers (minerva) <mchambers@anduril.com>
2024-03-28 09:45:07 -07:00
Paul Holzinger 4a7a8a3496 lint: enable ginkgolinter
This linter creates better assertions in ginkgo tests.
Fixes were made with `ginkgolinter -fix ./...`.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-18 11:51:54 +01:00
openshift-merge-bot[bot] 2eb18e07c7 Merge pull request #1846 from mheon/allow_rootless_netns_pasta
Allow creation of a rootless netns backed by Pasta
2024-02-29 16:55:07 +00:00
Shion Tanaka 2f0a04c6ee Add Rosetta support for applehv(arm64)
Signed-off-by: Shion Tanaka <shtanaka@redhat.com>
2024-02-29 17:23:30 +09:00
Ashley Cui 2a2e8de528 Adjust machine image default
We no longer use `testing` as the default image from fcos for machine.
Adjust default to "" temporarily, as we're still stablizing the location and images for machine images, but still allow the user to specify a custom image via containers.conf.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-02-28 09:44:32 -05:00
Matt Heon e7b5e55c19 Allow creation of a rootless netns backed by Pasta
This makes the code for setting up rootless network namespaces
dependent on what the default rootless network provider is, and
allows Pasta to be used for traffic forwarding on the rootless
netns.

This also switches the default rootless network provider to Pasta

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-27 08:17:09 -05:00
Paul Holzinger 461a17b0cc pkg/config: remove deprecated MachineEnabled field
We now only use the marker file, see pkg/machine.
The advantage of this is that pkg/machine no longer imports pkg/config
and we use it in rootlessport which means it will debloat the binary
there significantly.

The file approach has been added in podman 4.1 (2 years ago) so
basically all machines should have it now and this shouldn't break
anything.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-02-22 14:02:49 +01:00
Paul Holzinger 330f41d7a2 pkg/config: add new connections.conf file
podman systemd conenction and farm currently both write containers.conf
to store their settings. Each write removes comments from the user
config file and thus makes it not great to use.

The new approach is to have a seperate file connections.conf (json
format) to store both conenctions and farms for podman. We continue to
read containers.conf for the connections and farms as well and podman
can read both. This means we have a read only store in containers.conf
(manually added by users), they cannot be removed by the podman cli.

This is a breaking chnage and will require many chnages in podman to
migrate to the new APIs added in this commit.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-01-29 17:05:03 +01:00
Paul Holzinger 745268b117 pkg/config: use containersConfEnv constant everywhere
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-01-29 16:28:06 +01:00
Vikas Goel 9b0147a1ae New global option interface_name in containers.conf
Add a new containers.conf attribute to define how to set interface name inside containers.

Relates to: containers/podman#21313

Signed-off-by: Vikas Goel <vikas.goel@gmail.com>
2024-01-25 07:11:33 -08:00
Oleksandr Redko ba4c7c98bb chore: remove outdated build constraints
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-03 22:56:00 +02:00
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