From 2642f14e497c982315c4644715d1038f5cf02c1b Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Thu, 21 May 2026 02:41:02 +0200 Subject: [PATCH] (refactor) Remove pobsync_home from global config Drop the obsolete pobsync_home field from GlobalConfig and remove it from runtime config generation, form saves, and configuration commands. The runtime state root now comes exclusively from POBSYNC_HOME/settings, which keeps the Django model focused on backup behavior instead of install layout. --- src/pobsync/config/schemas.py | 2 -- src/pobsync_backend/config_repository.py | 1 - src/pobsync_backend/forms.py | 1 - .../commands/configure_pobsync_global.py | 5 ----- .../0010_remove_globalconfig_pobsync_home.py | 14 ++++++++++++++ src/pobsync_backend/models.py | 1 - .../tests/test_config_repository.py | 3 --- .../tests/test_configure_commands.py | 1 - .../tests/test_django_config_source.py | 6 ------ src/pobsync_backend/tests/test_views.py | 4 ---- 10 files changed, 14 insertions(+), 24 deletions(-) create mode 100644 src/pobsync_backend/migrations/0010_remove_globalconfig_pobsync_home.py diff --git a/src/pobsync/config/schemas.py b/src/pobsync/config/schemas.py index 2ab7bb2..c8baa1c 100644 --- a/src/pobsync/config/schemas.py +++ b/src/pobsync/config/schemas.py @@ -83,7 +83,6 @@ OUTPUT_SCHEMA = Schema( GLOBAL_SCHEMA = Schema( fields={ "backup_root": FieldSpec(str, required=True), - "pobsync_home": FieldSpec(str, required=False, default="/opt/pobsync"), "ssh": FieldSpec(dict, required=False, schema=SSH_SCHEMA), "rsync": FieldSpec(dict, required=False, schema=RSYNC_SCHEMA), "defaults": FieldSpec(dict, required=False, schema=DEFAULTS_SCHEMA), @@ -131,4 +130,3 @@ HOST_SCHEMA = Schema( }, allow_unknown=False, ) - diff --git a/src/pobsync_backend/config_repository.py b/src/pobsync_backend/config_repository.py index 7f08e5d..91a53d8 100644 --- a/src/pobsync_backend/config_repository.py +++ b/src/pobsync_backend/config_repository.py @@ -17,7 +17,6 @@ class ConfigRepositoryError(RuntimeError): def _global_runtime_data(global_config: GlobalConfig) -> dict[str, Any]: data = { "backup_root": global_config.backup_root, - "pobsync_home": global_config.pobsync_home, "ssh": { "user": global_config.ssh_user, "port": global_config.ssh_port, diff --git a/src/pobsync_backend/forms.py b/src/pobsync_backend/forms.py index ec2f6cc..b177a40 100644 --- a/src/pobsync_backend/forms.py +++ b/src/pobsync_backend/forms.py @@ -119,7 +119,6 @@ class GlobalConfigForm(forms.ModelForm): def save(self, commit: bool = True): instance = super().save(commit=False) instance.backup_root = settings.POBSYNC_BACKUP_ROOT - instance.pobsync_home = settings.POBSYNC_HOME if commit: instance.save() self.save_m2m() diff --git a/src/pobsync_backend/management/commands/configure_pobsync_global.py b/src/pobsync_backend/management/commands/configure_pobsync_global.py index a7cc318..730f053 100644 --- a/src/pobsync_backend/management/commands/configure_pobsync_global.py +++ b/src/pobsync_backend/management/commands/configure_pobsync_global.py @@ -1,9 +1,7 @@ from __future__ import annotations -from pathlib import Path from typing import Any -from django.conf import settings from django.core.management.base import BaseCommand, CommandError from pobsync.config.retention import parse_retention @@ -18,7 +16,6 @@ class Command(BaseCommand): def add_arguments(self, parser) -> None: parser.add_argument("--name", default="default") parser.add_argument("--backup-root", required=True) - parser.add_argument("--pobsync-home", default=settings.POBSYNC_HOME, help="Runtime state root") parser.add_argument("--ssh-user", default="root") parser.add_argument("--ssh-port", type=int, default=22) parser.add_argument("--source-root", default="/") @@ -30,11 +27,9 @@ class Command(BaseCommand): if not is_absolute_non_root(backup_root): raise CommandError("--backup-root must be an absolute path and must not be '/'") - pobsync_home = str(Path(options["pobsync_home"])) retention = parse_retention(options["retention"]) defaults = { "backup_root": backup_root, - "pobsync_home": pobsync_home, "ssh_user": options["ssh_user"], "ssh_port": options["ssh_port"], "ssh_options": ["-oBatchMode=yes", "-oStrictHostKeyChecking=accept-new"], diff --git a/src/pobsync_backend/migrations/0010_remove_globalconfig_pobsync_home.py b/src/pobsync_backend/migrations/0010_remove_globalconfig_pobsync_home.py new file mode 100644 index 0000000..e88081a --- /dev/null +++ b/src/pobsync_backend/migrations/0010_remove_globalconfig_pobsync_home.py @@ -0,0 +1,14 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("pobsync_backend", "0009_remove_scheduleconfig_user"), + ] + + operations = [ + migrations.RemoveField( + model_name="globalconfig", + name="pobsync_home", + ), + ] diff --git a/src/pobsync_backend/models.py b/src/pobsync_backend/models.py index 830458c..c97ffe3 100644 --- a/src/pobsync_backend/models.py +++ b/src/pobsync_backend/models.py @@ -14,7 +14,6 @@ class TimestampedModel(models.Model): class GlobalConfig(TimestampedModel): name = models.CharField(max_length=64, default="default", unique=True) backup_root = models.CharField(max_length=512) - pobsync_home = models.CharField(max_length=512, default="/opt/pobsync") default_ssh_credential = models.ForeignKey( "SshCredential", on_delete=models.SET_NULL, diff --git a/src/pobsync_backend/tests/test_config_repository.py b/src/pobsync_backend/tests/test_config_repository.py index 409294a..64d32d1 100644 --- a/src/pobsync_backend/tests/test_config_repository.py +++ b/src/pobsync_backend/tests/test_config_repository.py @@ -11,7 +11,6 @@ class ConfigRepositoryTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/backups", - pobsync_home="/var/lib/pobsync", ssh_user="backup", ssh_port=2222, rsync_args=["--archive"], @@ -22,7 +21,6 @@ class ConfigRepositoryTests(TestCase): retention_yearly=1, data={ "backup_root": "/ignored", - "pobsync_home": "/ignored", "ssh": {"user": "ignored", "port": 22, "options": []}, "unknown": "must-not-leak", "retention_defaults": {"daily": 99, "weekly": 99, "monthly": 99, "yearly": 99}, @@ -51,7 +49,6 @@ class ConfigRepositoryTests(TestCase): host_cfg = host_config_data("web-01") self.assertEqual(global_cfg["backup_root"], "/backups") - self.assertEqual(global_cfg["pobsync_home"], "/var/lib/pobsync") self.assertEqual(global_cfg["ssh"]["user"], "backup") self.assertEqual(global_cfg["ssh"]["port"], 2222) self.assertEqual(global_cfg["retention_defaults"]["daily"], 7) diff --git a/src/pobsync_backend/tests/test_configure_commands.py b/src/pobsync_backend/tests/test_configure_commands.py index f96798b..bf5ef99 100644 --- a/src/pobsync_backend/tests/test_configure_commands.py +++ b/src/pobsync_backend/tests/test_configure_commands.py @@ -16,7 +16,6 @@ class ConfigureCommandsTests(TestCase): call_command( "configure_pobsync_global", backup_root="/backups", - pobsync_home="/opt/pobsync", retention="daily=3,weekly=2,monthly=1,yearly=0", stdout=out, ) diff --git a/src/pobsync_backend/tests/test_django_config_source.py b/src/pobsync_backend/tests/test_django_config_source.py index 0d78740..0dbc549 100644 --- a/src/pobsync_backend/tests/test_django_config_source.py +++ b/src/pobsync_backend/tests/test_django_config_source.py @@ -15,7 +15,6 @@ class DjangoConfigSourceTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/backups", - pobsync_home="/opt/pobsync", rsync_args=["--archive"], rsync_extra_args=["--numeric-ids"], excludes_default=["/proc/***"], @@ -25,7 +24,6 @@ class DjangoConfigSourceTests(TestCase): retention_yearly=1, data={ "backup_root": "/ignored", - "pobsync_home": "/ignored", "ssh": {"user": "root", "port": 22, "options": []}, "rsync": { "binary": "rsync", @@ -72,7 +70,6 @@ class DjangoConfigSourceTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/backups", - pobsync_home="/opt/pobsync", default_ssh_credential=credential, ssh_options=["-oBatchMode=yes"], ) @@ -99,7 +96,6 @@ class DjangoConfigSourceTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/backups", - pobsync_home="/opt/pobsync", default_ssh_credential=global_credential, ) HostConfig.objects.create( @@ -127,7 +123,6 @@ class DjangoConfigSourceTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/backups", - pobsync_home="/opt/pobsync", default_ssh_credential=credential, ) HostConfig.objects.create(host="web-01", address="web-01.example.test") @@ -146,7 +141,6 @@ class DjangoConfigSourceTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/backups", - pobsync_home="/opt/pobsync", default_ssh_credential=credential, ) HostConfig.objects.create(host="web-01", address="web-01.example.test") diff --git a/src/pobsync_backend/tests/test_views.py b/src/pobsync_backend/tests/test_views.py index 08c3360..0303bf9 100644 --- a/src/pobsync_backend/tests/test_views.py +++ b/src/pobsync_backend/tests/test_views.py @@ -475,7 +475,6 @@ class ViewTests(TestCase): self.assertContains(response, "Global config saved for default.") config = GlobalConfig.objects.get(name="default") self.assertEqual(config.backup_root, "/backups") - self.assertEqual(config.pobsync_home, "/opt/pobsync") self.assertEqual(config.default_ssh_credential, credential) self.assertEqual(config.ssh_user, "backup") self.assertEqual(config.ssh_port, 2222) @@ -502,7 +501,6 @@ class ViewTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/mnt/pobsync/backups", - pobsync_home="/custom/state/home", ) response = self.client.get(reverse("edit_global_config")) @@ -532,7 +530,6 @@ class ViewTests(TestCase): GlobalConfig.objects.create( name="default", backup_root="/mnt/pobsync/backups", - pobsync_home="/custom/state/home", ) response = self.client.post( @@ -561,7 +558,6 @@ class ViewTests(TestCase): self.assertRedirects(response, reverse("dashboard")) config = GlobalConfig.objects.get(name="default") self.assertEqual(config.backup_root, "/backups") - self.assertEqual(config.pobsync_home, "/opt/pobsync") def test_create_host_config_form_creates_host(self) -> None: self.client.force_login(self.staff_user)