summaryrefslogtreecommitdiff
path: root/lib/hyperstack
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-24 12:19:55 +0300
committerPaul Buetow <paul@buetow.org>2026-05-24 12:19:55 +0300
commit0052731668b768fd566a535b222becb8bdd2ee78 (patch)
tree558428546d1a30a77b849a752c75331215ff3596 /lib/hyperstack
parentbd46adb83a948655fe305b10e63cbeec55c7b33c (diff)
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.
Diffstat (limited to 'lib/hyperstack')
-rw-r--r--lib/hyperstack/config.rb4
1 files changed, 4 insertions, 0 deletions
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)