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

Wait on network to be available before trying to run backups against remote repos #2176

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rzeigler
Copy link

@rzeigler rzeigler commented Dec 25, 2024

Description

Reactively disable scheduled jobs against remote repositories when there is no network connection.

Related Issue

#2133

Motivation and Context

Running a backup against a remote repo will fail without a network connection.
This results in a notification on default settings, stress (because why are my backups failing) and could maybe result in backups not happening.
On my Linux systems configured to sleep, the first backup after resuming always seems to fail because the network has not finished activating yet.
This should allow that backup to just wait for a little while.

As a side benefit, this should also defer backups that happen in the normal course when there is no possible way they could work (i.e. when in airplane mode).

I thought about these changes for a little and its what I came up with. However, if the maintainers have a different approach they would like to try I'm more than willing to rework my PR or open a new one with that approach. I do also have a mac that I can in theory develop the stubbed mac implementation here, but I'm less familiar with how to programatically access the state of the mac network. If this approach is good, I can flesh that out also.

How Has This Been Tested?

  1. Activate airplane mode from kde plasma network manager
  2. Manipulate the event log in settings.db so that the scheduled backup will fire immediately
  3. Start vorta
  4. Observe the new logs indicating that the scheduled task is being postponed because no network
  5. Re-enable the network
  6. Observe the scheduling come back

I had a little bit of trouble figuring out how to manipulate vorta's database state so that I could actually start vorta, then put my system to sleep. Vorta always wanted to backup immediately. I assume this should be a reasonable facsimile of the behavior.

Regarding actual tests, I am not an experienced python developer and running nox locally seems to fail to collect tests in test_darwin.py which I wouldn't expect to execute at all on my system. That said, I don't think I changed anything covered by unit tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes. I am unsure of how I would test this
  • All new and existing tests passed. See note re: nox, I'm not actually sure

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

@rzeigler rzeigler force-pushed the wait-for-network branch 2 times, most recently from 2fe7de9 to eaaadf0 Compare December 25, 2024 23:23
Don't try and start jobs with remote repos until the network is up.
This should prevent job failures when, for instance, waking from sleep.

Mac implementation is a stub currently.

Signed-off-by: Ryan Zeigler <zeiglerr@gmail.com>
Signed-off-by: Ryan Zeigler <zeiglerr@gmail.com>
NetworkStatusMonitor is now a QObject with signal
network_status_changed.
The scheduler listens to this signal and handles rescheduling
similar to the existing 'wake from suspend' logic works.

Signed-off-by: Ryan Zeigler <zeiglerr@gmail.com>
@rzeigler
Copy link
Author

I didn't like the timer firing constantly so I have reworked this to listen for network manager events.

It seems that sometimes the signal does't arrive.

Signed-off-by: Ryan Zeigler <zeiglerr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant