just report missing config as nil in log
sharding isn't necessarily set up if this fires during boot sequence Change-Id: I2d5448184f141716bd38eb29beef33fe155abdb7 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/247927 Reviewed-by: Simon Williams <simon@instructure.com> Reviewed-by: Jacob Burroughs <jburroughs@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Ethan Vizitei <evizitei@instructure.com> Product-Review: Ethan Vizitei <evizitei@instructure.com>
This commit is contained in:
parent
782ef8ef04
commit
0819d3cc80
|
@ -16,7 +16,6 @@
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
module Canvas
|
module Canvas
|
||||||
module Cache
|
module Cache
|
||||||
class NilCacheEntry < StandardError; end
|
|
||||||
# all local cache implementations share a goal of being able to expire
|
# all local cache implementations share a goal of being able to expire
|
||||||
# cache entries before they're actually gone (think credentials expiring soon, etc),
|
# cache entries before they're actually gone (think credentials expiring soon, etc),
|
||||||
# but to hold onto the stale version just in case.
|
# but to hold onto the stale version just in case.
|
||||||
|
@ -43,7 +42,6 @@ module Canvas
|
||||||
def write_entry(key, entry, options)
|
def write_entry(key, entry, options)
|
||||||
if entry.value.nil?
|
if entry.value.nil?
|
||||||
Rails.logger.warn("[LOCAL_CACHE] Writing nil value for key #{key}")
|
Rails.logger.warn("[LOCAL_CACHE] Writing nil value for key #{key}")
|
||||||
Canvas::Errors.capture_exception(:local_cache, NilCacheEntry.new("No Config For Key: #{key}"))
|
|
||||||
end
|
end
|
||||||
super(key, entry, options)
|
super(key, entry, options)
|
||||||
forever_entry = entry.dup
|
forever_entry = entry.dup
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
module Canvas
|
module Canvas
|
||||||
class DynamicSettings
|
class DynamicSettings
|
||||||
class AbsentConfigError < StandardError; end
|
|
||||||
# A class for reading values from Consul
|
# A class for reading values from Consul
|
||||||
#
|
#
|
||||||
# @attr prefix [String] The prefix to be prepended to keys for querying.
|
# @attr prefix [String] The prefix to be prepended to keys for querying.
|
||||||
|
@ -110,7 +109,6 @@ module Canvas
|
||||||
return result if result
|
return result if result
|
||||||
end
|
end
|
||||||
Rails.logger.warn("[DYNAMIC_SETTINGS] config requested which was found no-where (#{key})")
|
Rails.logger.warn("[DYNAMIC_SETTINGS] config requested which was found no-where (#{key})")
|
||||||
Canvas::Errors.capture_exception(:dynamic_settings, AbsentConfigError.new("No Config For Key: #{key}"))
|
|
||||||
nil
|
nil
|
||||||
rescue Imperium::TimeoutError => exception
|
rescue Imperium::TimeoutError => exception
|
||||||
LocalCache.fetch_without_expiration(CACHE_KEY_PREFIX + keys.first).tap do |val|
|
LocalCache.fetch_without_expiration(CACHE_KEY_PREFIX + keys.first).tap do |val|
|
||||||
|
|
|
@ -42,8 +42,6 @@ module Canvas
|
||||||
.and_return(
|
.and_return(
|
||||||
Imperium::Testing.kv_not_found_response(options: [:stale])
|
Imperium::Testing.kv_not_found_response(options: [:stale])
|
||||||
)
|
)
|
||||||
allow(Canvas::Errors).to receive(:capture_exception).with(any_args).and_call_original
|
|
||||||
expect(Canvas::Errors).to receive(:capture_exception).with(:dynamic_settings, anything)
|
|
||||||
expect(proxy.fetch('baz')).to be_nil
|
expect(proxy.fetch('baz')).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -87,15 +87,5 @@ describe LocalCache do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "allows writing nil, but will tell on you" do
|
|
||||||
expect(Canvas::Errors).to receive(:capture_exception) do |message, e|
|
|
||||||
expect(message).to eq(:local_cache)
|
|
||||||
end
|
|
||||||
LocalCache.fetch("never_seen_key") do
|
|
||||||
# nil on purpose
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
expect(LocalCache.read("never_seen_key")).to be_nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue