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

Add freeze/thaw apis for external snapshots #4538

Merged
merged 3 commits into from
Sep 9, 2023
Merged

Conversation

mdegat01
Copy link
Contributor

@mdegat01 mdegat01 commented Sep 8, 2023

Proposed change

Users often run HAOS as a VM in software like KVM and Proxmox. These applications all contain snapshot features which quickly take a snapshot of the entire VM. For users of these applications this is significantly easier and faster alternative to backup then supervisor's native backup and restore features. Which makes sense, supervisor can't really compete with disk snapshot features given how and where we are running.

The problem is these features currently create data consistency issues. Home Assistant continues to run and write data to disk at an extremely rapid pace, it is definitely possible to end up with a corrupted database. Just like what used to happen to Supervisor's backups before we put in hooks to pause recorder during backups.

This adds a freeze API. When called it does the following:

  1. Puts supervisor in FREEZE state
  2. Tells Home Assistant a backup is underway to pause disk writes
  3. Calls backup_pre for any running addons which have that configured
  4. Stops any running addons which require cold mode for backups

It also adds a thaw API which reverses the above (unfreezes supervisor, tells HA the backup has ended, calls backup_post on addons and restarts any addons it stopped). Note that this thaw API only works on a freeze initiated by the freeze API, it errors if the freeze was initiated elsewhere.

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 API new-feature A new feature labels Sep 8, 2023
@mdegat01 mdegat01 added missing-documentation Added to pull requests that needs a docs, but none is linked need-cli Added to pull requests that need cli changes but none is linked labels Sep 8, 2023
@mdegat01 mdegat01 removed the missing-documentation Added to pull requests that needs a docs, but none is linked label Sep 8, 2023
@mdegat01 mdegat01 removed the need-cli Added to pull requests that need cli changes but none is linked label Sep 8, 2023
@mdegat01 mdegat01 marked this pull request as ready for review September 8, 2023 13:19
@pvizeli pvizeli merged commit 44daffc into main Sep 9, 2023
23 checks passed
@pvizeli pvizeli deleted the manual-freeze-api branch September 9, 2023 08:54
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants