feat(hub): add fleet distribution policy controls and unblock update checks
CI Test Suite / Run Component Tests & Pipeline Verification (push) Successful in 2m1s
CI Test Suite / Run Component Tests & Pipeline Verification (push) Successful in 2m1s
This commit is contained in:
+5
-29
@@ -1497,12 +1497,6 @@ def sync_upstream_packages_api(auth_user: str = Depends(require_admin_auth)):
|
||||
"""
|
||||
Downloads latest client binary packages from upstream release assets to local Hub storage.
|
||||
"""
|
||||
db_path = SERVER_STATE.get("config", {}).get("db_path", DEFAULT_DB_FILE)
|
||||
if not is_feature_licensed("auto_update", db_path):
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail="Fleet package synchronization requires an active license with the 'auto_update' capability."
|
||||
)
|
||||
mgr: ServerUpdateManager = SERVER_STATE.get("update_manager") or UPDATE_MANAGER
|
||||
results = mgr.sync_upstream_packages(force=True)
|
||||
return {
|
||||
@@ -1519,16 +1513,9 @@ def update_server_update_config(req: ServerUpdateConfigRequest, auth_user: str =
|
||||
"""
|
||||
Updates fleet auto-update settings (on/off switch and automatic vs manual acquisition mode).
|
||||
"""
|
||||
db_path = SERVER_STATE.get("config", {}).get("db_path", DEFAULT_DB_FILE)
|
||||
config = SERVER_STATE.get("config", {})
|
||||
mgr: ServerUpdateManager = SERVER_STATE.get("update_manager") or UPDATE_MANAGER
|
||||
|
||||
if req.auto_update_enabled and not is_feature_licensed("auto_update", db_path):
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail="Fleet auto-update requires an active license with the 'auto_update' capability."
|
||||
)
|
||||
|
||||
mode = (req.update_mode or "auto").lower()
|
||||
if mode not in ("auto", "manual"):
|
||||
raise HTTPException(status_code=400, detail="Invalid update_mode. Must be 'auto' (fetch from upstream) or 'manual' (provided only).")
|
||||
@@ -1550,7 +1537,7 @@ def update_server_update_config(req: ServerUpdateConfigRequest, auth_user: str =
|
||||
except Exception as e:
|
||||
print(f"[!] Warning: Could not save config file: {e}")
|
||||
|
||||
# If enabled and switched to auto mode, optionally trigger sync in background
|
||||
# If enabled and in auto mode, trigger upstream check
|
||||
if mgr.auto_update_enabled and mgr.update_mode == "auto":
|
||||
try:
|
||||
mgr.check_upstream_updates(force=False, auto_download_clients=True)
|
||||
@@ -1594,14 +1581,6 @@ def check_client_update(
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not is_feature_licensed("auto_update", db_path):
|
||||
return {
|
||||
"update_available": False,
|
||||
"current_version": current_version or "0.0.0",
|
||||
"target_version": current_version or "0.0.0",
|
||||
"reason": "Fleet auto-update is not authorized by the server license."
|
||||
}
|
||||
|
||||
return mgr.check_client_update(client_id=client_id, os_type=target_os, current_version=current_version, arch=arch)
|
||||
|
||||
|
||||
@@ -2363,13 +2342,10 @@ async def update_checker_loop(interval_hours: int = 1):
|
||||
await asyncio.sleep(initial_delay)
|
||||
while True:
|
||||
try:
|
||||
db_path = SERVER_STATE.get("config", {}).get("db_path", DEFAULT_DB_FILE)
|
||||
if is_feature_licensed("auto_update", db_path):
|
||||
mgr: ServerUpdateManager = SERVER_STATE.get("update_manager") or UPDATE_MANAGER
|
||||
if mgr.auto_update_enabled:
|
||||
loop = asyncio.get_running_loop()
|
||||
should_dl = (mgr.update_mode == "auto")
|
||||
await loop.run_in_executor(None, lambda: mgr.check_upstream_updates(force=False, auto_download_clients=should_dl))
|
||||
mgr: ServerUpdateManager = SERVER_STATE.get("update_manager") or UPDATE_MANAGER
|
||||
loop = asyncio.get_running_loop()
|
||||
should_dl = bool(mgr.auto_update_enabled and mgr.update_mode == "auto")
|
||||
await loop.run_in_executor(None, lambda: mgr.check_upstream_updates(force=False, auto_download_clients=should_dl))
|
||||
except Exception as e:
|
||||
print(f"[!] Warning in update checker background loop: {e}")
|
||||
await asyncio.sleep(interval_hours * 3600)
|
||||
|
||||
Reference in New Issue
Block a user