canonical / lxd

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

UDP Proxy device crashes #5487

Closed dang-khoa-tran closed 5 years ago

dang-khoa-tran commented 5 years ago

Required information

Issue description

Trying to host a teamspeak server on container. To do that I added a UDP proxy device to forward the port, and after a uncertain amount of time the proxy seems to crash. lsof -i -n | grep 9987 returns nothing

and the proxys log files contains following message: `panic: runtime error: racy use of timers

goroutine 36 [running]: time.startTimer(0xc0001c42d8) /build/lxd/parts/go/build/src/runtime/time.go:114 +0x2b time.(*Timer).Reset(0xc0001c42d0, 0x1a3185c5000, 0xc0001b6c00) /build/lxd/parts/go/build/src/time/sleep.go:130 +0x81 main.proxyCopy(0x1379ee0, 0xc00000e030, 0x1379ee0, 0xc0001ba028, 0x0, 0x0) /build/lxd/parts/lxd/go/src/github.com/lxc/lxd/lxd/main_forkproxy.go:778 +0x68b created by main.proxyCopy /build/lxd/parts/lxd/go/src/github.com/lxc/lxd/lxd/main_forkproxy.go:733 +0xb9e`

Steps to reproduce

Not sure how to reproduce. Installed and configured Teamspeak3 on the container, added the proxy devices and then connected with multiple clients on to the server. After some time it just disconnects.

Information to attach

Name: teamspeak Location: none Remote: unix:// Architecture: x86_64 Created: 2019/01/27 19:05 UTC Status: Running Type: persistent Profiles: default Pid: 63900 Ips: lo: inet 127.0.0.1 lo: inet6 ::1 eth0: inet 192.168.0.116 vethQT39LV eth0: inet6 fd42:3b06:828a:7517:216:3eff:fe16:a6be vethQT39LV eth0: inet6 fe80::216:3eff:fe16:a6be vethQT39LV Resources: Processes: 41 CPU usage: CPU usage (in seconds): 224 Memory usage: Memory (current): 95.78MB Memory (peak): 109.88MB Network usage: eth0: Bytes received: 6.12MB Bytes sent: 116.36kB Packets received: 56089 Packets sent: 1463 lo: Bytes received: 25.99MB Bytes sent: 25.99MB Packets received: 238899 Packets sent: 238899

Log:

lxc teamspeak 20190211163957.970 WARN conf - conf.c:lxc_map_ids:2970 - newuidmap binary is missing lxc teamspeak 20190211163957.970 WARN conf - conf.c:lxc_map_ids:2976 - newgidmap binary is missing lxc teamspeak 20190211163958.298 WARN conf - conf.c:lxc_map_ids:2970 - newuidmap binary is missing lxc teamspeak 20190211163958.298 WARN conf - conf.c:lxc_map_ids:2976 - newgidmap binary is missing lxc teamspeak 20190211163958.413 WARN conf - conf.c:lxc_setup_devpts:1641 - Invalid argument - Failed to unmount old devpts instance

architecture: x86_64 config: boot.autostart: "1" image.architecture: amd64 image.build: "20181129_07:43" image.description: Ubuntu bionic amd64 (20181129_07:43) image.distribution: ubuntu image.name: ubuntu-bionic-amd64-default-20181129_07:43 image.os: ubuntu image.release: bionic image.serial: "20181129_07:43" image.variant: default limits.cpu.allowance: 10% limits.memory: 1024MB limits.memory.enforce: hard volatile.base_image: 1bae1c087cedd4f169f5e3cd9e0a088116460a0bc0f2ea25741a6bf997634171 volatile.eth0.hwaddr: 00:16:3e:16:a6:be volatile.idmap.base: "0" volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]' volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]' volatile.last_state.power: RUNNING devices: FileTransfer: connect: tcp:192.168.0.116:30033 listen: tcp:192.168.178.138:30033 type: proxy ServerQuery: connect: tcp:192.168.0.116:10011 listen: tcp:192.168.178.138:10011 type: proxy Voice: connect: udp:192.168.0.116:9987 listen: udp:192.168.178.138:9987 type: proxy eth0: name: eth0 nictype: bridged parent: lxdbr0 type: nic root: path: / pool: default type: disk ephemeral: false profiles:

stgraber commented 5 years ago
and the proxys log files contains following message:
`panic: runtime error: racy use of timers

goroutine 36 [running]:
time.startTimer(0xc0001c42d8)
/build/lxd/parts/go/build/src/runtime/time.go:114 +0x2b
time.(*Timer).Reset(0xc0001c42d0, 0x1a3185c5000, 0xc0001b6c00)
/build/lxd/parts/go/build/src/time/sleep.go:130 +0x81
main.proxyCopy(0x1379ee0, 0xc00000e030, 0x1379ee0, 0xc0001ba028, 0x0, 0x0)
/build/lxd/parts/lxd/go/src/github.com/lxc/lxd/lxd/main_forkproxy.go:778 +0x68b
created by main.proxyCopy
/build/lxd/parts/lxd/go/src/github.com/lxc/lxd/lxd/main_forkproxy.go:733 +0xb9e`

@brauner apparently that timer stuff is your code, any idea what's going on?

alexpmorris commented 5 years ago

I may be having a similar problem with UDP in a container as this (lxd 3.10 via snap, ubuntu 18.04).

If I use socat as follows, the UDP connection seems to be rock solid: socat UDP-LISTEN:6050,fork UDP:10.120.31.34:6050

However, if I use the UDP proxy via LXD, as follows: lxc config device add mycontainer udp6050 proxy listen=udp:0.0.0.0:6050 connect=udp:127.0.0.1:6050 bind=host

While it works fine at first (albeit with a few more "request timed out" on ping requests) than socat, eventually the proxy fails completely and the only way I can get it going again is by removing and adding it back again. Unfortunately, I could not seem to find any appropriate log file entries to share in this case, but I will keep an eye out and add any relevant entries if I find some.

lxc config device remove mycontainer udp6050
lxc config device add mycontainer udp6050 proxy listen=udp:0.0.0.0:6050 connect=udp:127.0.0.1:6050 bind=host