Skip to content

Commit eae60d2

Browse files
committed
don't timeout the fleet when an agent fails
fixes CNVS-30198 TEST PLAN: 1) kill a consul local agent 2) the whole fleet should not start timing out to consul Change-Id: Ic699339862ddfd17c1cb973d93b0091d452649a5 Reviewed-on: https://gerrit.instructure.com/83627 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins QA-Review: Jeremy Putnam <jeremyp@instructure.com> Product-Review: Ethan Vizitei <evizitei@instructure.com>
1 parent ca88f85 commit eae60d2

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

lib/canvas/dynamic_settings.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class ConsulError < StandardError
77
end
88

99
KV_NAMESPACE = "config/canvas".freeze
10+
TIMEOUT_INTERVAL = 3.freeze
1011

1112
class << self
1213
attr_accessor :config, :cache, :fallback_data
@@ -77,14 +78,16 @@ def init_values(hash)
7778
store_put("#{parent_key}/#{child_key}", value)
7879
end
7980
end
81+
rescue Timeout::Error
82+
return false
8083
end
8184

8285
def store_get(key)
8386
begin
8487
# store all values that we get here to
8588
# kind-of recover in case of big failure
8689
@strategic_reserve ||= {}
87-
consul_value = Canvas.timeout_protection('consul', {raise_on_timeout: true}) do
90+
consul_value = Timeout.timeout(TIMEOUT_INTERVAL) do
8891
diplomat_get(key)
8992
end
9093

@@ -106,7 +109,7 @@ def store_get(key)
106109
end
107110

108111
def store_put(key, value)
109-
Canvas.timeout_protection('consul') do
112+
Timeout.timeout(TIMEOUT_INTERVAL) do
110113
Diplomat::Kv.put("#{KV_NAMESPACE}/#{key}", value)
111114
end
112115
end

spec/lib/canvas/dynamic_settings_spec.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,13 @@ def stub_consul_with(value)
249249
end
250250

251251
it "returns old value during connection timeout" do
252-
Canvas.stubs(:timeout_protection).with('consul', raise_on_timeout: true).
252+
253+
Timeout.stubs(:timeout).with(DynamicSettings::TIMEOUT_INTERVAL).
253254
raises(Timeout::Error, 'consul took too long')
254255
value = DynamicSettings.from_cache(parent_key, expires_in: 10.minutes)
255256
expect(value["app-host"]).to eq("rce.insops.com")
256257
end
257258

258-
it "uses cached values during TimeoutCutoff events" do
259-
Canvas.stubs(:timeout_protection).with('consul', raise_on_timeout: true).
260-
raises(TimeoutCutoff, 'consul took too long too many times')
261-
value = DynamicSettings.from_cache(parent_key, expires_in: 10.minutes)
262-
expect(value["app-host"]).to eq("rce.insops.com")
263-
end
264259
end
265260
end
266261

0 commit comments

Comments
 (0)