124 Commits

Author SHA1 Message Date
29273cda10 lint: fix warnings found by perfsprint
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-20 16:27:46 +02:00
e4b7455b72 e2e: ExitCleanly(): manual fixes to get tests working
Commit 2 of 2: fixes to get tests passing

Mostly reverting back to Exit(0) on tests that produce stderr,
adding stderr checks when those are missing.

One pretty big exception: "run check dns" test was completely
broken in many respects. It should never have worked under CNI,
but was passing because nslookup in that alpine image was
checking /etc/hosts. This has been fixed in subsequent alpine
images, which we're now using in this test (CITEST_IMAGE).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-26 08:47:16 -06:00
dbd946a932 e2e: ExitCleanly(): a few more
Commit 1 of 2: automated string replace Exit(0) -> ExitCleanly()

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-26 08:47:16 -06:00
d7e25e14aa Add missing reserved annotation support to play
Adds any required "wiring" to ensure the reserved annotations are supported by
`podman kube play`.

Addtionally fixes a bug where, when inspected, containers created using
the `--publish-all` flag had a field `.HostConfig.PublishAllPorts` whose
value was only evaluated as `false`.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-17 14:06:23 -04:00
2a9b9bb53f netavark: macvlan networks keep custom nameservers
The change to use the custom dns server in aardvark-dns caused a
regression here because macvlan networks never returned the nameservers
in netavark and it also does not make sense to do so.

Instead check here if we got any network nameservers, if not we then use
the ones from the config if set otherwise fallback to host servers.

Fixes #19169

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-12 14:07:34 +02:00
f1c68b79eb add hostname to network alias
We use the name as alias but using the hostname makes also sense and
this is what docker does. We have to keep the short id as well for
docker compat.

While adding some tests I removed some duplicated tests that were
executed twice for nv for no reason.

Fixes #17370

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-11 15:38:24 +02:00
7d831d555c network create/update: allow dns servers comma separated
The examples show that --dns-add 8.8.8.8,1.1.1.1 is valid but it fails,
fix this by using StringSliceVar which splits at commas.
Added tests to ensure it is working.

Fixes #18632

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-22 13:30:39 +02:00
ab29ff2f66 test/e2e: dedup Before/AfterEach nodes
There is no reason to define the same code every time in each file, just
use global nodes. This diff should speak for itself.

CleanupSecrets()/Volume() no longer call Cleanup() directly, as the
global AfterEach node will always call Cleanup() this is no longer
necessary. If one AfterEach() node fails it will still run the others.

Also always unset the CONTAINERS_CONF env vars. This prevents people
from forgetting to unset it. And fix the special CONTAINERS_CONF logic
in the system connection tests, we do not want to preserve
CONTAINERS_CONF anyway so just remove this logic.

Ginkgo orders the BeforeEach and AfterEach nodes. They will be executed
from the outer-most defined to inner-most. This means our global
BeforeEach is always first. Only then the inner one (in the Describe()
function in each file). For AfterEach it is inverted, from the inner to
the outer.
Also see https://onsi.github.io/ginkgo/#organizing-specs-with-container-nodes

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-15 16:56:18 +02:00
c564d9d7af ginkgo v2: remove CurrentGinkgoTestDescription()
This function is deprecated and replaced with CurrentSpecReport().
Also fix inconsitent callers.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:36 +02:00
445815036f update to ginkgo v2
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-05-02 11:27:35 +02:00
eeb210bc56 e2e: remove "-it" from podman run & exec
...at least as many as possible. "run/exec -it" make no sense
in a CI environment; I believe the vast majority of these are
the result of fingers typing on autopilot, then copy/pasting
cascades from those. This PR gets rid of as many -it/-ti as
possible. Some are still needed for testing purposes.

