Skip to content
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

improve compose network_mode error message #38

Closed
trijpstra-fourlights opened this issue Dec 18, 2023 · 1 comment · Fixed by #42
Closed

improve compose network_mode error message #38

trijpstra-fourlights opened this issue Dec 18, 2023 · 1 comment · Fixed by #42
Milestone

Comments

@trijpstra-fourlights
Copy link

trijpstra-fourlights commented Dec 18, 2023

Hi, thanks for your hard work on this!

I noticed that the network_mode: 'service:xyz' is not supported, but network_mode: 'container:xyz' is.

The difference between the two:

* container: shares the networking stack and IP address of an existing container
* service: connects to the network of an existing service to enable communication, but containers maintain separate IP addresses and networking stacks

The service: network mode is useful for inter-container communication within a service. The container: mode can be used to join the networking namespace of an infrastructure container like a proxy or router to share its networking stack.

So service: keeps containers more isolated and portable, while container: ties them more directly to another container's network configuration.

I used the following patch to build the PKGBUILD with support for service:xyz and that seems to work.

diff --color --unified --recursive --text package.orig/podlet-0.2.2/src/cli/container/quadlet.rs package.new/podlet-0.2.2/src/cli/container/quadlet.rs
--- package.orig/podlet-0.2.2/src/cli/container/quadlet.rs      2023-12-16 00:32:56.000000000 +0100
+++ package.new/podlet-0.2.2/src/cli/container/quadlet.rs       2023-12-17 17:08:41.788103927 +0100
@@ -449,6 +449,7 @@
             .map(|mode| match mode.as_str() {
                 "bridge" | "host" | "none" => Ok(mode),
                 s if s.starts_with("container") => Ok(mode),
+                s if s.starts_with("service") => Ok(mode),
                 _ => Err(eyre::eyre!("network_mode `{mode}` is unsupported")),
             })
             .transpose()?

which can be applied by adding the following to the PKGBUILD

// ...

source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz" "add_network_mode_service.patch")
sha256sums=('70834d2143c2c06059cb424f9cc7cff0ef48c77d3a5938c4b97ecf257c3ff4f6'
            'eb4d9a538fbc03c5804ce94761d8a1950a05df4457813568c79783c4e511b91f')

// ....

prepare() {
  cd "$pkgname-$pkgver"
  patch --forward --strip=2 --input="${srcdir}/add_network_mode_service.patch"
}

// ...

I'll try to create a PR later

@k9withabone
Copy link
Member

As discussed in #39, I think the best way to handle the service network_mode is to provide a better error message suggesting the use of the container network_mode and linking to the podman docs. Other suggestions are welcome.

@k9withabone k9withabone added this to the v0.2.3 milestone Dec 20, 2023
@k9withabone k9withabone changed the title network_mode: service:xyz is unsupported improve compose network_mode error message Dec 22, 2023
k9withabone added a commit that referenced this issue Dec 22, 2023
- Support all `podman run --network` values for service `network_mode`
- Improve error message for unsupported values, link to the podman docs

Fixes: #38
@k9withabone k9withabone linked a pull request Dec 22, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants