115 Commits

Author SHA1 Message Date
666d839157 golangci-lint: make windows linting happy
It qemu cannot be compiled anyway so make sure we do not try to compile
parts where the typechecker complains about on windows.
Also all the e2e test files are only used on linux as well.
pkg/machine/wsl also reports some error but to many for me to fix them
now. One minor problem was fixed in pkg/machine/machine_windows.go.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-08-19 11:41:29 +02:00
7bb3b83c17 CI: enable root user namespaces
Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-07-27 23:23:29 +02:00
267d838e38 ExitWithError, continued
Low-hanging fruit: Exit(X) with no error message
is now ExitWithError(X, "")

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-06-12 08:48:19 -06:00
275c068df7 ExitWithError() - pod_xxx tests
Followup to #22270: wherever possible/practical, extend command
error checks to include explicit exit status codes and error strings.

This commit handles a subset of test/e2e/pod_xxxx_test.go
(I stopped before this grew too huge for review)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-05-02 08:48:24 -06:00
facad62afe tests: fix after make podman inspect cmd return compatible with Docker API v1.44
Signed-off-by: Florian Bezannier <florian.bezannier@hotmail.fr>
2024-02-28 19:45:03 +01:00
72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
29273cda10 lint: fix warnings found by perfsprint
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-20 16:27:46 +02:00
26b5b1dd3c unbreak CI: useradd not found
The fedora minimal 39 image has been updated on the fedora registry and
removed the `useradd` binary.  Since we were pulling by tag and not by
digest, updates to images outside of our control always entail a certain
risk - and now it bit us.

To fix it, try to move as many users of `useradd` to _our_ CITEST_IMAGE
and migrate the code where necessary to this Alpine-based tooling.
However, the Alpine-based `adduser` binary (not useradd!) doesn't work
well when being executed as a non-root user and will just error out.
Hence, move the fedora minimal image back to version 34 which is still
including the `useradd` binary.

Ultimately, all images on public registries should be pulled via digest
to make sure we pin them down.  I refrain from doing this now to make
sure we can cherry-pick this PR to older branches and get things back
into a working state ASAP.

Fixes: #20119
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-25 11:48:35 +02:00
64c46c4297 e2e: ExitCleanly(): low-hanging fruit, part 1
Continuing work on RUN-1907: huge set of files, but not
as intimidating as it looks.

Commit 1 of 2: mindless replace of Exit(0) with ExitCleanly()

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-19 10:26:06 -06:00
1e94100940 Tests: remove/update obsolete skips
To silence my find-obsolete-skips script, remove the '#'
from the following issues in skip messages:

  #11784 #15013 #15025 #17433 #17436 #17456

Also update the messages to reflect the fact that the issues
will never be fixed.

Also remove ubuntu skips: we no longer test ubuntu.

Also remove one buildah skip that is no longer applicable:

Fixes: #17520

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-07-13 15:04:07 -06:00
d0af5df893 e2e: use parallel-safe /dev subdirectories
Replace /dev/foodevdir with unique paths, to avoid one
test's RemoveAll() from stepping on another test.

Closes: #18958

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-21 13:43:19 -06:00
aa453c4f11 make lint: re-enable ginkgolinter
To make sure the e2e tests are kept in order.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 15:09:34 +02:00
ef42f54aca e2e: GetSafeIPAddress() replaces GetRandomIPAddress
For tests that use '--ip XX', random IP allocation is not
working well. Switch instead to a deterministic algorithm
with CPU affinity and a fudge factor for CNI.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-06-15 11:06:40 -06: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
09c11a8d95 Merge pull request #17627 from umohnani8/pod-restart
Add --restart flag to pod create
2023-05-02 16:46:52 -04:00
3050a64373 e2e test cleanup
- fix a typo that was resulting in a test being a NOP, and
   add actual testing to it.

 - fix two Expects() with incorrectly-ordered actual/expects

 - remove leading whitespace from an It() test name

 - To(BeTrue()) is evil. Wherever possible, replace it with
   useful string or field checks. When not possible, use
   the annotation field to indicate what failed. I got
   carried away here, #sorrynotsorry

 - remove unused system-test code

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-05-02 08:36:26 -06:00
edbeee5238 Add --restart flag to pod create
Add --restart flag to pod create to allow users to set the
restart policy for the pod, which applies to all the containers
in the pod. This reuses the restart policy already there for
containers and has the same restart policy options.
Add "never" to the restart policy options to match k8s syntax.
It is a synonym for "no" and does the exact same thing where the
containers are not restarted once exited.
Only the containers that have exited will be restarted based on the
restart policy, running containers will not be restarted when an exited
container is restarted in the same pod (same as is done in k8s).

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-05-02 10:29:58 -04: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
1f45c715df test/e2e: fix incorrect usage of CreateTempDirInTempDir()
Creating a new diretory results in the test leaking it when it is not
removed via a defer call. All tests have already access to
`podmanTest.TempDir` which will be automatically removed in the
`AfterEach()` block.

While some test were fine other forgot the defer call. To keep the test
consitent and prevent other from making the same mistake convert all
users to `podmanTest.TempDir`. `CreateTempDirInTempDir()` is only used
for the `podmanTest.Setup()` call.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-04-20 16:26:55 +02:00
7daab31f1f Ensure that SQLite state handles name-ID collisions
If a container with an ID starting with "db1" exists, and a
container named "db1" also exists, and they are different
containers - if I run `podman inspect db1` the container named
"db1" should be inspected, and there should not be an error that
multiple containers matched the name or id "db1". This was
already handled by BoltDB, and now is properly managed by SQLite.

Fixes #17905

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-03-24 15:09:25 -04:00
0f8530b1ee Remove test for pod/container name global uniqueness
We're removing this constraint from the database, so we should
not be verifying it in CI anymore.

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-03-15 14:44:47 -04:00
0999991b20 add support for limiting tmpfs size for systemd-specific mnts
* add tests
* add documentation for --shm-size-systemd
* add support for both pod and standalone run

Signed-off-by: danishprakash <danish.prakash@suse.com>
2023-02-14 14:56:09 +05:30
0e3524b8b2 e2e tests: fix incorrect os.User.Name
Ha ha. This was supposed to be a trivial little followup to #17174:

   https://github.com/containers/podman/pull/17174#discussion_r1085963780
      (safer username check when --userns=keep-id)

It got complicated. TL;DR we need to use User.Username, not User.Name.
The latter is GECOS! Tests were working because, on Fedora, GECOS
for root is "root". Found and fixed all 'u.Name' instances, but
if there are any references with a variable other than 'u', they
still need looking into.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-01-30 13:54:10 -07:00
c4aae9b47e Get correct username in pod when using --userns=keep-id
Fixes: https://github.com/containers/podman/issues/17148

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-01-24 11:06:06 -05:00
17b5bd758d e2e: use isRootless() instead of rootless.IsRootless()
Unify the functions used to detect rootless to "isRootless()".
This function can detect to join the user namespace by mistake.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-01-18 10:34:51 +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
049a5d82f1 Allow namespace path network option for pods.
Closes #16208.

Signed-off-by: Björn Mosler <dev@bjoern.mosler.ch>
2022-11-04 11:26:06 +01:00
d968f3fe09 Replace deprecated ioutil
Package `io/ioutil` was deprecated in golang 1.16, preventing podman from
building under Fedora 37.  Fortunately, functionality identical
replacements are provided by the packages `io` and `os`.  Replace all
usage of all `io/ioutil` symbols with appropriate substitutions
according to the golang docs.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-09-20 15:34:27 -04:00
0a160fed77 Bump VMs, to Ubuntu 2204 with cgroups v1
...and enable the at-test-time confirmation, the one that
double-checks that if CI requests runc we actually use runc.
This exposed a nasty surprise in our setup: there are steps to
define $OCI_RUNTIME, but that's actually a total fakeout!
OCI_RUNTIME is used only in e2e tests, it has no effect
whatsoever on actual podman itself as invoked via command
line such as in system tests. Solution: use containers.conf

Given how fragile all this runtime stuff is, I've also added
new tests (e2e and system) that will check $CI_DESIRED_RUNTIME.

Image source: https://github.com/containers/automation_images/pull/146

Since we haven't actually been testing with runc, we need
to fix a few tests:

  - handle an error-message change (make it work in both crun and runc)
  - skip one system test, "survive service stop", that doesn't
    work with runc and I don't think we care.

...and skip a bunch, filing issues for each:

  - #15013 pod create --share-parent
  - #15014 timeout in dd
  - #15015 checkpoint tests time out under $CONTAINER
  - #15017 networking timeout with registry
  - #15018 restore --pod gripes about missing --pod
  - #15025 run --uidmap broken
  - #15027 pod inspect cgrouppath broken
  - ...and a bunch more ("podman pause") that probably don't
    even merit filing an issue.

Also, use /dev/urandom in one test (was: /dev/random) because
the test is timing out and /dev/urandom does not block. (But
the test is still timing out anyway, even with this change)

Also, as part of the VM switch we are now using go 1.18 (up
from 1.17) and this broke the gitlab tests. Thanks to @Luap99
for a quick fix.

