27 Commits

Author SHA1 Message Date
2f5025a2d7 compat API: allow MacAddress on container config
docker-compose sets the mac address in the container config and not the
network endpoint config. This is ugly when you have more than one
network, in this case docker just chooses the first network.

Fixes #16411

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-12-05 16:52:36 +01:00
52656887e1 compat API: network inspect do not show isolate option
We force the isolate option on new newtworks because that is the docker
behavior. However when we inspect them they should not be displayed to
the caller since they have no idea about it and docker-compose throws an
error because of that.

Fixes #15580

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-25 22:10:22 -04:00
cfbc4aaeb5 Cleanup: fix problems reported by shell lint
Followup to #15616, which is not usable as it is (way, way, way
too much noise) but actually found a few real nits that should
be fixed.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-09-15 20:10:34 -06:00
afbfbe18a1 compose test: remove cni config copy
The network backend always has default config in memory so there is no
need to copy it. Also netavark cannot use it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-07-21 15:37:10 +02:00
340eeed0cb Merge pull request #14626 from jakecorrenti/disable-docker-compose-health-check
Docker-compose disable healthcheck properly handled
2022-07-05 13:50:35 +00:00
5633ef1d15 Docker-compose disable healthcheck properly handled
Previously, if a container had healthchecks disabled in the
docker-compose.yml file and the user did a `podman inspect <container>`,
they would have an incorrect output:

```
"Healthcheck":{
   "Test":[
      "CMD-SHELL",
      "NONE"
   ],
   "Interval":30000000000,
   "Timeout":30000000000,
   "Retries":3
}
```

After a quick change, the correct output is now the result:
```
"Healthcheck":{
   "Test":[
      "NONE"
   ]
}
```

Additionally, I extracted the hard-coded strings that were used for
comparisons into constants in `libpod/define` to prevent a similar issue
from recurring.

Closes: #14493

Signed-off-by: Jake Correnti <jcorrenti13@gmail.com>
2022-07-05 08:02:22 -04:00
488eb3b74c (rootful) docker-compose now updates network MTU
Previously, the following network block did not update using
docker-compose:

```
networks:
  default:
    driver: bridge
    driver_opts:
      mtu: 9000
```

In the API, the network options were previously not being handled when the
network was being created. I translated the docker options into podman
options, and added the options to the network.

When doing `podman network inspect <network>`, the results now contain
`"mtu": "9000"`

Fixes: #14482

Signed-off-by: Jake Correnti <jcorrenti13@gmail.com>
2022-07-05 07:54:09 -04:00
c25213c8f8 fix compose test error in retry logic
We cannot use local var outside of a function. We have to use a global
one.

Log: https://storage.googleapis.com/cirrus-ci-6707778565701632-fcae48/artifacts/containers/podman/5970023511490560/html/compose_v2-podman-fedora-35-root-host.log.html

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-22 15:22:17 +01:00
54641f5f76 fix compose test flake
Reading from the nc socket is flaky because docker-compose only starts
the containers. We cannot know at this point if the container did already
send the message. Give the container 5 seconds time to send the message
to prevent flakes.

This happened rarely with compose v1 but it looks like it will happen a
lot more with compose v2.

Example failure log:
https://storage.googleapis.com/cirrus-ci-6707778565701632-fcae48/artifacts/containers/podman/6567556239589376/html/compose_v2-podman-fedora-35-rootless-host.log.html

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-03-18 16:59:14 +01:00
4b359e4598 Set names in compose tests based on version
Compose v2 uses dashes as separators instead of hyphens. This
broke some tests that relied upon container names. Set the name
conditionally to make it safe for both.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-03-17 15:16:13 -04:00
c0e0723463 rename --cni-config-dir to --network-config-dir
Since this option will also be used for netavark we should rename it to
something more generic. It is important that --cni-config-dir still
works otherwise we could break existing container cleanup commands.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-01-18 19:28:25 +01:00
05614ee139 always add short container id as net alias
This matches what docker does. Also make sure the net aliases are also
shown when the container is stopped.

docker-compose uses this special alias entry to check if it is already
correctly connected to the network. [1]
Because we do not support static ips on network connect at the moment
calling disconnect && connect will loose the static ip.

Fixes #11748

[1] 0bea52b18d/compose/service.py (L663-L667)

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-28 13:40:22 +02:00
dc70382886 Fix AVC denials in tests of volume mounts
This becomes a problem on hosts with upgraded policies.  Ref:
https://github.com/containers/podman/issues/10522

Also, made a small change to compose-test setup to reduce runtime.

Signed-off-by: Chris Evich <cevich@redhat.com>
2021-08-18 12:04:06 -04:00
daebdf3859 Add container config to compat image inspect
With docker-compose, there is a use case where you can `docker-compose
up -d`, then change a file like docker-compose.yml and run up again.
This requires a ContainerConfig with at least Volumes be populated in
the inspect data.  This PR adds just that.

