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

Improve error handling when mounts fail #4872

Merged
merged 1 commit into from
Feb 5, 2024
Merged

Conversation

mdegat01
Copy link
Contributor

@mdegat01 mdegat01 commented Feb 2, 2024

Proposed change

When we fail to mount a media or share type mount it is supposed to mount a read-only file in that spot. This ensures that attempts to write to that folder will fail and report rather then essentially silently fail by writing locally (and then creating other issues later). This logic did not work because it relied on user permissions and all docker containers in the Home Assistant ecosystem run as root. This changes the bind mount itself to use the read-only option which causes write failures even for root.

Since there was a feature request to create mounts of type media and share as read-only this was extended into a feature. Users can now make read-only mounts of type media and share.

As for backup type mounts, we expected that if the user tried to make a backup on a downed mount they would get a timeout. It appears that instead it writes the file locally instead. This causes impossible to fix errors next startup as we cannot mount over a non-empty folder and users can't see these folders without going into the supervisor container.

So if the user tries to make a backup in a mount we first check that the folder is in fact a mountpoint using Path.is_mount. In testing this only returns true if the folder is a mountpoint and if that connection is active. If this returns false we raise an error immediately and exit.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints of add-on configuration are added/changed:

@mdegat01 mdegat01 added missing-documentation Added to pull requests that needs a docs, but none is linked new-feature A new feature need-cli Added to pull requests that need cli changes but none is linked labels Feb 2, 2024
@mdegat01 mdegat01 requested review from agners and pvizeli February 2, 2024 23:00
@mdegat01 mdegat01 force-pushed the improve-mount-error-handling branch from 2e6296c to 2975785 Compare February 2, 2024 23:00
@mdegat01 mdegat01 removed the missing-documentation Added to pull requests that needs a docs, but none is linked label Feb 3, 2024
@mdegat01 mdegat01 removed the need-cli Added to pull requests that need cli changes but none is linked label Feb 3, 2024
@mdegat01 mdegat01 force-pushed the improve-mount-error-handling branch from 2975785 to 7963e2d Compare February 5, 2024 16:38
@mdegat01 mdegat01 merged commit 4c57399 into main Feb 5, 2024
19 checks passed
@mdegat01 mdegat01 deleted the improve-mount-error-handling branch February 5, 2024 21:24
@jmealo
Copy link

jmealo commented Feb 5, 2024

@mdegat01 thanks for taking care of this! 🙏

@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

For discussion/architecture: Network Storage Issues: Proposed fix for: home-assistant/core #106446
4 participants