add cache settings and processing time display to cluster view

This commit is contained in:
Eduardo Silva
2026-01-14 09:48:07 -03:00
parent 412c8fc88d
commit 0b0d08f0b2
3 changed files with 35 additions and 11 deletions

View File

@@ -130,13 +130,9 @@ class ClusterSettingsForm(forms.ModelForm):
def clean(self):
cleaned_data = super().clean()
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:
raise ValidationError(_("Disabling WireGuard on the master server is currently not supported."))
return cleaned_data

View File

@@ -4,6 +4,7 @@ from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import gettext_lazy as _
from api.models import WireguardStatusCache
from dns.functions import compress_dnsmasq_config
from user_manager.models import UserAcl
from .forms import WorkerForm, ClusterSettingsForm
@@ -19,11 +20,20 @@ def cluster_main(request):
cluster_settings, created = ClusterSettings.objects.get_or_create(name='cluster_settings')
page_title = _('Cluster')
workers = Worker.objects.all().order_by('name')
master_cache_times = ", ".join([str(c.processing_time_ms) for c in WireguardStatusCache.objects.filter(cache_type='master').order_by('-created')])
cluster_cache_times = ", ".join([str(c.processing_time_ms) for c in WireguardStatusCache.objects.filter(cache_type='cluster').order_by('-created')])
context = {
'page_title': page_title,
'workers': workers,
'page_title': page_title,
'workers': workers,
'current_worker_version': settings.CLUSTER_WORKER_CURRENT_VERSION,
'cluster_settings': cluster_settings
'cluster_settings': cluster_settings,
'cache_refresh_interval': settings.WIREGUARD_STATUS_CACHE_REFRESH_INTERVAL,
'cache_enabled': settings.WIREGUARD_STATUS_CACHE_ENABLED,
'cache_web_load_previous_count': settings.WIREGUARD_STATUS_CACHE_WEB_LOAD_PREVIOUS_COUNT,
'master_cache_times': master_cache_times,
'cluster_cache_times': cluster_cache_times,
}
return render(request, 'cluster/workers_list.html', context)