Fixes: #10795

Signed-off-by: Brent Baude <bbaude@redhat.com>
2021-07-09 10:10:04 -05:00
44d9c453d3 Fix network connect race with docker-compose
Network connect/disconnect has to call the cni plugins when the network
namespace is already configured. This is the case for `ContainerStateRunning`
and `ContainerStateCreated`. This is important otherwise the network is
not attached to this network namespace and libpod will throw errors like
`network inspection mismatch...` This problem happened when using
`docker-compose up` in attached mode.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-06-11 16:00:12 +02:00
55f00bac02 Clear the storage-options from the graphdriver if users specifies --root
Fixes: https://github.com/containers/podman/issues/10393

Currently if a user specifies a --root flag to override the location of
the container storage, we still enforce the storage-opts from
storage.conf. This causes issues with people trying to intereact with
the additional stores feature, and then forces them to use the obscure
--storage-opt="" option. I belive this should be the default and we
already do this when the user specifies the --storage-driver option.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-19 15:35:59 -04:00
c0de4a4d70 Fixes docker-compose cannot set static ip when use ipam
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2021-05-06 19:25:27 +08:00
ca4f6ec1db Parse slirp4netns net options with compat api
Parse the slirp4netns network options when called via compat api. The
options must be extracted from the NetworkMode string.

Fixes #10110

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-23 11:48:50 +02:00
4f0a080fdc compose test: diagnose flakes v3
From the debug output we know that rootlesskit does not bind the port
correctly. The rootlesskit port forwarder has a quite a few debug
statements so lets see the debug log when the test fails. Also check
if it binded the port inside the rootless cni namespace.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-15 20:05:39 +02:00
1cf2b3eb28 compose test: ongoing efforts to diagnose flakes
Yay, we got a failure with the new code (#10017). It shows
one ECONNRESET followed by a lot of ECONNREFUSED over an 8-second
period (actually 15s because of the second curl retry).

My hunch: the container itself is dying. No amount of retrying
will get anything to work. So, instead of the curl retry, if
curl fails, run 'docker-compose logs', 'podman ps', and 'ss -tulpn'
and hope that one/more of those tells us something useful when
the test flakes again.

Also: DUH! Bitten by one of the most common bash pitfalls.
Checking exit status after 'local' will always be zero.
Split the declaration and the action into separate lines.

Also: if curl fails, return immediately. There's no point in
running the string output comparison.

Also: in _show_ok(), don't emit "actual/expect" messages
if both strings are empty.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-14 12:32:20 -06:00
31e31aa9dd compose test: try to get useful data from flakes
docker-compose test continues to flake even after #9961.
Let's try to get some useful data from the failures, by:

  * adding -S (--show-error) to curl. With just -s (--silent),
    curl is completely quiet. With -S, it displays errors.
    (Not in TAP form, but I'm OK with that)

  * oops, adding safety checks to the fix from #9961 (it
    was inadvertently clobbering the curl exit status)

And, as long as I'm in this code: logformatter was not
highlighting these results, because the '1..N' TAP line
needs to be spit out at the end. Have test-compose emit
a 'TAP' header <http://testanything.org/> and make
logformatter recognize it.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-13 15:18:34 -06:00
42e4609faf Fix flaking rootless compose test
The compose port test is flaking with an empty curl result. The curl retry
does not work properly. Given the the tests never expect an empty result
lets just wait one second and retry again.
Unfortunately there is no way for me to actually verify if this will fix
the flake.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-07 11:41:15 +02:00
676fcb722f Add new docker-compose test for two networks
Also fix the tests so we can use the podman function with the output.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-01 17:27:03 +02:00
954d920825 Make the docker-compose test work rootless
Make sure the DOCKER_SOCK location is accessible by the user when run
rootless. Alos set the DOCKER_HOST env var to ensure docker-compose will
use the non default location. Cleanup steps such as `rm` or `umount`
must be run inside podman unshare otherwise they can fail due missing
privileges.

Change the curl test to use --retry-all-errors otherwise the tests will
flake. The web server inside the container will return http code 500
sometimes, most likely because it is not fully ready to accept
connections. With --retry-all-errors curl will retry instead of failing
and thus the test will work.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-01 17:27:03 +02:00
cb91bf96e0 add compose test descriptions
adding compose test descriptions and validations.

Signed-off-by: baude <bbaude@redhat.com>
2020-12-11 10:07:13 -06:00
f3e69d7300 test-compose: rewrite to new subdir form
...in which we use all-local tests

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-11 09:27:42 -06:00
82d7b9f2e2 add compose regression to ci
to prevent any regressions, we should be running regression tests using
compose.

Signed-off-by: baude <bbaude@redhat.com>
2020-12-11 09:26:29 -06:00