disable cluster settings if WireGuard status cache is not enabled; add validation for cluster mode

This commit is contained in:
Eduardo Silva
2026-01-13 12:22:07 -03:00
parent 3fff8a4e15
commit 72e2e84b34
2 changed files with 9 additions and 0 deletions

View File

@@ -101,6 +101,10 @@ def get_worker(request):
success = False success = False
cluster_settings, created = ClusterSettings.objects.get_or_create(name='cluster_settings') cluster_settings, created = ClusterSettings.objects.get_or_create(name='cluster_settings')
if not settings.WIREGUARD_STATUS_CACHE_ENABLED and cluster_settings.enabled:
cluster_settings.enabled = False
cluster_settings.save()
if cluster_settings.enabled: if cluster_settings.enabled:
if worker.error_status == 'cluster_disabled': if worker.error_status == 'cluster_disabled':
worker.error_status = '' worker.error_status = ''

View File

@@ -1,6 +1,7 @@
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import Column, HTML, Layout, Row, Submit from crispy_forms.layout import Column, HTML, Layout, Row, Submit
from django import forms from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@@ -130,6 +131,10 @@ class ClusterSettingsForm(forms.ModelForm):
def clean(self): def clean(self):
cleaned_data = super().clean() cleaned_data = super().clean()
primary_enable_wireguard = cleaned_data.get('primary_enable_wireguard') primary_enable_wireguard = cleaned_data.get('primary_enable_wireguard')
cluster_enabled = cleaned_data.get('enabled')
if cluster_enabled and not settings.WIREGUARD_STATUS_CACHE_ENABLED:
raise ValidationError(_("Cluster mode requires WireGuard status cache to be enabled."))
if not primary_enable_wireguard: if not primary_enable_wireguard:
raise ValidationError(_("Disabling WireGuard on the master server is currently not supported.")) raise ValidationError(_("Disabling WireGuard on the master server is currently not supported."))