Closed SAOPP closed 6 months ago
Seems I can't run headless at this server too:
go-hass-agent --terminal register --token TOKEN --server http://192.168.1.4:8123
go-hass-agent: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by go-hass-agent)
go-hass-agent: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by go-hass-agent)
I expected this, and at the same time I thought that I would not have any problems with the container.
Another instance with fresh debian bookworm, the situation with registration the next:
12:17PM ERR Unable to open log file for writing. error="open /home/gouser/.local/state/go-hass-app.log: no such file or directory"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xd24933]
goroutine 1 [running, locked to thread]:
github.com/joshuar/go-hass-agent/internal/agent.(*Agent).Register(0xc0000bba60)
/usr/src/go-hass-agent/internal/agent/agent.go:156 +0x213
github.com/joshuar/go-hass-agent/cmd.glob..func1(0xc00015ed00?, {0xf4cfd0?, 0x4?, 0xf4cfd4?})
/usr/src/go-hass-agent/cmd/register.go:35 +0xed
github.com/spf13/cobra.(*Command).execute(0x1746480, {0xc000510680, 0x4, 0x4})
/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xaa3
github.com/spf13/cobra.(*Command).ExecuteC(0x1746760)
/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/joshuar/go-hass-agent/cmd.Execute()
/usr/src/go-hass-agent/cmd/root.go:53 +0x1a
main.main()
/usr/src/go-hass-agent/main.go:29 +0xf
What am I doing wrong?
Hey @SAOPP thanks for trying out Go Hass Agent! Those are some funky errors. Running the agent in a container is a bit rough at the moment.
I can see the cause of the nil pointer crash in https://github.com/joshuar/go-hass-agent/issues/87#issuecomment-1910092072. It's due to the way I was building inside the image including an empty internal/agent/config/VERSION
file. This file should contain the version of the agent and is embedded when building. The code wasn't expecting it to be empty. I can fix that in the next release.
The other error in https://github.com/joshuar/go-hass-agent/issues/87#issue-2099993859 is a bit trickier. I'll have to bring up a VM to do some testing and see if I can reproduce and to be able to debug it. That might take some time.
Are you able to run the agent directly, not within a container, on your server?
Welp, I think I've fixed the issues with the container build... Can you try with version ed4d3bef0275f78d96376d96e083c7260c82ac2c that is up on the ghcr.io repo?
The following commands for registering and running work for me on a Ubuntu 20.04 VM in VirtualBox:
Register:
docker run --rm --hostname go-hass-agent-container \
--network host \
--volume go-hass-agent:/home/gouser \
ghcr.io/joshuar/go-hass-agent:ed4d3bef0275f78d96376d96e083c7260c82ac2c --debug register \
--server someserver \
--token sometoken
Run:
docker run --security-opt apparmor:unconfined --hostname go-hass-agent-container --name my-go-hass-agent \
--network host \
--volume go-hass-agent:/home/gouser \
--volume /proc:/host/proc:ro --volume /sys:/host/sys:ro \
--volume /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro \
--volume /run/user/1000/bus:/run/user/1000/bus:ro \
ghcr.io/joshuar/go-hass-agent:ed4d3bef0275f78d96376d96e083c7260c82ac2c --debug
Note I'm using a Docker volume rather than a bind mount for the agent config. To use a bind mount might require additional options and/or configuration on the host.
Unfortunately, while I've passed in the D-Bus volumes, sensors based on D-Bus don't work in the container. I am still trying to understand how to get D-Bus working inside a container. If you have any ideas, please let me know!
Hi! Thanks for the reply.
Are you able to run the agent directly, not within a container, on your server?
Yes, I'm has mention 'bout this already ova here: https://github.com/joshuar/go-hass-agent/issues/87#issuecomment-1909936975
I will try what are u propose above, and give some feedback of da result soon. Thanks.
So, this the first try:
docker run --rm --hostname server-agent --network host --volume homeassistant-agent:/home/gouser ghcr.io/joshuar/go-hass-agent:ed4d3bef0275f78d96376d96e083c7260c82ac2c --debug register --server http://192.168.1.4:8123 --token to_ke_n
...
runtime/cgo: pthread_create failed: Operation not permitted
SIGABRT: abort
PC=0x7f39388e3d3c m=0 sigcode=18446744073709551610
goroutine 0 [idle]:
runtime: g 0: unknown pc 0x7f39388e3d3c
stack: frame={sp:0x7ffd21454f90, fp:0x0} stack=[0x7ffd20c56410,0x7ffd21455420)
0x00007ffd21454e90: 0x0000000000000000 0x0000ffff00001fa0
0x00007ffd21454ea0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454eb0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ec0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ed0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ee0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ef0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f00: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f10: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f20: 0x00007f3938a2c703 0x00007f3938a2c703
0x00007ffd21454f30: 0x2525252525252525 0x2525252525252525
0x00007ffd21454f40: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f50: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f60: 0x00000000000000ff 0x0000000000000000
0x00007ffd21454f70: 0x0000000000000000 0x0000000000f926f7
0x00007ffd21454f80: 0x0000000000000003 0x00007f39388e3d2e
0x00007ffd21454f90: <0x7020746f6e206e6f 0xce645d3f9f2da600
0x00007ffd21454fa0: 0x0000000000000006 0x00007f3938713740
0x00007ffd21454fb0: 0x00007ffd21455260 0x0000000000000000
0x00007ffd21454fc0: 0x0000000001f2ee80 0x00007f3938894f32
0x00007ffd21454fd0: 0x00007f3938a2ce70 0x00007f393887f472
0x00007ffd21454fe0: 0x0000000000000020 0x0000000000000006
0x00007ffd21454ff0: 0x0000000001f80b4a 0x0000000000000000
0x00007ffd21455000: 0x0000000000f94124 0x0000000000000004
0x00007ffd21455010: 0x0000000000000000 0x0000000000000000
0x00007ffd21455020: 0x0000000000000000 0x0000000001f2ee80
0x00007ffd21455030: 0x0000000000000006 0x00007f39388daee9
0x00007ffd21455040: 0x00007f3938a2c680 0x00007f39388db2f3
0x00007ffd21455050: 0x00007f3938a2c680 0x000000000000000a
0x00007ffd21455060: 0x00007f3938713740 0x00007f39388d687a
0x00007ffd21455070: 0x00007f3938a2c840 0xce645d3f9f2da600
0x00007ffd21455080: 0x00007f3938a2c840 0x00007f3938a2c840
runtime: g 0: unknown pc 0x7f39388e3d3c
stack: frame={sp:0x7ffd21454f90, fp:0x0} stack=[0x7ffd20c56410,0x7ffd21455420)
0x00007ffd21454e90: 0x0000000000000000 0x0000ffff00001fa0
0x00007ffd21454ea0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454eb0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ec0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ed0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ee0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454ef0: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f00: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f10: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f20: 0x00007f3938a2c703 0x00007f3938a2c703
0x00007ffd21454f30: 0x2525252525252525 0x2525252525252525
0x00007ffd21454f40: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f50: 0x0000000000000000 0x0000000000000000
0x00007ffd21454f60: 0x00000000000000ff 0x0000000000000000
0x00007ffd21454f70: 0x0000000000000000 0x0000000000f926f7
0x00007ffd21454f80: 0x0000000000000003 0x00007f39388e3d2e
0x00007ffd21454f90: <0x7020746f6e206e6f 0xce645d3f9f2da600
0x00007ffd21454fa0: 0x0000000000000006 0x00007f3938713740
0x00007ffd21454fb0: 0x00007ffd21455260 0x0000000000000000
0x00007ffd21454fc0: 0x0000000001f2ee80 0x00007f3938894f32
0x00007ffd21454fd0: 0x00007f3938a2ce70 0x00007f393887f472
0x00007ffd21454fe0: 0x0000000000000020 0x0000000000000006
0x00007ffd21454ff0: 0x0000000001f80b4a 0x0000000000000000
0x00007ffd21455000: 0x0000000000f94124 0x0000000000000004
0x00007ffd21455010: 0x0000000000000000 0x0000000000000000
0x00007ffd21455020: 0x0000000000000000 0x0000000001f2ee80
0x00007ffd21455030: 0x0000000000000006 0x00007f39388daee9
0x00007ffd21455040: 0x00007f3938a2c680 0x00007f39388db2f3
0x00007ffd21455050: 0x00007f3938a2c680 0x000000000000000a
0x00007ffd21455060: 0x00007f3938713740 0x00007f39388d687a
0x00007ffd21455070: 0x00007f3938a2c840 0xce645d3f9f2da600
0x00007ffd21455080: 0x00007f3938a2c840 0x00007f3938a2c840
goroutine 1 [running]:
runtime.systemstack_switch()
/usr/local/go/src/runtime/asm_amd64.s:474 +0x8 fp=0xc000054740 sp=0xc000054730 pc=0x473a48
runtime.main()
/usr/local/go/src/runtime/proc.go:169 +0x6d fp=0xc0000547e0 sp=0xc000054740 pc=0x4422cd
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc0000547e8 sp=0xc0000547e0 pc=0x475a21
rax 0x0
rbx 0x1
rcx 0x7f39388e3d3c
rdx 0x6
rdi 0x1
rsi 0x1
rbp 0x7f3938713740
rsp 0x7ffd21454f90
r8 0x0
r9 0x73
r10 0x8
r11 0x246
r12 0x6
r13 0x0
r14 0x1f2ee80
r15 0x6
rip 0x7f39388e3d3c
rflags 0x246
cs 0x33
fs 0x0
gs 0x0
Next I had tried start my container in privileged mode:
docker run --rm --privileged --network host --volume homeassistant-agent:/home/gouser ghcr.io/joshuar/go-hass-agent:ed4d3bef0275f78d96376d96e083c7260c82ac2c --debug register --server http://192.168.1.4:8123 --token to_ke_n
...
6:56PM DBG Debug logging enabled.
6:56PM ERR Unable to open log file for writing. error="open /home/gouser/.local/state/go-hass-app.log: no such file or directory"
6:56PM DBG No config directory, creating new one. directory=/home/gouser/.config/com.github.joshuar.go-hass-agent
6:56PM INF Registration required. Starting registration process.
6:56PM DBG Validating config.
6:56PM INF Successfully registered agent.
6:56PM DBG Stopping agent.
And I see my server in integration:
Now I’ll try to run the container, and most likely also in privileged mode...
And here is my stack:
version: '3.9'
services:
ha-agent:
container_name: homeassistant-agent
image: ghcr.io/joshuar/go-hass-agent:ed4d3bef0275f78d96376d96e083c7260c82ac2c
network_mode: host
privileged: true
environment:
- TZ=Europe/Kiev
volumes:
- /home/docker_storage/homeassistant-agent:/home/gouser
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro
- /run/user/1000/bus:/run/user/1000/bus:ro
restart: unless-stopped
All done! Thanks homie! :+1:
Oh nice! That is awesome that you got it working! I'll have to look into some of the additional steps you did, that's different than what I needed. I'm also using Podman, so might be some Docker <-> Podman differences.
I think I'll close this issue for now though as it is working for you. I'll keep working away at improving the container support. If you still are having issues, feel free to re-open this issue.
Thanks again for trying out the agent!
@joshuar Hi! :smile:
I noticed today that the agent was stopped, I tried to start it and got an error, I didn't look into it much... I updated the agent and saw the following in the log:
Okay, let's re-created token and register again... But this is what I get when I try to register an agent on my instance:
docker run --rm --privileged --network host --volume /docker/homeassistant-agent:/home/gouser ghcr.io/joshuar/go-hass-agent:latest register --server http://localhost:8123 --token TOKEN
5:00PM DBG Setting language to [].
5:00PM TRC Starting Fyne UI loop.
2024/05/13 17:00:26 PlatformError: X11: The DISPLAY environment variable is missing
panic: NotInitialized: The GLFW library is not initialized
goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.acceptError({0x0, 0x0, 0xc000421008?})
/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20240306074159-ea2d69986ecb/error.go:177 +0x170
github.com/go-gl/glfw/v3.3/glfw.panicError(...)
/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20240306074159-ea2d69986ecb/error.go:188
github.com/go-gl/glfw/v3.3/glfw.CreateStandardCursor(0xeaa560?)
/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20240306074159-ea2d69986ecb/input.go:512 +0x3a
fyne.io/fyne/v2/internal/driver/glfw.initCursors()
/go/pkg/mod/fyne.io/fyne/v2@v2.4.5/internal/driver/glfw/window_desktop.go:49 +0x59
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).initGLFW.func1()
/go/pkg/mod/fyne.io/fyne/v2@v2.4.5/internal/driver/glfw/loop_desktop.go:20 +0x47
sync.(*Once).doSlow(0x486c13?, 0xa6463ce65c59?)
/usr/local/go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
/usr/local/go/src/sync/once.go:65
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).initGLFW(0xfe502a?)
/go/pkg/mod/fyne.io/fyne/v2@v2.4.5/internal/driver/glfw/loop_desktop.go:13 +0x3f
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).runGL(0xc000549b00)
/go/pkg/mod/fyne.io/fyne/v2@v2.4.5/internal/driver/glfw/loop.go:122 +0x88
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).Run(0xc000549b00)
/go/pkg/mod/fyne.io/fyne/v2@v2.4.5/internal/driver/glfw/driver.go:169 +0x6f
fyne.io/fyne/v2/app.(*fyneApp).Run(0xc000164150?)
/go/pkg/mod/fyne.io/fyne/v2@v2.4.5/app/app.go:71 +0x31
github.com/joshuar/go-hass-agent/internal/agent/ui/fyneUI.(*fyneUI).Run(0xc000012618, 0xc0001024e0)
/usr/src/go-hass-agent/internal/agent/ui/fyneUI/fyneUI.go:59 +0xb9
github.com/joshuar/go-hass-agent/internal/agent.(*Agent).Register(0xc000023020, {0x11a0350, 0xc00003e440})
/usr/src/go-hass-agent/internal/agent/agent.go:135 +0xc5
main.(*RegisterCmd).Run(0x1f98948, 0xc000022f60)
/usr/src/go-hass-agent/main.go:131 +0x20d
reflect.Value.call({0xeb35e0?, 0x1f98948?, 0xfc8000?}, {0xfcb03c, 0x4}, {0xc000454a68, 0x1, 0x1?})
/usr/local/go/src/reflect/value.go:596 +0xca6
reflect.Value.Call({0xeb35e0?, 0x1f98948?, 0xc000421b70?}, {0xc000454a68?, 0xfc8000?, 0x0?})
/usr/local/go/src/reflect/value.go:380 +0xb9
github.com/alecthomas/kong.callFunction({0xeb35e0?, 0x1f98948?, 0xc000421ce8?}, 0xc00001fe00)
/go/pkg/mod/github.com/alecthomas/kong@v0.9.0/callbacks.go:98 +0x45a
github.com/alecthomas/kong.(*Context).RunNode(0xc000549900, 0xc00047cff0, {0xc000421f10, 0x1, 0xf11840?})
/go/pkg/mod/github.com/alecthomas/kong@v0.9.0/context.go:774 +0x80e
github.com/alecthomas/kong.(*Context).Run(0xe480e0?, {0xc000421f10?, 0xc000421f20?, 0xc?})
/go/pkg/mod/github.com/alecthomas/kong@v0.9.0/context.go:799 +0x132
main.main()
/usr/src/go-hass-agent/main.go:200 +0x1f5
Oh dear, I imagine this will partly be due to https://github.com/joshuar/go-hass-agent/commit/e93f7335056b0ebb445b92dd3764b3ee472a54f8, where I've migrated the command-line parsing to a different package. For now, I'd recommand sticking to the images tagged with a version rather than latest
, the latter which may very well contain breaking changes. The latest version is v9.0.0
, can you try with that image? i.e.:
docker run --rm --privileged --network host --volume /docker/homeassistant-agent:/home/gouser ghcr.io/joshuar/go-hass-agent:v9.0.0 register --server http://localhost:8123 --token TOKEN
This is still a bug that will likely affect future versions, so thanks for reporting. I will look into fixing it!
Yep! It's works.
Great! Thanks for circling back, I'll close this off for now.
Hello!
This situation is present with first step of registration of agent and the next with the container also.
Ubuntu Focal server and Docker version 20.10.9, build c2ea9bc.
Registration step:
docker run --rm --network host --volume /home/docker_storage/homeassistant-agent:/home/gouser ghcr.io/joshuar/go-hass-agent register --server http://homeassistant:8123 --token mytoken
Compose: