From c0c358cb50ee446e57dcd1632375f77da74f5305 Mon Sep 17 00:00:00 2001 From: Marek Kwaczynski Date: Thu, 18 Sep 2025 10:46:25 +0200 Subject: [PATCH] cloud_discovery: add blacklist for discovery methods Introduce a blacklist mechanism to avoid retrying failed discovery methods within the same discovery cycle. Each time a method fails validation, it is added to the blacklist. The blacklist is cleared once the device transitions to ONLINE or after all discovery methods have been attempted. This prevents repeated attempts of failing methods and ensures the discovery process progresses more reliably. Signed-off-by: Marek Kwaczynski --- .../files/usr/bin/cloud_discovery | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery b/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery index 4f6a0db8c..3cae790d3 100755 --- a/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery +++ b/feeds/tip/cloud_discovery/files/usr/bin/cloud_discovery @@ -23,6 +23,7 @@ let ubus = libubus.connect(); let uci = libuci.cursor(); let state = DISCOVER; let discovery_method = ""; +let discovery_block_list = []; let validate_time; let offline_time; let orphan_time; @@ -158,6 +159,7 @@ function set_state(set) { ulog(LOG_INFO, 'Wait for validation\n'); validate_time = time(); state = VALIDATING; + push(discovery_block_list, discovery_method); break; case ONLINE: @@ -166,6 +168,7 @@ function set_state(set) { ulog(LOG_INFO, 'Setting cloud controller to validated\n'); gateway_write({ valid: true }); discovery_state_write(); + discovery_block_list = []; } break; @@ -234,6 +237,13 @@ function time_is_valid() { return valid; } +function is_discover_method_blacked() { + if (discovery_method in discovery_block_list) + return true; + + return false; +} + function interval_handler() { printf(`State ${state}\n`); switch(state) { @@ -267,15 +277,17 @@ function interval_handler() { return; discovery_method = DISCOVER_DHCP; - if (discover_dhcp()) + if (!is_discover_method_blacked() && discover_dhcp()) return; discovery_method = DISCOVER_FLASH; - if (!discover_flash()) + if (!is_discover_method_blacked() && !discover_flash()) return; discovery_method = DISCOVER_LOOKUP; redirector_lookup(); + + discovery_block_list = []; break; case VALIDATING: