From 0052731668b768fd566a535b222becb8bdd2ee78 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 24 May 2026 12:19:55 +0300 Subject: fix(config): memoize detected_operator_cidr failure to avoid repeated probes When all public IP probes fail (network down, DNS broken), detect_public_operator_cidr raises HyperstackVM::Error. The old code did not cache this failure, so every call to resolved_allowed_cidrs re-ran all probes, compounding slowness. Add a rescue block in detected_operator_cidr that stores the exception in @detected_operator_cidr_error and re-raises it. On subsequent calls the cached error is re-raised immediately, preventing redundant probe retries. --- lib/hyperstack/config.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/hyperstack') diff --git a/lib/hyperstack/config.rb b/lib/hyperstack/config.rb index 178429d..076cbed 100644 --- a/lib/hyperstack/config.rb +++ b/lib/hyperstack/config.rb @@ -588,12 +588,16 @@ module HyperstackVM def detected_operator_cidr return @detected_operator_cidr if defined?(@detected_operator_cidr) + raise @detected_operator_cidr_error if defined?(@detected_operator_cidr_error) configured = ENV['HYPERSTACK_OPERATOR_CIDR'].to_s.strip @detected_operator_cidr = normalize_operator_cidr(configured) unless configured.empty? return @detected_operator_cidr if defined?(@detected_operator_cidr) @detected_operator_cidr = detect_public_operator_cidr + rescue Error => e + @detected_operator_cidr_error = e + raise end def normalize_operator_cidr(value) -- cgit v1.2.3