fix(mailu): allow forced sync

This commit is contained in:
Brad Stein 2026-01-19 23:28:07 -03:00
parent 901f3e797c
commit 9ff88f7f13
3 changed files with 8 additions and 6 deletions

View File

@ -30,7 +30,7 @@ spec:
app: mailu-sync-listener
annotations:
vault.hashicorp.com/agent-inject: "true"
atlas.bstein.dev/mailu-sync-rev: "2"
atlas.bstein.dev/mailu-sync-rev: "3"
vault.hashicorp.com/role: "mailu-mailserver"
vault.hashicorp.com/agent-inject-secret-mailu-db-secret__database: "kv/data/atlas/mailu/mailu-db-secret"
vault.hashicorp.com/agent-inject-template-mailu-db-secret__database: |

View File

@ -39,12 +39,12 @@ def _run_sync_blocking() -> int:
sync_done.set()
def _trigger_sync_async() -> bool:
def _trigger_sync_async(force: bool = False) -> bool:
with lock:
now = time()
if sync_running:
return False
if now - last_run < MIN_INTERVAL_SECONDS:
if not force and now - last_run < MIN_INTERVAL_SECONDS:
return False
thread = threading.Thread(target=_run_sync_blocking, daemon=True)
@ -64,15 +64,17 @@ class Handler(http.server.BaseHTTPRequestHandler):
return
wait = False
force = False
if isinstance(payload, dict):
wait = bool(payload.get("wait"))
force = bool(payload.get("force"))
if wait:
with lock:
already_running = sync_running
if not already_running:
_trigger_sync_async()
_trigger_sync_async(force=force)
sync_done.wait(timeout=WAIT_TIMEOUT_SECONDS)
with lock:
@ -87,7 +89,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
self.end_headers()
return
_trigger_sync_async()
_trigger_sync_async(force=force)
self.send_response(202)
self.end_headers()

View File

@ -25,7 +25,7 @@ resources:
images:
- name: registry.bstein.dev/bstein/ariadne
newTag: 0.1.0-1 # {"$imagepolicy": "maintenance:ariadne"}
newTag: 0.1.0-2 # {"$imagepolicy": "maintenance:ariadne"}
configMapGenerator:
- name: disable-k3s-traefik-script