Also, slight tweak to #15021: include the timeout value, and
reword message so command string is at end.

Also, fixed a misspelling in a test name.

Fixes: #14833

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-07-21 20:08:32 -06:00
0424084b30 fix namespace reporting
somehow, #14501 got through CI even though the remote tests fail. The testa are failing
due to the PodSpecGenerator not containing the UTSNs entitiy and infra's spec is not yet allowed to be accessed remotely

[NO NEW TESTS NEEDED]

resolves #14847

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-07-07 09:51:20 -04:00
ca5bebb082 Merge pull request #14501 from cdoern/podUTS
podman pod create --uts support
2022-07-06 14:51:22 +00: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
8f2d9e7a7c podman pod create --uts support
add support for the --uts flag in pod create, allowing users to avoid
issues with default values in containers.conf.

uts follows the same format as other namespace flags:
--uts=private (default), --uts=host, --uts=ns:PATH

resolves #13714

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-07-05 09:28:07 -04:00
8106568ca2 test: drop pod-create --device-read-bps test
the test is not doing what it believes to do.  The containers are not
supposed to be joining the infra container cgroup.

In addition, the result is validated only on cgroup v1 systems (that
are not used in the CI).

We may want to add it back, or a variant of it, once the
--device-read-bps option applies to the pod parent cgroup.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-07-03 22:56:30 +02:00
f451b68dfa podman pod create --shm-size
expose the --shm-size flag to podman pod create and add proper handling and inheritance
for the option.

resolves #14609

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-06-20 10:25:00 -04:00
ed1e4f94fb Infra Inheritance patch
infra was overriding options that it should be appending rather than resetting.
fix this by appending the given container's spec to the compatible options before marshaling/unmarshaling

resolves #14454

Signed-off-by: cdoern <cdoern@redhat.com>
2022-06-07 11:42:16 -04: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
8080a5f8ec Revert "container,inspect: convert Entrypoint to array instead of a string"
It seems this breaks older version of `podman-remote` users hence it
looks like this patch would be a better candidate for podman `5.0`

Problem
* Client with `4.0` cannot interact with a server of `4.1`

Plan this patch for podman `5.0`

This reverts commit 0cebd158b6d8da1828b1255982e27fe9224310d0.

Signed-off-by: Aditya R <arajan@redhat.com>
2022-04-22 00:58:40 +05:30
0cebd158b6 container,inspect: convert Entrypoint to array instead of a string
Convert container entrypoint from string to an array inorder to make
sure there is parity between `podman inspect` and `docker inspect`

Signed-off-by: Aditya R <arajan@redhat.com>
2022-04-08 18:43:37 +05:30
7a53428049 fix pod volume passing and alter infra inheritance
the infra Inherit function was not properly passing pod volume information to new containers
alter the inherit function and struct to use the new `ConfigToSpec` function used in clone
pick and choose the proper entities from a temp spec and validate them on the spegen side rather
than passing directly to a config

resolves #13548

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Signed-off-by: cdoern <cdoern@redhat.com>
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-03-29 11:10:46 -04:00
956664f65b Merge pull request #12930 from cdoern/podCgroup
Podman pod create --share-parent vs --share=cgroup
2022-02-04 09:41:12 -05:00
9eb88ea474 Podman pod create --share-parent vs --share=cgroup
separated cgroupNS sharing from setting the pod as the cgroup parent,
made a new flag --share-parent which sets the pod as the cgroup parent for all
containers entering the pod

remove cgroup from the default kernel namespaces since we want the same default behavior as before which is just the cgroup parent.

resolves #12765

Signed-off-by: cdoern <cdoern@redhat.com>
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Signed-off-by: cdoern <cdoern@redhat.com>
2022-02-03 09:30:17 -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
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
f257d98394 Podman Pod Create --sysctl support
added support for pod wide sysctls. The sysctls supported are the same as the continer run controls.

These controls are only valid if the proper namespaces are shared within the pod, otherwise only the infra ctr gets the sysctl

resolves #12747

Signed-off-by: cdoern <cdoern@redhat.com>
2022-01-12 20:49:04 -05:00
289270375a Pod Security Option support
Added support for pod security options. These are applied to infra and passed down to the
containers as added (unless overridden).

Modified the inheritance process from infra, creating a new function Inherit() which reads the config, and marshals the compatible options into an intermediate struct `InfraInherit`
This is then unmarshaled into a container config and all of this is added to the CtrCreateOptions. Removes the need (mostly) for special additons which complicate the Container_create
code and pod creation.

resolves #12173

Signed-off-by: cdoern <cdoern@redhat.com>
2021-12-27 13:39:36 -05: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