canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.39k stars 929 forks source link

Snapped LXD 6.1 fail to create ovn network (snap path appending /var/lib/snapd/hostfs to network.ovn.northbound_connection) #13949

Open Fred78290 opened 3 months ago

Fred78290 commented 3 months ago

Required information

Issue description

Unable to setup OVN network, the command lxc network create ovntest --type=ovn network=lxdbr0 fail returning

Error: Failed to run: ovn-nbctl --timeout=10 --db unix:/var/lib/snapd/hostfs/run/ovn/ovnsb_db.sock --wait=sb ha-chassis-group-add lxd-net7: exit status 1 (ovn-nbctl: unix:/var/lib/snapd/hostfs/run/ovn/ovnsb_db.sock: database connection failed ()) The reason is snapped lxd append /var/lib/snapd/hostfs to ovn socket path

Steps to reproduce

  1. create an instance with multipass: multipass lxd-test launch -c 4 -m 8G -d 40G
  2. install snap lxd: sudo snap install lxd --channel=6.1/stable
  3. lxd init all default except: pool use dir storage
  4. install ovn as described in the documentation Set up a standalone OVN network
  5. set lxd config: lxc config set network.ovn.northbound_connection=unix:/var/run/ovn/ovnnb_db.sock
  6. create ovn network: lxc network create ovntest --type=ovn network=lxdbr0

Problem in the source location

File: ./lxd/network/openvswitch/ovn.go Line: 305 Method: func (o *OVN) xbctl(southbound bool, extraArgs ...string) (string, error) { Wrong code: if strings.HasPrefix(dbAddr, "unix:") { dbAddr = fmt.Sprintf("unix:%s", shared.HostPathFollow(strings.TrimPrefix(dbAddr, "unix:"))) }

shared.HostPathFollow(...) detect lxd snapped and append /var/lib/snapd/hostfs path

tomponline commented 3 months ago

@Fred78290 out of interest, why are you setting network.ovn.northbund_connection, as it defaults to unix:/var/run/ovn/ovnnb_db.sock anyway: https://documentation.ubuntu.com/lxd/en/latest/server/#server-miscellaneous:network.ovn.northbound_connection

tomponline commented 3 months ago

LXD appending /var/lib/snapd/hostfs/ to the supplied path is correct in order to access files outside of the snap package.

tomponline commented 3 months ago

This part is confusing me:

ovn-nbctl --timeout=10 --db unix:/var/lib/snapd/hostfs/run/ovn/ovnsb_db.sock

Why is ovn-nbctl (which manages the northbound database) being passed the path for the OVN southbound database (ovnsb_db.sock)?

Can you try lxc config unset network.ovn.northbound_connection and then also provide the output of:

sudo ovs-vsctl get open_vswitch . external_ids:ovn-remote

Which is where LXD gets the address of the OVN southbound database.

tomponline commented 3 months ago

Have you followed the setup guide here btw?

https://documentation.ubuntu.com/lxd/en/latest/howto/network_ovn_setup/#set-up-a-standalone-ovn-network

Fred78290 commented 3 months ago

@tomponline

After exec lxc config unset network.ovn.northbound_connection i'm able to run lxc network create ovntest --type=ovn network=lxdbr0 succesfully.

https://documentation.ubuntu.com/lxd/en/latest/howto/network_ovn_setup/#set-up-a-standalone-ovn-network

Yes I followed the setup guide.

Fred78290 commented 3 months ago

sudo ovs-vsctl get open_vswitch . external_ids:ovn-remote

got: unix:/var/run/ovn/ovnsb_db.sock

Fred78290 commented 3 months ago

@tomponline

This part is confusing me:

ovn-nbctl --timeout=10 --db unix:/var/lib/snapd/hostfs/run/ovn/ovnsb_db.sock

It's returned as error message the executed sub command.

I have setted the network.ovn.northbound_connection explicitly to network.ovn.northbound_connection because in my real environment I share ovn system beetwen openstack and LXd on the same machine and the connection is SSL and lxd won't connect to ovn when I fill SSL infos and remote IP but it connect thru the unix socket (default value). and I'm looking what is the problem.

It's mean actually setting the network.ovn.northbound_connection to something is not working.

tomponline commented 3 months ago

because in my real environment I share ovn system beetwen openstack and LXd on the same machine

I've never tried that, but its not supported, so you might be unexpected conflicts/problems doing that.

Fred78290 commented 3 months ago

I've never tried that, but its not supported, so you might be unexpected conflicts/problems doing that.

Has unexpected it's work but without setting network.ovn.northbound_connection.

On the same machine I run multipass, vmware workstation pro, openstack, devstack and lxd without conflicts.

tomponline commented 3 months ago

@boltmark as you're going to start looking into OVN uplink VLAN feature, please could you take a look at recreating this issue first as you setup your OVN environment? Thanks