fix(mailu): allow forced sync
This commit is contained in:
parent
901f3e797c
commit
9ff88f7f13
@ -30,7 +30,7 @@ spec:
|
|||||||
app: mailu-sync-listener
|
app: mailu-sync-listener
|
||||||
annotations:
|
annotations:
|
||||||
vault.hashicorp.com/agent-inject: "true"
|
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/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-secret-mailu-db-secret__database: "kv/data/atlas/mailu/mailu-db-secret"
|
||||||
vault.hashicorp.com/agent-inject-template-mailu-db-secret__database: |
|
vault.hashicorp.com/agent-inject-template-mailu-db-secret__database: |
|
||||||
|
|||||||
@ -39,12 +39,12 @@ def _run_sync_blocking() -> int:
|
|||||||
sync_done.set()
|
sync_done.set()
|
||||||
|
|
||||||
|
|
||||||
def _trigger_sync_async() -> bool:
|
def _trigger_sync_async(force: bool = False) -> bool:
|
||||||
with lock:
|
with lock:
|
||||||
now = time()
|
now = time()
|
||||||
if sync_running:
|
if sync_running:
|
||||||
return False
|
return False
|
||||||
if now - last_run < MIN_INTERVAL_SECONDS:
|
if not force and now - last_run < MIN_INTERVAL_SECONDS:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
thread = threading.Thread(target=_run_sync_blocking, daemon=True)
|
thread = threading.Thread(target=_run_sync_blocking, daemon=True)
|
||||||
@ -64,15 +64,17 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
|||||||
return
|
return
|
||||||
|
|
||||||
wait = False
|
wait = False
|
||||||
|
force = False
|
||||||
if isinstance(payload, dict):
|
if isinstance(payload, dict):
|
||||||
wait = bool(payload.get("wait"))
|
wait = bool(payload.get("wait"))
|
||||||
|
force = bool(payload.get("force"))
|
||||||
|
|
||||||
if wait:
|
if wait:
|
||||||
with lock:
|
with lock:
|
||||||
already_running = sync_running
|
already_running = sync_running
|
||||||
|
|
||||||
if not already_running:
|
if not already_running:
|
||||||
_trigger_sync_async()
|
_trigger_sync_async(force=force)
|
||||||
|
|
||||||
sync_done.wait(timeout=WAIT_TIMEOUT_SECONDS)
|
sync_done.wait(timeout=WAIT_TIMEOUT_SECONDS)
|
||||||
with lock:
|
with lock:
|
||||||
@ -87,7 +89,7 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
|||||||
self.end_headers()
|
self.end_headers()
|
||||||
return
|
return
|
||||||
|
|
||||||
_trigger_sync_async()
|
_trigger_sync_async(force=force)
|
||||||
self.send_response(202)
|
self.send_response(202)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ resources:
|
|||||||
|
|
||||||
images:
|
images:
|
||||||
- name: registry.bstein.dev/bstein/ariadne
|
- name: registry.bstein.dev/bstein/ariadne
|
||||||
newTag: 0.1.0-1 # {"$imagepolicy": "maintenance:ariadne"}
|
newTag: 0.1.0-2 # {"$imagepolicy": "maintenance:ariadne"}
|
||||||
|
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: disable-k3s-traefik-script
|
- name: disable-k3s-traefik-script
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user