Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network share mounting after add-ons have started, after a reboot (Example: Frigate add-on) #5471

Open
neekul opened this issue Dec 6, 2024 · 9 comments
Labels

Comments

@neekul
Copy link

neekul commented Dec 6, 2024

Describe the issue you are experiencing

I have recently spotted something that is causing issues with Frigate.

I followed the documentation in Frigate to have my recordings placed on my NAS so my local drive isn’t eaten up (500GB SSD. HA is running on Proxmox in a VM)

I moved the Frigate DB to /config/
I used HA (Settings → System → Storage → Add Network Storage)
Started up Frigate and it all was working great.

Then I noticed if HA was to reboot in anyway, the mount would not happen, as it sees there is an existing fold/file in the location (media/frigate).
Here is the Supervisor Error

ERROR (MainThread) [supervisor.mounts.mount] Cannot mount bind_frigate at /data/media/frigate because it is not empty

What I suspect is happening is during a reboot, HA starts up all the Addons.
Frigate is set to start up on boot.
Frigate attempts to look at the media folder and realises its not there (the mount hasnt taken place by HA at this point) so it creates a directory (now this is created on the local drive by Frigate)
Then the mount process, I guess, kicks in and sees stuff in /media/frigate already and throws the error.
Frigate is happy so I don't notice it until I see my local drive suddenly filling up.

I have worked around this by making sure I uncheck “Start on Boot” for Frigate addon. Then created an automation that waits a few mins for HA to start up and then turns on Frigate giving HA time to mount the network drive.

I assume this a sequence thing for when HA boots up. The mount should happen before any Addons start to avoid this issue and have any addons that use mounted drives not try create their own folders before a mount has been done.

What type of installation are you running?

Home Assistant OS

Which operating system are you running on?

Home Assistant Operating System

Steps to reproduce the issue

  1. Create a Network Drive mount to /media/frigate
  2. Start Frigate Addon, check "Start on boot"
  3. Reboot Home Assistant
  4. Frigate Addons starts on boot
  5. Frigate creates /media/frigate before mount
  6. Mount fails

Anything in the Supervisor logs that might be useful for us?

2024-12-04 12:11:58.790 ERROR (MainThread) [supervisor.mounts.mount] Cannot mount bind_frigate at /data/media/frigate because it is not empty
2024-12-04 12:11:58.790 ERROR (MainThread) [asyncio] Task exception was never retrieved

System Health information

System Information

version core-2024.11.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.63-haos
arch x86_64
timezone Europe/Stockholm
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
HACS Data ok
GitHub API Calls Remaining 5000
Installed Version 2.0.1
Stage running
Available Repositories 1475
Downloaded Repositories 18
Home Assistant Cloud
logged_in true
subscription_expiration 22 August 2025 at 02:00
relayer_connected true
relayer_region eu-central-1
remote_enabled true
remote_connected true
alexa_enabled false
google_enabled false
cloud_ice_servers_enabled true
remote_server eu-central-1-21.ui.nabu.casa
certificate_status ready
instance_id 6cedce93a5ec4d5ead50c0b4a88697d3
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 14.0
update_channel stable
supervisor_version supervisor-2024.11.4
agent_version 1.6.0
docker_version 27.2.0
disk_total 97.7 GB
disk_used 21.6 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization kvm
board ova
supervisor_api ok
version_api ok
installed_addons Advanced SSH & Web Terminal (19.0.0), File editor (5.8.0), Studio Code Server (5.17.3), Samba share (12.3.2), Home Assistant Google Drive Backup (0.112.1), Samba Backup (5.2.0), Whisper (2.3.0), Piper (1.5.2), Zigbee2MQTT (1.42.0-2), Mosquitto broker (6.4.1), Frigate (0.14.1), Filebrowser (2.23.0_14), openWakeWord (1.10.0), Glances (0.21.1)
Dashboards
dashboards 4
resources 11
views 3
mode storage
Recorder
oldest_recorder_run 6 November 2024 at 09:59
current_recorder_run 5 December 2024 at 11:51
estimated_db_size 1209.50 MiB
database_engine sqlite
database_version 3.45.3

Supervisor diagnostics

