sanity check cache_store.yml and warn of misconfig
test-plan: - create a cache_store.yml that's not a hash - try to boot canvas, get an appropriate error - create a cache_store.yml with non-hash values for the top level keys (e.g. entire file is "cache_store: redis_store") - try to boot canvas, get an appropriate error Change-Id: I4e8965a61c11c64e1d81894e8ae316761ac12f1b Reviewed-on: https://gerrit.instructure.com/29663 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Jacob Fugal <jacob@instructure.com> QA-Review: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
parent
09388ec353
commit
b5de4b72fb
|
@ -1,3 +1,5 @@
|
|||
# Configure the cache_store by environment. Should be a hash at top level, one
|
||||
# key per environment, with configuration hashes as values.
|
||||
test:
|
||||
cache_store: redis_store
|
||||
development:
|
||||
|
|
|
@ -61,6 +61,17 @@ module Canvas
|
|||
require_dependency 'app/models/setting'
|
||||
@cache_stores = {}
|
||||
configs = Setting.from_config('cache_store', nil) || {}
|
||||
|
||||
# sanity check the file
|
||||
unless configs.is_a?(Hash)
|
||||
raise "Invalid config/cache_store.yml: Root is not a hash. See comments in config/cache_store.yml.example"
|
||||
end
|
||||
|
||||
unless configs.values.all? { |cfg| cfg.is_a?(Hash) }
|
||||
broken = configs.keys.select{ |k| !configs[k].is_a?(Hash) }.map(&:to_s).join(', ')
|
||||
raise "Invalid config/cache_store.yml: Some keys are not hashes: #{broken}. See comments in config/cache_store.yml.example"
|
||||
end
|
||||
|
||||
configs.each do |env, config|
|
||||
config = {'cache_store' => 'mem_cache_store'}.merge(config)
|
||||
case config.delete('cache_store')
|
||||
|
|
Loading…
Reference in New Issue