Closed nataloko closed 3 months ago
I've been playing around a bit more and I think I've found the source:
This bad behaviour only happens when I remove Gladys' connection to Docker socket:
/var/run/docker.sock:/var/run/docker.sock
When I add it back everything works fine again.
In my particular installation I'm handling containers externally so I don't understand why Gladys needs access to the Docker socket?
@nataloko Hey ! Thanks for your bug report.
There might be a bug indeed.
This is the file initializing the MQTT integration => https://github.com/GladysAssistant/Gladys/blob/master/server/services/mqtt/lib/init.js
I've tried on my side, and for now I can't reproduce the bug...
This is my configuration :
{
mqttUrl: 'mqtt://localhost',
mqttUsername: null,
mqttPassword: null,
useEmbeddedBroker: false,
dockerBased: false,
brokerContainerAvailable: false,
networkModeValid: false,
mosquittoVersion: null
}
When restarting, MQTT is connected with success
Did you do a "Gladys based installation" before connecting to an external broker?
Hi Pierre,
I started to see this on a fresh installation. A difference on my setup is that I've using a user/password to connect to the mqtt broker.
Also I've just checked the locker logs I see this warning when Gladys starts without the docker.sock link (it doesn't show when I add the link back)
2024-05-18T09:21:13+0100 <warn> service.start.js:44 (Service.start) Unable to start service mqtt PlatformNotCompatible [Error]: SYSTEM_NOT_RUNNING_DOCKER
at System.getNetworkMode (/src/server/lib/system/system.getNetworkMode.js:12:11)
at MqttHandler.checkDockerNetwork (/src/server/services/mqtt/lib/checkDockerNetwork.js:8:54)
at MqttHandler.getConfiguration (/src/server/services/mqtt/lib/getConfiguration.js:24:35)
at MqttHandler.init (/src/server/services/mqtt/lib/init.js:13:25)
at Object.start (/src/server/services/mqtt/index.js:17:5)
at Service.start (/src/server/lib/service/service.start.js:33:7)
I think that warning could be related; I've just tried with the following with a new Gladys installation:
So it seems that the configuration is actually saved but it's just the connection that is not automatically started when there is no docker.sock.
I've also noticed that after step 4 (initial configuration without docker.sock) if I nagivate away from the "setup" screen and then come back to that screen, the configuration details show blank (although message still says "success").
@nataloko Thanks for your investigation, it helps a lot.
I understand what's going on now, we check in this integration is "Docker based" on this line: https://github.com/GladysAssistant/Gladys/blob/master/server/services/mqtt/lib/getConfiguration.js#L23
If yes, we get the networkMode of the current container, and in your case it fails because the docker socket is not available.
I'm going to add some safety checks to avoid breaking the MQTT integration in case the Docker socket is not here
Fixed in PR : https://github.com/GladysAssistant/Gladys/pull/2084
@nataloko Fix available in Gladys Assistant 4.42
Thank you, I can confirm it's working as expected now :)
Describe the bug I have Gladys running in docker and an external MQTT broker (Mosquitto), everything seems to work OK when I enter the address and login details but configuration gets lost when I reboot (or restart Gladys).
To Reproduce
Expected behavior I expect the configured broker to stay saved.
Screenshots
![image](https://github.com/GladysAssistant/Gladys/assets/93059500/10f45216-7b1a-47d5-a283-af5f266a6e83)
Your Gladys installation (please complete the following information):
Desktop (please complete the following information):