Skip to content

Commit 39bc950

Browse files
fix for stale policy and tom select put api
1 parent 42a61dc commit 39bc950

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

dockflare/app/core/access_manager.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,25 @@ def handle_access_policy_from_labels(rule_key, hostname_config_item):
508508
local_state_changed_by_access_policy = True
509509

510510
app_result = None
511+
app_update_failed = False
511512
if effective_app_id:
512513
logging.info(f"Updating Access App {effective_app_id} for {application_domain}.")
513-
app_result = update_cloudflare_access_application(
514-
effective_app_id, application_domain, desired_app_name, desired_session_duration,
515-
desired_app_launcher_visible, [application_domain], cf_access_policies_or_ids,
516-
desired_allowed_idps, desired_auto_redirect, use_reusable
517-
)
518-
else:
514+
try:
515+
app_result = update_cloudflare_access_application(
516+
effective_app_id, application_domain, desired_app_name, desired_session_duration,
517+
desired_app_launcher_visible, [application_domain], cf_access_policies_or_ids,
518+
desired_allowed_idps, desired_auto_redirect, use_reusable
519+
)
520+
except Exception as update_error:
521+
error_text = str(update_error)
522+
if "access.api.error.unknown_application" in error_text or "404" in error_text:
523+
logging.info(f"Existing Access App {effective_app_id} not found in Cloudflare (404); will recreate for {application_domain}.")
524+
app_update_failed = True
525+
else:
526+
logging.error(f"Error updating access app during reconciliation: {update_error}", exc_info=True)
527+
raise
528+
529+
if not effective_app_id or app_update_failed or not app_result:
519530
logging.info(f"Creating new Access App for {application_domain}.")
520531
app_result = create_cloudflare_access_application(
521532
application_domain, desired_app_name, desired_session_duration,

dockflare/app/templates/access_policies.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,14 @@ <h3 class="font-bold text-lg mb-4">Sync Access Policies from Cloudflare</h3>
827827
const accessGroupForm = document.getElementById('access_group_form');
828828
if (accessGroupForm) {
829829
accessGroupForm.addEventListener('submit', function(e) {
830+
// Sync tom-select values to underlying select elements before form submission
831+
if (window.enhancedCountrySelector && window.enhancedCountrySelector.tomSelect) {
832+
window.enhancedCountrySelector.tomSelect.sync();
833+
}
834+
if (window.idpTomSelect) {
835+
window.idpTomSelect.sync();
836+
}
837+
830838
const publicMode = document.getElementById('public_mode').value;
831839

832840
if (publicMode === 'false') {

dockflare/app/web/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ def stream_state_updates_route():
11631163
def event_stream():
11641164
redis_client = get_redis_client()
11651165
if not redis_client:
1166-
logging.error("SSE: Redis client not available for pub/sub")
1166+
logging.warning("SSE: Redis client not available for pub/sub (real-time updates disabled)")
11671167
yield "data: {\"type\": \"error\", \"message\": \"Redis unavailable\"}\n\n"
11681168
return
11691169

0 commit comments

Comments
 (0)