-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix multiple networks with separately specified ip and mac #867
Conversation
195db2a
to
fedb601
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. It looks good in principle.
The test suite has moved to unittest in main branch, so this PR needs to be updated to match.
Also I think it would be useful to add explicit unit tests to get_net_args function. See e.g. what I did in this PR: https://github.com/containers/podman-compose/pull/819/files.
With unit tests we can cover way more special cases as they run so fast.
Hi @p12tic ! I'm working on the unit tests as you suggested, but I encountered a bit of a problem. It turns out that docker-compose doesn't support specifying a Of course, podman is much nicer than docker and properly supports specification of There are two choices to make here. First, how to handle the container-level
I would expect that option 1 might lead to network headaches inside the container, that option 2 is probably most like the original docker-compose behaviour, and option 3 might mostly do what people might expect (as there is usually no reason to specify And then there's the question if you would like podman-compose to support "extended" podman functionality and allow specification of the services:
some_service:
image: busybox
hostname: myhost
command: ["/bin/busybox", "httpd", "-f", "-h", "/var/www/html", "-p", "8001"]
working_dir: /var/www/html
networks:
shared-network:
ipv4_address: "172.19.1.10"
mac_address: "02:01:01:00:01:01"
internal-network:
ipv4_address: "172.19.2.10"
mac_address: "02:01:01:00:02:01" Please let me know how you would like me to implement this. |
docker-compose spec says it just passes the mac address as
You can see this here https://github.com/docker/cli/blob/a2f3f40233bbe9cd119bed9048973366789de8b5/cli/command/container/opts.go#L810 I think it makes sense to preserve this behavior for the container level As for network-level |
11c4eea
to
35edb9f
Compare
I've made the changes as you requested:
|
pytests/test_get_net_args.py
Outdated
self.assertListEqual(expected_args, args) | ||
|
||
@parameterized.expand([ | ||
# TODO: check is this behaviour introduced by this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover that probably shouldn't be in a PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small nit and we can merge this in. Thanks a lot!
35edb9f
to
b55250b
Compare
Indeed, I forgot to remove that comment. Fixed now! |
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
… addresses Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Specifically: - use "--network=foo" instead of "--network foo" - specify "--network-alias" multiple times instead of concatenating values Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Signed-off-by: Bas Zoetekouw <bas.zoetekouw@surf.nl>
Rebased and will merge soon. Thanks! |
Currently, podman-compose incorrectly parses docker-compose file with multiple networks, for which the
ipv4_address
,ipv6_address
ormac_address
is specified for each network (see eg #817). There is a partial fix in devel, which solves this issue for the case that the networks addresses are explicitly specified for all defined addresses. However, two cases still fail:mac_address
is specified (either globally or per interface)To be more specific, current HEAD of podman-compose, using this configuration:
fails with:
This is caused by podman-compose parsing the compose file network config to
which in invalid.
With this PR, it executes
so the network arguments are
instead.
Note that I've added a test case for this issue in tests/test_podman_compose_networks.py. I'm not entirely sure this this is the correct way to integrate the tests, so please let me know if I should adjust that.
Closes #817