Gladys on Unraid

Ok, that’s what I don’t understand well:

Does this correspond to the default values? Or to what is currently being used on Docker? Because if it’s what’s currently running on Docker, it’s easy to retrieve. So I’m convinced I don’t understand the problem well since the solution seems simple to me.

Well that’s simple but if your path is /here/toto there’s no way to guess that it’s the mount on the host.

That could work but we’ll see what others think.

I’m trying to anticipate problems :grin:

I edited my previous message

So in my case, you get:

[
'/var/run/docker.sock:/var/run/docker.sock',
'/run/udev:/run/udev',
'/dev:/dev',
'/mnt/user/appdata/Gladys:/var/lib/gladysassistant'
]

But on the right side, it’s always the same thing /var/lib/gladysassistant/ it never changes, so that’s what allows you to identify it, right?

Edit after seeing your edit: yes, I completely agree with you, but you seemed to have found a method to do it automatically, right or wrong?

In theory, yes, it does not change.

Edit: yes, the idea is to list the mounts, look for /var/lib/gladysassistant and take the value on the left

The /var/lib/gladysassistant comes from the SQLITE_FILE_PATH, so I wouldn’t say it never moves either, but yes it is known in the code :slight_smile:

So to summarize, two options:

  • Option 1: Extract the folder from the mounted volumes, by finding the right folder thanks to the SQLITE_FILE_PATH
  • Option 2: Environment variable, like GLADYS_FOLDER_PATH_ON_HOST, which is perhaps more explicit and more predictable. Especially since in the case where we launch Gladys via Syno or Unraid, we can very well add this variable.

I, who have been using UNRAID for quite some time, think that option 2 is the best. All the more so since it is easy in the Unraid template to comment on the fields to be filled in to guide the user if necessary

To bounce back on all this, I went to see the code to try to see if I could do it, but in fact all this is already coded so I don’t understand anything anymore :sweat_smile:

The Zigbee2mqtt integration indeed calls the basePath function:

const { basePathOnContainer, basePathOnHost } = await this.basePath();

Which itself returns the host side path:

https://github.com/GladysAssistant/Gladys/blob/master/server/services/zigbee2mqtt/lib/basePath.js#L23

So I don’t understand why it doesn’t work, the code is there! :smiley:

@cicoub13 tell me if that rings a bell!

In reading the code, I get the impression that it’s reversed, that we’re retrieving the path on the container side, am I wrong?

gladys-z2m-mqtt-env.sh ${basePathOnContainer}

This is normal, this part takes place in the container.

The place where the volume is defined is here:

However, there is something that doesn’t work, this line mutates the global json object, so it pushes every time this function is called, and it affects the global variable, that’s not good.

Same here (Gladys/server/services/zigbee2mqtt/lib/installMqttContainer.js at master · GladysAssistant/Gladys · GitHub), the push mutates the global object.

Do you think that’s the problem?

I don’t think this is the bug here, but in any case it’s certain that this issue is causing bugs

I launched a small VM to test all this.

I started a container with the following parameters:

docker run -d \
# removed for readability
-v /var/lib/gladysassistant_other_folder:/var/lib/gladysassistant \
gladysassistant/gladys:v4

I added some logs, and I started a Zigbee2mqtt container, and here’s what it gives:

2022-03-07T18:55:44+0100 <info> installMqttContainer.js:25 (Zigbee2mqttManager.installMqttContainer) MQTT broker is being installed as Docker container...
2022-03-07T18:55:44+0100 <info> installMqttContainer.js:26 (Zigbee2mqttManager.installMqttContainer) Pulling eclipse-mosquitto:2 image...
2022-03-07T18:55:47+0100 <info> installMqttContainer.js:30 (Zigbee2mqttManager.installMqttContainer) Preparing broker environment...
{
  basePathOnContainer: '/var/lib/gladysassistant',
  basePathOnHost: '/var/lib/gladysassistant'
}
[ '/var/lib/gladysassistant/zigbee2mqtt/mqtt:/mosquitto/config' ]
2022-03-07T18:55:47+0100 <info> installMqttContainer.js:37 (Zigbee2mqttManager.installMqttContainer) Creating container...
2022-03-07T18:55:47+0100 <info> installMqttContainer.js:51 (Zigbee2mqttManager.installMqttContainer) MQTT broker is restarting...

The basePathOnHost is not correct, there is a bug in the basePath function

I am investigating…

I’m going further after adding logs, the call:

const gladysMounts = await this.gladys.system.getContainerMounts(os.hostname());

Returns an empty array… So, gladysMounts is empty and the default is applied..

I continue my investigation

I think I understand, the function expects a containerId:

And behind the function sends the hostname:

https://github.com/GladysAssistant/Gladys/blob/master/server/services/zigbee2mqtt/lib/basePath.js#L17

We should send the current container’s id

I created a GitHub issue with the details:

And:

Thanks a lot for these advancements,

With the release of 4.8, this will be an opportunity to test the update on unraid because I don’t run watchtower…
Therefore, I’m waiting to see if it offers to update the docker image with a new one

Keep us posted! However, what I mentioned about Unraid (the fixes related to Zigbee2mqtt) are not in this 4.8, it will be available in the next update :slight_smile: I worked on it this morning, it was too late to include in 4.8.

Yes, I suspected as much, no problem, the instance is working on my side, we are not in a hurry, the more time passes, the more Gladys becomes competitive, so it’s better to leave some time.

Thanks a lot anyway, the update is very nice!