Commit Graph

2423 Commits

Author SHA1 Message Date
Paul Holzinger 2589ef49aa libnetwork/rootlessnetns: make mountns tree private
While this is a none issue normally because we run in a unprivileged
userns we cannot modify the host mounts in any way. However in case
where the rootless netns logic might be executed from a non userns
context we might change the mount tree if the mounts are shared which is
the systemd default. While this should never happen let's make sure we
never mess up the system by accident in case there are more bugs and
explicitly make our mount tree private.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-03 11:40:44 +02:00
Paul Holzinger 8b4ecddf95 libnetwork/rootlessnetns: do not use rootless-netns when not re-exec
The IsRootless() check is dangerous in a sense that it may not do what
you think it does. It also returns true even when podman is run as root
and not in the podman userns but as part of a different userns. Could be
a other container manager that configured the userns.

This results in us doing the rootless-netns logic even when we should
not need to. To fix this we now check for the
_CONTAINERS_USERNS_CONFIGURED env var to make sure we are not
re-exe'ed. This is what we actually care about.

This is a regression compared to podman 4.X, because the code was moved
into c/common the IsRootless() check was changed to the c/storage
version which has the userns special case.

Fixes containers/podman#22218

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-03 11:40:44 +02:00
Paul Holzinger 0ecb922857 libnetwork/rootlessnetns: make setup more robust
We have little to no control over what happens tot he slirp4netns/pasta
process after we started it. It could crash or get killed then we end up
in state where we think networking works when it doesn't.

To fix this each time we access the rootless-netns we should also make
to program is still running, if it is not try to recover by starting it
again. This ensures that we are much more fault tolerant.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-03 11:40:43 +02:00
Paul Holzinger 717b818665 libnetwork/rootlessnetns: add readPidFile() helper
Add a function to read a pidfile, this helps to avoid some duplication.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-03 11:40:43 +02:00
Paul Holzinger 657beb187c libnetwork/rootlessnetns: fix netns leak on errors
When the netns program fails to configure the netns or we fail for any
other reason during the setup we must make sure to remove the netns
mount again. Without it the next command sees the existing mount and
thinks the netns was setup correctly but than later fails during the
custom resolv.conf mount because the resolv.conf source file was never
created.

For future we should consider adding checks due ensure pasta/slirp4netns
is still running when we access the netns to make it more fault
tolerant.

The reason this is a common problem is that on boot pasta can likely
fail if it was started before the networking was fully configured (i.e.
no default route).

Fixes containers/podman#22168

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-03 11:40:43 +02:00
openshift-merge-bot[bot] 93fa77f3c7 Merge pull request #1919 from nalind/index-resolve-images
manifest add: check for local images last
2024-04-02 18:44:48 +00:00
openshift-merge-bot[bot] c7b0f576a6 Merge pull request #1917 from nalind/index-add-annotations
manifests: preserve Annotations when adding from indexes
2024-04-02 17:08:33 +00:00
openshift-merge-bot[bot] 7455dbaf1e Merge pull request #1920 from nalind/libimage-load-reference
Add a libimage.Runtime.LoadReference for loading images
2024-04-02 11:05:32 +00: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
Nalin Dahyabhai c58341d561 manifest add: check for local images last
When adding a reference to a manifest list or image index, if we are
guessing that it's a reference to an image in a registry, check if we
can read something from that location instead of assuming it's correct,
and if we can't, check for a local image.  This will let use use local
image IDs to refer to items that we want to add to a list or index.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-29 17:15:56 -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
Lokesh Mandvekar ec70a4238c mention default runtimes correctly
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2024-03-27 18:33:46 +05:30
openshift-merge-bot[bot] 735af70653 Merge pull request #1923 from afbjorklund/dlocate-list
Use dlocate list instead of dpkg query
2024-03-26 14:22:39 +00:00
Nalin Dahyabhai 966738be5b manifests: preserve Annotations and URLs when adding from indexes
When adding items from one index into another, preserve the annotations
and URLs which are set in the descriptors in the source index.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-25 09:48:52 -04:00
Nalin Dahyabhai 2f0cf99f30 Add a libimage.Runtime.LoadReference for loading images
Add a LoadReference() method, for when we already know what format the
local image should be treated as, and we don't have the patience for
Load()'s guessing at it.

