{"action":"created","issue":{"url":"https://api.github.com/repos/lxc/lxd/issues/1953","repository_url":"https://api.github.com/repos/lxc/lxd","labels_url":"https://api.github.com/repos/lxc/lxd/issues/1953/labels{/name}","comments_url":"https://api.github.com/repos/lxc/lxd/issues/1953/comments","events_url":"https://api.github.com/repos/lxc/lxd/issues/1953/events","html_url":"https://github.com/lxc/lxd/issues/1953","id":151315379,"number":1953,"title":"Containers initialized before openvswitch service starts","user":{"login":"nick4u","id":5399008,"avatar_url":"https://avatars.githubusercontent.com/u/5399008?v=3","gravatar_id":"","url":"https://api.github.com/users/nick4u","html_url":"https://github.com/nick4u","followers_url":"https://api.github.com/users/nick4u/followers","following_url":"https://api.github.com/users/nick4u/following{/other_user}","gists_url":"https://api.github.com/users/nick4u/gists{/gist_id}","starred_url":"https://api.github.com/users/nick4u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nick4u/subscriptions","organizations_url":"https://api.github.com/users/nick4u/orgs","repos_url":"https://api.github.com/users/nick4u/repos","events_url":"https://api.github.com/users/nick4u/events{/privacy}","received_events_url":"https://api.github.com/users/nick4u/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-27T07:16:56Z","updated_at":"2016-04-27T07:42:04Z","closed_at":null,"body":"System: Ubuntu 16.04 LTS\r\n```\r\n#lxc info\r\napicompat: 0\r\nauth: trusted\r\nenvironment:\r\n  addresses: []\r\n  architectures:\r\n  - x86_64\r\n  - i686\r\n  certificate: |\r\n    -----BEGIN CERTIFICATE-----\r\n<data>\r\n    -----END CERTIFICATE-----\r\n  driver: lxc\r\n  driverversion: 2.0.0\r\n  kernel: Linux\r\n  kernelarchitecture: x86_64\r\n  kernelversion: 4.4.0-21-generic\r\n  server: lxd\r\n  serverpid: 2481\r\n  serverversion: 2.0.0\r\n  storage: zfs\r\n  storageversion: \"5\"\r\nconfig:\r\n  storage.zfs_pool_name: lxd\r\npublic: false\r\n\r\n```\r\n\r\nI am using openvswitch \r\n```\r\n#ovs-vsctl -V\r\novs-vsctl (Open vSwitch) 2.5.0\r\nCompiled Mar 10 2016 14:16:49\r\nDB Schema 7.12.1\r\n```\r\n\r\nMy containers have config like :\r\n```\r\n# lxc config show ct04\r\nname: ct04\r\nprofiles:\r\n- small\r\nconfig:\r\n  boot.autostart: \"true\"\r\n  user.ens.p: 8i\r\n  user.ens.x: \"12.2\"\r\n  volatile.base_image: 4525094c3dd2c58b0a60feac5e72963942062ea74f2ee08bcba13a7b448712e4\r\n  volatile.eth0.hwaddr: 00:16:3e:3c:e8:b0\r\n  volatile.eth0.name: eth0\r\n  volatile.last_state.idmap: '[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":165536,\"Nsid\":0,\"Maprange\":65536},{\"Isuid\":false,\"Isgid\":true,\"Hostid\":165536,\"Nsid\":0,\"Maprange\":65536}]'\r\ndevices:\r\n  eth0:\r\n    host_name: vlan100ct04\r\n    limits.max: 1000kbit\r\n    nictype: bridged\r\n    parent: vlan100\r\n    type: nic\r\n  root:\r\n    limits.read: 10MB\r\n    limits.write: 10MB\r\n    path: /\r\n    type: disk\r\nephemeral: false\r\n```\r\n\r\nnot all CT's are started after reboot and I think the reason for it is:\r\n```\r\nApr 27 08:46:07 ubuntu ovs-vsctl[2684]: ovs|00001|vsctl|INFO|Called as ovs-vsctl add-port vlan100 vlan100ct04\r\nApr 27 08:46:07 ubuntu ovs-vsctl[2684]: ovs|00002|db_ctl_base|ERR|unix:/var/run/openvswitch/db.sock: database connection failed (No such file or directory)\r\nApr 27 08:46:07 ubuntu ovs-ctl[2025]:  * Starting ovsdb-server\r\nApr 27 08:46:07 ubuntu ovs-vsctl[3210]: ovs|00001|vsctl|INFO|Called as ovs-vsctl --no-wait -- init -- set Open_vSwitch . db-version=7.12.1\r\nApr 27 08:46:07 ubuntu ovs-vsctl[3296]: ovs|00001|vsctl|INFO|Called as ovs-vsctl --no-wait set Open_vSwitch . ovs-version=2.5.0 \"external-ids:system-id=\\\"21299820-5e7b-448c-bdf1-d990d011969d\\\"\" \"system-type=\\\"Ubuntu\\\"\" \"s\r\nApr 27 08:46:07 ubuntu ovs-ctl[2025]:  * Configuring Open vSwitch system IDs\r\n\r\n```\r\n\r\nIt seams lxd service has no dependency with openvswitch and tries to start container before vswitch is ready\r\n\r\n```\r\n            lxc 20160427084607.211 INFO     lxc_start - start.c:lxc_init:488 - 'ct04' is initialized\r\n            lxc 20160427084607.211 INFO     lxc_confile - confile.c:config_idmap:1498 - read uid map: type u nsid 0 hostid 165536 range 65536\r\n            lxc 20160427084607.211 INFO     lxc_confile - confile.c:config_idmap:1498 - read uid map: type g nsid 0 hostid 165536 range 65536\r\n            lxc 20160427084607.219 INFO     lxc_confile - confile.c:config_idmap:1498 - read uid map: type u nsid 0 hostid 165536 range 65536\r\n            lxc 20160427084607.219 INFO     lxc_confile - confile.c:config_idmap:1498 - read uid map: type g nsid 0 hostid 165536 range 65536\r\n            lxc 20160427084607.225 DEBUG    lxc_start - start.c:__lxc_start:1302 - Not dropping cap_sys_boot or watching utmp\r\n            lxc 20160427084607.225 INFO     lxc_start - start.c:resolve_clone_flags:999 - Cloning a new user namespace\r\n            lxc 20160427084607.344 ERROR    lxc_conf - conf.c:instantiate_veth:2594 - failed to attach 'vlan100ct04' to the bridge 'vlan100': Operation not permitted\r\n            lxc 20160427084607.359 ERROR    lxc_conf - conf.c:lxc_create_network:2871 - failed to create netdev\r\n            lxc 20160427084607.359 ERROR    lxc_start - start.c:lxc_spawn:1066 - failed to create the network\r\n            lxc 20160427084607.359 ERROR    lxc_start - start.c:__lxc_start:1329 - failed to spawn 'ct04'\r\n            lxc 20160427084607.359 INFO     lxc_conf - conf.c:run_script_argv:367 - Executing script '/usr/share/lxcfs/lxc.reboot.hook' for container 'ct04', config section 'lxc'\r\n            lxc 20160427084607.871 INFO     lxc_conf - conf.c:run_script_argv:367 - Executing script '/usr/bin/lxd callhook /var/lib/lxd 9 stop' for container 'ct04', config section 'lxc'\r\n            lxc 20160427084608.019 WARN     lxc_commands - commands.c:lxc_cmd_rsp_recv:172 - command get_cgroup failed to receive response\r\n            lxc 20160427084608.019 WARN     lxc_commands - commands.c:lxc_cmd_rsp_recv:172 - command get_cgroup failed to receive response\r\n            lxc 20160427084608.019 WARN     lxc_commands - commands.c:lxc_cmd_rsp_recv:172 - command get_cgroup failed to receive response\r\n            lxc 20160427084608.025 INFO     lxc_confile - confile.c:config_idmap:1498 - read uid map: type u nsid 0 hostid 165536 range 65536\r\n```\r\nOf course when I later manualy do \"lxc start ct04\" everything is just fine and CT start\r\n\r\nAt my dev/test env 1 of 3 CTs fail to start due to this I guess\r\nAt prod env with is much faster 4 CTs are spawned to fast.\r\n\r\nI would like to add and test systemd dependency (Requires=openvswitch-switch and After=openvswitch-switch) but I am not sure to which one?\r\n\r\n```\r\n  lxd-bridge.service                                                                                                        loaded active exited    LXD - network bridge\r\n  lxd-containers.service                                                                                                    loaded active exited    LXD - container startup/shutdown\r\n  lxd.service                                                                                                               loaded active running   LXD - main daemon\r\n  lxd.socket                                                                                                                loaded active running   LXD - unix socket\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/lxc/lxd/issues/comments/214995798","html_url":"https://github.com/lxc/lxd/issues/1953#issuecomment-214995798","issue_url":"https://api.github.com/repos/lxc/lxd/issues/1953","id":214995798,"user":{"login":"nick4u","id":5399008,"avatar_url":"https://avatars.githubusercontent.com/u/5399008?v=3","gravatar_id":"","url":"https://api.github.com/users/nick4u","html_url":"https://github.com/nick4u","followers_url":"https://api.github.com/users/nick4u/followers","following_url":"https://api.github.com/users/nick4u/following{/other_user}","gists_url":"https://api.github.com/users/nick4u/gists{/gist_id}","starred_url":"https://api.github.com/users/nick4u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nick4u/subscriptions","organizations_url":"https://api.github.com/users/nick4u/orgs","repos_url":"https://api.github.com/users/nick4u/repos","events_url":"https://api.github.com/users/nick4u/events{/privacy}","received_events_url":"https://api.github.com/users/nick4u/received_events","type":"User","site_admin":false},"created_at":"2016-04-27T07:42:04Z","updated_at":"2016-04-27T07:42:04Z","body":"I've added to /etc/systemd/system/multi-user.target.wants/lxd-containers.service:\r\nAfter=lxd.socket lxd.service **openvswitch-switch.service**\r\n\r\nand after 3 reboots it looks like it did the work as all CTs start (tested only on dev env as I can't reboot prod now)\r\n\r\nIf this is indeed needed fix than I think shipped service definitions should safely be altered to include After openvswitch-switch.service\r\n"}}