config_entry-hassio-834020f9bf7ad173979ba5f36fa06776.json

Additional information

No response

@neekul neekul added the bug label Dec 6, 2024
@BobMac57
Copy link

This has been an issue for a long time, is there any resolve to this? I have to manually click on repair or do an HA restart and then start Frigate to resolve...

@neekul
Copy link
Author

neekul commented Jan 10, 2025

This has been an issue for a long time, is there any resolve to this? I have to manually click on repair or do an HA restart and then start Frigate to resolve...

Getting to this late.
I don't know of a proper fix and I hope someone see's this at somepoint to fix. For now all I have done is to setup an automation:

On HA Start
Delay 5mins
Start Frigate Addon.

I have set Frigate to not load on boot in the Addon Options. Its a workaround and for now its working just fine. Would be nice to not have to think about this though.

@Hiekkaharju
Copy link

@neekul : I'd suggest change of title. Something like "Supervisor starts add-on:s before HA network storage is mounted."
Because that's the root cause, Frigate just happens to be ONE add on that starts writing soon after starting. And if that happens before the network mount is there, the write will go to local storage - and prevent the mount. I see that you understood what happens, I just think that a title that makes the root cause clear might better draw the attention of the developers.

@neekul
Copy link
Author

neekul commented Jan 17, 2025

@neekul : I'd suggest change of title. Something like "Supervisor starts add-on:s before HA network storage is mounted." Because that's the root cause, Frigate just happens to be ONE add on that starts writing soon after starting. And if that happens before the network mount is there, the write will go to local storage - and prevent the mount. I see that you understood what happens, I just think that a title that makes the root cause clear might better draw the attention of the developers.

@Hiekkaharju good point. Changed!

@neekul neekul changed the title Network share not mounting after reboot (Frigate) Network share mounting after add-ons have started, after a reboot (Example: Frigate add-on) Jan 17, 2025
@Hiekkaharju
Copy link

update: this might not be as straightforward as I have thought. I was just restarting the computer my HA runs on, After the restart I noticed that Frigate had apparently written to the media/frigate location during the shutdown, after the network storage mount had been unmounted. Thus at startup there already was a local media/frigate directory, and as there was some time between the shutdown and start, the timestamps made clear it was from the time of the shutdown. That directory then prevented the mount already before Frigate got started again.
So seems the shutdown process also did the unmount before (all) add-ons had stopped.

@BobMac57
Copy link

update: this might not be as straightforward as I have thought. I was just restarting the computer my HA runs on, After the restart I noticed that Frigate had apparently written to the media/frigate location during the shutdown, after the network storage mount had been unmounted. Thus at startup there already was a local media/frigate directory, and as there was some time between the shutdown and start, the timestamps made clear it was from the time of the shutdown. That directory then prevented the mount already before Frigate got started again. So seems the shutdown process also did the unmount before (all) add-ons had stopped.

That's not good!

@neekul
Copy link
Author

neekul commented Jan 18, 2025

update: this might not be as straightforward as I have thought. I was just restarting the computer my HA runs on, After the restart I noticed that Frigate had apparently written to the media/frigate location during the shutdown, after the network storage mount had been unmounted. Thus at startup there already was a local media/frigate directory, and as there was some time between the shutdown and start, the timestamps made clear it was from the time of the shutdown. That directory then prevented the mount already before Frigate got started again. So seems the shutdown process also did the unmount before (all) add-ons had stopped.

Strange. I performed multiple HA restarts, and also rebooted the machine HA runs on (Proxmox node reboot) and did not have this happen to me.

@Hiekkaharju
Copy link

Strange. I performed multiple HA restarts, and also rebooted the machine HA runs on (Proxmox node reboot) and did not have this happen to me.

It doesn't seem to happen often. I've also had far more restarts without this than with it - while the startup version happened every time until I delayed Frigate start.
And when considering what would be written at that point, I first thougth of continuous recording, which I have on. But the local directory at that point contained only an empty media/frigate/clips dir and it's subdirectories - no media/frigate/recordings.

@mad-tunes
Copy link

+1
I find exactly the same. Only with a share frigate uses, but I only use frigate and backup shares.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants