don't raise an error if consul is completely unconfigured
just pretend it's empty. the caller should be responsible for dealing with missing consul data as appropriate Change-Id: I2c37d33481b55776b14c6c17e109005a75dd600b Reviewed-on: https://gerrit.instructure.com/125567 Reviewed-by: Tyler Pickett <tpickett@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Jenkins Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
7197e44389
commit
9ba80db746
|
@ -70,8 +70,7 @@ module AuthenticationMethods
|
|||
@authenticated_with_jwt = true
|
||||
rescue JSON::JWT::InvalidFormat, # definitely not a JWT
|
||||
Canvas::Security::TokenExpired, # it could be a JWT, but it's expired if so
|
||||
Canvas::Security::InvalidToken, # Looks like garbage
|
||||
Canvas::DynamicSettings::NoFallbackError # no config present for talking to consul
|
||||
Canvas::Security::InvalidToken # Looks like garbage
|
||||
# these will happen for some configurations (no consul)
|
||||
# and for some normal use cases (old token, access token),
|
||||
# so we can return and move on
|
||||
|
|
|
@ -25,7 +25,6 @@ module Canvas
|
|||
|
||||
class Error < StandardError; end
|
||||
class ConsulError < Error; end
|
||||
class NoFallbackError < Error; end
|
||||
|
||||
CONSUL_READ_OPTIONS = %i{recurse stale}.freeze
|
||||
KV_NAMESPACE = "config/canvas".freeze
|
||||
|
@ -94,8 +93,7 @@ module Canvas
|
|||
elsif @fallback_data.present?
|
||||
DynamicSettings::FallbackProxy.new(@fallback_data[prefix])
|
||||
else
|
||||
raise NoFallbackError, 'DynamicSettings.fallback_data is not set and'\
|
||||
' consul is not configured, unable to supply configuration values.'
|
||||
DynamicSettings::FallbackProxy.new({})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -54,18 +54,13 @@ module MathMan
|
|||
def with_plugin_settings
|
||||
dynamic_settings = Canvas::DynamicSettings.find('math-man')
|
||||
plugin_settings = Canvas::Plugin.find(:mathman).settings
|
||||
raise "math-man not properly configured in consul" if !dynamic_settings[:base_url] && Rails.env.production?
|
||||
settings = {
|
||||
base_url: dynamic_settings[:base_url],
|
||||
use_for_mml: plugin_settings[:use_for_mml],
|
||||
use_for_svg: plugin_settings[:use_for_svg]
|
||||
}
|
||||
yield settings
|
||||
rescue Canvas::DynamicSettings::NoFallbackError
|
||||
if Rails.env.production?
|
||||
raise
|
||||
else
|
||||
yield({})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -113,13 +113,11 @@ module Canvas
|
|||
expect(proxy).to be_a(DynamicSettings::PrefixProxy)
|
||||
end
|
||||
|
||||
it 'must raise an error when neither consul or fallback data have been configured' do
|
||||
it 'must return a FallbackProxy when neither consul or fallback data have been configured' do
|
||||
allow(DynamicSettings).to receive(:kv_client).and_return(nil)
|
||||
DynamicSettings.fallback_data = nil
|
||||
expect { DynamicSettings.find('foo') }.to raise_error(
|
||||
DynamicSettings::NoFallbackError,
|
||||
/fallback_data is not set/
|
||||
)
|
||||
expect(DynamicSettings.find('foo')).to be_a(DynamicSettings::FallbackProxy)
|
||||
expect(DynamicSettings.find('foo')['bar']).to eq nil
|
||||
end
|
||||
|
||||
it 'must return a FallbackProxy when consul is not configured' do
|
||||
|
|
Loading…
Reference in New Issue