Y'all have no idea how much I hate #10927 (the "no logs from conmon"
flake). This does not fix the underlying problem, nor does it even
eliminate the flake (The "exec terminal doesn't hang" test needs
to keep the -ti flag, and that's one of the most popular flakers).
But this at least reduces the scope of the problem. It also removes
a ton of nasty orange "input device is not a TTY" warnings from logs.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-04-26 09:21:02 -06:00
bdf367958e Netavark userns test: give aardvark time to come up
Nasty test flake, "bad address nc-server.dns.podman"

Cause: "There is absolutely no guarantee that aardvark-dns
is ready before the container is started." (source: Paul).

Workaround (not a real solution): wait before doing a host lookup.

Also: remove a 99%-duplicate test.

Closes: #16272   (I hope)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-04-25 10:54:01 -06:00
a089f1b5c3 e2e networking test: better way to get host IP
uber/jaeger-client-go library is deprecated. Remove it.

Only place it's used is in one e2e test, a test that is flaking
in a way that suggests that the HostIP() weighting heuristic from
that module was not actually getting the best outgoing IP address.
So, switch to using what seems to be the current best practice.
No need to make it reusable, since it's only used in one place.

Oh, also remove undesired "-dt" from two "podman run"s. In one
it's harmless, in the other it would cause a test failure under
some circumstances.

Closes: #18269   (optimistic, aren't I?)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-04-19 13:35:32 -06:00
af7c258117 test/e2e: remove unnecessary SkipIfNetavark() calls
DHCP should be support with netavark now, the dns tests should just
work as well.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-11 17:04:43 +02:00
5f274e45f2 Run make codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-03-21 16:00:54 -04:00
06241077cc libpod,netavark: correctly populate /etc/resolv.conf with custom dns server
After https://github.com/containers/netavark/pull/452 `netavark` is
incharge of deciding `custom_dns_servers` if any so lets honor that and
libpod should not set these manually.

This also ensures docker parity
Podman populates container's `/etc/resolv.conf` with custom DNS servers ( specified via `--dns` or `dns_server` in containers.conf )
even when container is connected to a network where `dns_enabled` is `true`.

Current behavior does not matches with docker, hence following commit ensures that podman only populates custom DNS server when container is not connected to any network where DNS is enabled and for the cases where `dns_enabled` is `true`
the resolution for custom DNS server will happen via ( `aardvark-dns` or `dnsname` ).

Reference: https://docs.docker.com/config/containers/container-networking/#dns-services
Closes: containers#16172

Signed-off-by: Aditya R <arajan@redhat.com>
2023-01-22 12:48:55 +05:30
7be8ff5644 unskip network update test
They should work with the new VM images.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-01-19 15:44:17 +01:00
882cd17f83 network: add support for podman network update and --network-dns-server
* Add support for `podman network update <>`

```console
network update

Description:
  update networks for containers and pods

Usage:
  podman network update [options] NAME

Examples:
  podman network update podman1

Options:
      --dns-add stringArray      add network level nameservers
      --dns-drop stringArray   remove network level nameservers
```

* Add support for `--network-dns-server` to `podman network create`

Extends podman to support recently added features in `netavark` and
`aardvark-dns`

* https://github.com/containers/netavark/pull/497
* https://github.com/containers/aardvark-dns/pull/252
* https://github.com/containers/netavark/pull/503

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2023-01-12 20:19:14 +05:30
37ade6be12 Network tests: ping redhat.com, not podman.io
Much as we'd love to eat our dogfood, podman.io is not hosted
on reliable infrastructure; redhat.com is. Let's see if this
gets rid of CI flakes.

Closes: #17044

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-01-10 05:38:43 -07:00
3718ac8e96 Vendor in latest containers/common with default capabilities
Also update vendor of containers/storage and image

Cleanup display of added/dropped capabilties as well

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-15 14:28:30 -05:00
7784f1d165 Merge pull request #16758 from Luap99/nv-ipam-none
test/e2e: enable "podman run with ipam none driver" for nv
2022-12-06 20:02:43 -05:00
c7b936a415 test/e2e: enable "podman run with ipam none driver" for nv
This should work since nv v1.1.

Fixes #13931

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-12-06 18:25:34 +01:00
86f4bd4f54 e2e: fix e2e tests in proxy environment
- podman generate kube inheritents the proxy environment valiable by default.
  Therefore, Env field is not empty if it is set.

- systemd-socket-acrivate needs to pass an proxy environment variable.

- busybox wget with an proxy doesn't work.
  Network tests should use not wget but curl.
  https://gitlab.alpinelinux.org/alpine/aports/-/issues/10446

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-12-06 11:14:19 +09:00
2ddf1c5cbd ginkgo tests: apply ginkgolinter fixes
I found the ginkgolinter[1] by accident, this looks for not optimal
matching and suggest how to do it better.

Overall these fixes seem to be all correct and they will give much
better error messages when something fails.
Check out the repo to see what the linter reports.

[1] https://github.com/nunnatsa/ginkgolinter

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-11-25 14:41:43 +01:00
75740be395 all: stop using deprecated GenerateNonCryptoID
In view of https://github.com/containers/storage/pull/1337, do this:

	for f in $(git grep -l stringid.GenerateNonCryptoID | grep -v '^vendor/'); do
		sed -i 's/stringid.GenerateNonCryptoID/stringid.GenerateRandomID/g' $f;
	done

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-09-13 16:26:26 -07:00
4fd5fb97a0 e2e tests: cleanup: capitalize CONSTANTS
A number of standard image names were lower-case, leading to
confusion in code such as:

    registry := podman(... , "-n", "registry", registry, ...)
    ^--- variable                              ^---- constant

Fix a number of those to be capitalized and with _IMAGE suffix:

    registry := podman(...,                    REGISTRY_IMAGE

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-07-05 15:36:08 -06:00
cb76d15230 fix f35 integration test network flake
I am not 100% sure if this is actually causing the problem but I was
able to reproduce locally and this change fixed it there. Without the `-n`
option iptables tries to reverse lookup the ips to domain names. This is
extremely slow for unknown reasons. Given the large amount of iptables
entries due parallel test runs it will not succeed in the default 90 sec
timeout.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-25 15:46:15 +02:00
b22143267b linter: enable unconvert linter
Detects unneccessary type conversions and helps in keeping the code base
cleaner.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-19 13:59:15 +02:00
69c479b16e enable errcheck linter
The errcheck linter makes sure that errors are always check and not
ignored by accident. It spotted a lot of unchecked errors, mostly in the
tests but also some real problem in the code.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-29 14:06:38 +02:00
b3f38c31b2 Ginkgo: use HaveField() for better error checking
This is a very late followup to my ginkgo-improving work of 2021.
It has been stuck since December because it requires gomega 1.17,
which we've just enabled.

This commit is simply a copy-paste of a command I saved in
my TODO list many months ago:

     sed -i -e 's/Expect(\([^ ]\+\)\.\([a-zA-Z0-9]\+\))\.To(Equal(/Expect(\1).To(HaveField(\"\2\", /' test/e2e/*_test.go

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-04-28 05:41:53 -06:00
d4e30b33a1 Temporarily skip netavark/aardvark e2e test
Ref: https://github.com/containers/podman/issues/13931

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-04-27 12:13:54 -04:00
e4ab8a5bed shared netns and --add-host should conflict
Because /etc/hosts is shared for all containers with a shared network
namespace you should not be able to add hosts from a joined container.
Only the primary netns container can set the hosts.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 13:06:00 +02:00
784a13f577 network create: add support for ipam-driver none
Add a new flag to set the ipam-driver. Also adds a new ipam driver none
mode which only creates interfaces but does not assign addresses.

Fixes #13521

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-11 11:09:15 +02:00
ffbab30d7b Run codespell to cleanup typos
[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-03-25 15:34:41 -04:00
611b45c517 Inspect network info of a joined network namespace
Closes: https://github.com/containers/podman/issues/13150
Signed-off-by: 😎 Mostafa Emami <mustafaemami@gmail.com>
2022-03-08 11:00:36 +01:00
6f9f78f7f2 enable netavark specific tests
These are copies of the CNI tests with modifications wherever
neccessary.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2022-02-11 13:34:28 -05:00
7d3ad6081f netavark e2e tests
enabled e2e tests for netavark

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-02-02 13:03:45 -06:00
2f371cb12c container create: do not check for network dns support
We should not check if the network supports dns when we create a
container with network aliases. This could be the case for containers
created by docker-compose for example if the dnsname plugin is not
installed or the user uses a macvlan config where we do not support dns.

Fixes #12972

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-24 16:56:11 +01:00
bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00
eee3a42b7e tests: clean up FIXMEs and noise
e2e tests:
 * remove two FIXMEs:
   * one of them is expected behavior, not a FIXME
   * the other is easily fixed

 * File issue #12521 for a real podman-remote bug, and
   update the Skip() message

system tests:
 * in command-completion test, clean up stray podman-pause image
   (followup to #12322, in which I missed this instance). This
   removes distracting warnings from test logs.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-12-06 08:30:59 -07:00
c0a8814fb4 Use HaveLen(x) instead of Expect(len(y)).To(Equal(x))
sed -i -e 's/Expect(len(\(.*\)))\.To(Equal(\(.*\)))/Expect(\1).To(HaveLen(\2))/' test/e2e/*.go

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-12-02 07:54:53 -07:00
c676495468 Same as previous, for assertions other than Equal()
sed -i -e 's/Expect(\(.*\)\[\(\".*\"\)\])\.To(\(.*\)/Expect(\1).To(HaveKeyWithValue(\2, \3)/' test/e2e/*_test.go

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-12-02 07:54:53 -07:00
9ce7ade8c8 e2e: yet more cleanup of BeTrue/BeFalse
Thanks to Paul for teaching me about HaveKey()

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-30 15:19:57 -07:00
f7cbb1d845 Convert strings.Contains() to Expect(ContainSubstring)
...done manually, not via sed, because some of the inner
expressions include nested commas.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-30 09:53:15 -07:00
b63d696405 e2e tests: enable golint
...and fix problems found therewith.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-29 08:30:00 -07:00
97ab9176f7 e2e tests: clean up antihelpful BeTrue()s
Many ginkgo tests have been written to use this evil form:

    GrepString("foo")
    Expect(that to BeTrue())

...which yields horrible useless messages on failure:

    false is not true

Identify those (automatically, via script) and convert to:

    Expect(output to ContainSubstring("foo"))

...which yields:

    "this output" does not contain substring "foo"

There are still many BeTrue()s left. This is just a start.

This is commit 1 of 2. It includes the script I used, and
all changes to *.go are those computed by the script.
Commit 2 will apply some manual fixes.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-22 14:37:43 -07:00
d173ebc067 Add EXPOSE e2e test
Signed-off-by: Colin Bendell <colin@bendell.ca>
2021-11-20 21:05:49 -05:00
0136a66a83 libpod: deduplicate ports in db
The OCICNI port format has one big problem: It does not support ranges.
So if a users forwards a range of 1k ports with podman run -p 1001-2000
we have to store each of the thousand ports individually as array element.
This bloats the db and makes the JSON encoding and decoding much slower.
In many places we already use a better port struct type which supports
ranges, e.g. `pkg/specgen` or the new network interface.

Because of this we have to do many runtime conversions between the two
port formats. If everything uses the new format we can skip the runtime
conversions.

This commit adds logic to replace all occurrences of the old format
with the new one. The database will automatically migrate the ports
to new format when the container config is read for the first time
after the update.

The `ParsePortMapping` function is `pkg/specgen/generate` has been
reworked to better work with the new format. The new logic is able
to deduplicate the given ports. This is necessary the ensure we
store them efficiently in the DB. The new code should also be more
performant than the old one.

To prove that the code is fast enough I added go benchmarks. Parsing
1 million ports took less than 0.5 seconds on my laptop.

Benchmark normalize PortMappings in specgen:
Please note that the 1 million ports are actually 20x 50k ranges
because we cannot have bigger ranges than 65535 ports.
```
$ go test -bench=. -benchmem  ./pkg/specgen/generate/
goos: linux
goarch: amd64
pkg: github.com/containers/podman/v3/pkg/specgen/generate
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
BenchmarkParsePortMappingNoPorts-12             480821532                2.230 ns/op           0 B/op          0 allocs/op
BenchmarkParsePortMapping1-12                      38972             30183 ns/op          131584 B/op          9 allocs/op
BenchmarkParsePortMapping100-12                    18752             60688 ns/op          141088 B/op        315 allocs/op
BenchmarkParsePortMapping1k-12                      3104            331719 ns/op          223840 B/op       3018 allocs/op
BenchmarkParsePortMapping10k-12                      376           3122930 ns/op         1223650 B/op      30027 allocs/op
BenchmarkParsePortMapping1m-12                         3         390869926 ns/op        124593840 B/op   4000624 allocs/op
BenchmarkParsePortMappingReverse100-12             18940             63414 ns/op          141088 B/op        315 allocs/op
BenchmarkParsePortMappingReverse1k-12               3015            362500 ns/op          223841 B/op       3018 allocs/op
BenchmarkParsePortMappingReverse10k-12               343           3318135 ns/op         1223650 B/op      30027 allocs/op
BenchmarkParsePortMappingReverse1m-12                  3         403392469 ns/op        124593840 B/op   4000624 allocs/op
BenchmarkParsePortMappingRange1-12                 37635             28756 ns/op          131584 B/op          9 allocs/op
BenchmarkParsePortMappingRange100-12               39604             28935 ns/op          131584 B/op          9 allocs/op
BenchmarkParsePortMappingRange1k-12                38384             29921 ns/op          131584 B/op          9 allocs/op
BenchmarkParsePortMappingRange10k-12               29479             40381 ns/op          131584 B/op          9 allocs/op
BenchmarkParsePortMappingRange1m-12                  927           1279369 ns/op          143022 B/op        164 allocs/op
PASS
ok      github.com/containers/podman/v3/pkg/specgen/generate    25.492s
```

Benchmark convert old port format to new one:
```
go test -bench=. -benchmem  ./libpod/
goos: linux
goarch: amd64
pkg: github.com/containers/podman/v3/libpod
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
Benchmark_ocicniPortsToNetTypesPortsNoPorts-12          663526126                1.663 ns/op           0 B/op          0 allocs/op
Benchmark_ocicniPortsToNetTypesPorts1-12                 7858082               141.9 ns/op            72 B/op          2 allocs/op
Benchmark_ocicniPortsToNetTypesPorts10-12                2065347               571.0 ns/op           536 B/op          4 allocs/op
Benchmark_ocicniPortsToNetTypesPorts100-12                138478              8641 ns/op            4216 B/op          4 allocs/op
Benchmark_ocicniPortsToNetTypesPorts1k-12                   9414            120964 ns/op           41080 B/op          4 allocs/op
Benchmark_ocicniPortsToNetTypesPorts10k-12                   781           1490526 ns/op          401528 B/op          4 allocs/op
Benchmark_ocicniPortsToNetTypesPorts1m-12                      4         250579010 ns/op        40001656 B/op          4 allocs/op
PASS
ok      github.com/containers/podman/v3/libpod  11.727s
```

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-10-27 18:59:56 +02:00
008075ce54 Slirp4netns with ipv6 set net.ipv6.conf.default.accept_dad=0
Duplicate Address Detection slows the ipv6 setup down for 1-2 seconds.
Since slirp4netns is run it is own namespace and not directly routed
we can skip this to make the ipv6 address immediately available.
We change the default to make sure the slirp tap interface gets the
correct value assigned so DAD is disabled for it.
Also make sure to change this value back to the original after slirp4netns
is ready in case users rely on this sysctl.

Fixes #11062

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-10-26 18:27:30 +02:00
21c9dc3c40 Add --time out for podman * rm -f commands
Add --time flag to podman container rm
Add --time flag to podman pod rm
Add --time flag to podman volume rm
Add --time flag to podman network rm

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-04 07:07:56 -04:00