containers / netavark

Container network stack
Apache License 2.0
515 stars 83 forks source link

Append file/directory name to missing file/directory error (suggestion) #547

Open ancebfer opened 1 year ago

ancebfer commented 1 year ago

After reporting a problem with podman-compose (https://github.com/containers/podman-compose/issues/609) that outputs error:

Error: unable to start container 945f51fa502fc70dfc60ea2b05a2497d6fc0b09506641eadd68cd7e1d6b740a7: netavark: No such file or directory (os error 2)

I have found with strace that the missing file was iptables. Debian podman package (https://packages.debian.org/bookworm/podman) only suggests iptables package therefore it is not installed by default.

My suggestion is to append the missing file/directory name to the netavark error for easier debugging.

Joulinar commented 1 year ago

better to make iptables a dependency package instead of optional.

Luap99 commented 1 year ago

My suggestion is to append the missing file/directory name to the netavark error for easier debugging.

I agree, @ancebfer do you want to open a PR fix it?

better to make iptables a dependency package instead of optional.

That is up to your packager and not something we can fix upstream.

ancebfer commented 1 year ago

Looking at the source code I guess that the error comes from "setup.rs":

        debug!("{:?}", "Setting up...");
        let network_options = network::types::NetworkOptions::load(input_file)?;

        let firewall_driver = match firewall::get_supported_firewall_driver() {
            Ok(driver) => driver,
            Err(e) => return Err(e),
        };

But unfortunately I'm not enough familiarized with Rust syntax to propose a PR fix.

My general suggestion is to include the name of the file/directory in all errors triggered by a missing file/directory. I think that missing "iptables" is not the only cause that can trigger a missing file/directory error. Getting the name of the file/directory on these errors can help to identify and solve them very fast.

wrobelda commented 1 year ago

better to make iptables a dependency package instead of optional.

Well, why not both? Because I am actually facing this very exact issue, except iptables is installed, and so is netavark.

Quacky2200 commented 1 year ago

I had a similar problem to @wrobelda where iptables/netavark is installed but podman falls over. I found out that this was an issue with my Bash environment in Debian due to running as root through su root - since your bash environment PATH differs depending on a root or normal user (this is why you can't execute some commands like adduser in /usr/sbin), the PATH difference is implemented in /etc/profile. You can fix this running su root -l which runs a login allowing the new bash shell profile to be picked up or it's probably best installing/setting up sudo.

Sadly I discovered this profile issue earlier and would normally use sudo su on Ubuntu so I was caught off-guard by this error and only remembered it when strace showed access to /usr/bin/iptables and /bin/iptables failing despite being installed and eventually putting the 2 together. Podman does work for me now that I've fixed my bash profile (oops)...

Hopefully this helps someone in future. It's an easy mistake to make.

Refers to containers/podman#16956, containers/podman#16958