(feature) Add global and effective host config checks
Introduce reusable configuration checks for global settings and effective host runtime configuration. The checks now surface risky backup settings such as missing recursive rsync args, missing critical root excludes, invalid SSH settings, missing credentials, and retention gaps. Show these checks on the global config form, host edit form, and host detail page so operators can validate the compounded host/global config before starting real backup runs.
This commit is contained in:
@@ -16,6 +16,7 @@ from pobsync.errors import PobsyncError
|
||||
from pobsync.config.defaults import DEFAULT_EXCLUDES, DEFAULT_RSYNC_ARGS
|
||||
|
||||
from .backup_runner import queue_backup_run
|
||||
from .config_checks import collect_effective_host_config_checks, collect_global_config_checks
|
||||
from .forms import (
|
||||
CreateHostConfigForm,
|
||||
GlobalConfigForm,
|
||||
@@ -203,6 +204,7 @@ def edit_global_config(request):
|
||||
return redirect("dashboard")
|
||||
else:
|
||||
form = GlobalConfigForm(instance=global_config) if global_config else GlobalConfigForm(initial=_default_global_initial())
|
||||
config_checks = collect_global_config_checks(global_config) if global_config else []
|
||||
|
||||
return render(
|
||||
request,
|
||||
@@ -211,6 +213,8 @@ def edit_global_config(request):
|
||||
"global_config": global_config,
|
||||
"form": form,
|
||||
"backup_root": settings.POBSYNC_BACKUP_ROOT,
|
||||
"config_checks": config_checks,
|
||||
"config_check_summary": summarize_self_checks(config_checks),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -452,6 +456,8 @@ def apply_host_retention(request, host: str):
|
||||
@staff_member_required
|
||||
def edit_host_config(request, host: str):
|
||||
host_config = get_object_or_404(HostConfig, host=host)
|
||||
global_config = GlobalConfig.objects.filter(name="default").first()
|
||||
config_checks = collect_effective_host_config_checks(host_config, global_config) if global_config else []
|
||||
if request.method == "POST":
|
||||
form = HostConfigForm(request.POST, instance=host_config)
|
||||
if form.is_valid():
|
||||
@@ -467,6 +473,8 @@ def edit_host_config(request, host: str):
|
||||
{
|
||||
"host": host_config,
|
||||
"form": form,
|
||||
"config_checks": config_checks,
|
||||
"config_check_summary": summarize_self_checks(config_checks),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user