Teach libimage.Runtime.copyFromDefault() about the docker transport.
It's already required at build-time because it's directly referenced
elsewhere in the same file.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-03-25 09:40:54 -04:00
renovate[bot] 18380f9fad fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-24 17:00:51 +00:00
Anders F Björklund 22622707d6 Use dlocate list instead of dpkg query
Previously dlocate was only used for half of the process, not both.

Use the dlocatedb for both lookups, both package list and file list.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2024-03-24 17:57:47 +01:00
openshift-merge-bot[bot] 34590f03a2 Merge pull request #1922 from rhatdan/pull
Simplify PullPolicy handling
2024-03-22 06:55:26 +00:00
Ed Santiago 17351e274e CI: bump VMs to 2024-03-20
...and remove the "dnf install podman-plugins", that package
no longer exists.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-03-21 08:24:22 -06:00
Daniel J Walsh 6ce9df9f83 Simplify PullPolicy handling
Add support for ifmissing

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-03-21 08:00:57 +01:00
Anders F Björklund 00fe10d824 Only try each package format once
If there is a "slow" and a "quick" program (not missing),
do not look for the package again (if it is not there).

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2024-03-20 22:17:10 +01:00
renovate[bot] dd38d401a6 fix(deps): update module github.com/onsi/gomega to v1.32.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-20 15:28:11 +00:00
renovate[bot] a3e54c38de fix(deps): update module github.com/docker/docker to v25.0.5+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-20 10:06:49 +00:00
renovate[bot] 6021fd06a6 fix(deps): update module github.com/onsi/ginkgo/v2 to v2.17.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-18 19:13:37 +00:00
openshift-merge-bot[bot] 18420ec9a5 Merge pull request #1905 from Luap99/pasta-result
libnetwork: add new function to better deal with pasta's resolv.conf/hosts file setup in podman
2024-03-18 13:17:53 +00: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
Paul Holzinger 41132462dc libnetwork/slirp4netns: build result type on all oses
My plan is to directly use the result in podman on the Container struct,
this is shared with freebsd even though slirp4netns will never be used
there. Thus we can simply move the type definition to the file that is
shared to not cause build problems.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-15 11:54:23 +01:00
Paul Holzinger 41cf937776 libnetwork/etchosts: add GetHostContainersInternalIPExcluding()
For callers like podman we might have to exclude certain ips for the use
of host.containers.internal as they might conflict with the inside
container ip otherwise.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-15 11:54:23 +01:00
Paul Holzinger 70ce08ed1e libnetwork/util: add GetLocalIPExcluding()
For some cases it may be required to get a local ip while excluding a
certain ip. This will be used to set a better host.containers.internal
name for pasta networks as it is likely that host eth0 ip == container
ip so in this case we must use different host ip.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-15 11:54:23 +01:00
Paul Holzinger a06b884af6 libnetwork/rootlessnetns: use pasta.Setup2()
This tells us if ipv6 is supported. And we should use the forward ips as
dns servers to make sure we can read localhost resolvers on the host.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-15 11:54:22 +01:00
Paul Holzinger 0e9fc319dd libnetwork/pasta: set --dns-forward as default
By default set 169.254.0.1 as nameserver in the container, right now we
do not do special dns handling which means if a user has only localhost
resolver or the same nameserver ip as the host ip used by pasta then dns
will most likely fail.

pasta allows us to remap one ipv4 for dns which will then automatically
get remapped to the host dns server from resolv.conf. For that we must
use --dns-forward, now the choice of which ip is arbitrary but using the
local link address 169.254.0.1 is unlikely to be used so it should avoid
conflicts.

Also return the ip in the result together with a ipv6 bool so that
podman can create a correct resolv.conf with that ip for the container.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-15 11:54:22 +01:00
Paul Holzinger 41a8f8ea1b Revert "libnetwork/pasta: pass --dns none"
This reverts commit 2793c58e68.
I plan on using --dns-forward now so we do not want to disable dns by
default, see [1].

[1] https://github.com/containers/podman/issues/19213

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-15 11:54:22 +01:00
Paul Holzinger 83573fa60c libnetwork/pasta: add new Setup2 to return result
Currently both callers in podman and buildah join and inspect the netns
to get the local ip configured by pasta in order to add it to
/etc/hosts. So instead of doing this in two places let's just do it here
once and return the result to the caller.

In order to not cause vendoring issues I decided against breaking the
API and added a new Setup2 function instead. I will then update
podman and buildah to make use of it.

Also I plan on adding more fields in the result, i.e. dns address.

Because this now depends on linux only functionality make sure to only
build it on linux, pasta only works on linux anyway so this is not a
problem.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-15 11:54:22 +01:00
renovate[bot] bd3ddb9321 fix(deps): update module github.com/checkpoint-restore/go-criu/v7 to v7.1.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-15 10:01:38 +00:00
Paul Holzinger 7f9cb46d49 revert dep bumps that require go 1.21
So apparently go 1.21 introduced a new toolchain directive that
specifies the minimum version that go uses to build. Also the go
directive is now a hard requirement. We are not ready for this at all,
podman CI still uses f38 with go 1.20.

We need to figure a proper way how to deal with this, for now do not
merge any PR's that set toolchain or bump the go version to 1.21.

see https://go.dev/doc/toolchain

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-14 16:47:24 +01:00
renovate[bot] ac3197eee7 chore(deps): update module google.golang.org/protobuf to v1.33.0 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-14 14:18:19 +00:00
Chris Evich 3a6e224ca5 Cirrus-CI: Give success a name
This and the referenced openshift/release PR will make `prow` (via the
`tide` bot) block merges unless the success aggregation task is green.
This must be configured independently from branch-protection rules which
tide does/can not manage due to write-only access.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-03-13 10:25:14 -04:00
openshift-merge-bot[bot] b55a9507e7 Merge pull request #1904 from adrianreber/2024-03-13-common
Added checkpoint specific functions
2024-03-13 09:56:42 +00:00
Adrian Reber 3d5258dcd7 Added checkpoint specific functions
These functions are currently used in Podman and CRI-O. Instead of CRI-O
including Podman files, let's move it to common.

Signed-off-by: Adrian Reber <areber@redhat.com>
2024-03-13 07:05:36 +00:00
renovate[bot] f10d66280a chore(deps): update module gopkg.in/go-jose/go-jose.v2 to v2.6.3 [security]
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-12 16:51:49 +00:00
renovate[bot] 16888b620a fix(deps): update module github.com/containernetworking/plugins to v1.4.1
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-12 13:20:43 +00:00
renovate[bot] 093e25c2d5 fix(deps): update module github.com/containers/ocicrypt to v1.1.10
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-12 12:34:20 +00:00
renovate[bot] 1ae82969f1 fix(deps): update module github.com/onsi/ginkgo/v2 to v2.16.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-12 10:36:24 +00:00
renovate[bot] c35e892c5d fix(deps): update module github.com/docker/docker to v25.0.4+incompatible
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-12 07:50:00 +00:00
renovate[bot] 059c2a1880 fix(deps): update module github.com/containerd/containerd to v1.7.14
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-11 16:32:02 +00:00
tomsweeneyredhat ea9891a487 Bump to v0.59.0-dev
As the title say, bumping to the next dev version.

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-03-06 09:48:10 -05:00
tomsweeneyredhat 66329bdd95 Bump to v0.58.0
As the title says.  In preparation of Podman v5.0,
bumping to v0.58.0.

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-03-06 09:48:10 -05:00
tomsweeneyredhat 7ef6b56fd2 Bump c/storage to v1.53.0, c/image to v5.30.0
As the title says.  The third step in the vendor dance.
Bumps c/storage v1.53.0 and c/image to v5.30.0 all in
preparation of Podman v5.0

[NO NEW TESTS NEEDED]

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2024-03-06 09:48:10 -05:00
Paul Holzinger 326501ca49 github: bump go version for lint to 1.22
1.19 is eol and likely no longer works to compile new code thus failing
all lints jobs that uses go 1.20 or newer features.

To fix that lets update to the latest stable version go 1.22.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-06 13:03:55 +01:00
Paul Holzinger d240865a45 lint: update golangci-lint to v1.56.2
Adds a couple of new linters with many new warnings:
- perfsprint (fixed in code, excluded for tests)
- revive (fix the problems, disabled the dot import check as we use it
  for ginkgo)
- inamedparam (disabled because it is opinionated)
- testifylint (great linter but we have like 1000+ issues that I have no
  time fixing now)

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-05 18:10:32 +01:00