Bug #20457
closedforeman_memcache is not compatible with 1.16
Description
(called from block in <top (required)> at /home/foreman/git/foreman/config/environments/production.rb:25) rake aborted! No such middleware to insert after: ActionDispatch::Session::ActiveRecordStore /home/foreman/gems/gems/actionpack-5.0.4/lib/action_dispatch/middleware/stack.rb:108:in `assert_index' /home/foreman/gems/gems/actionpack-5.0.4/lib/action_dispatch/middleware/stack.rb:80:in `insert_after' /home/foreman/gems/gems/railties-5.0.4/lib/rails/configuration.rb:69:in `block in merge_into' /home/foreman/gems/gems/railties-5.0.4/lib/rails/configuration.rb:68:in `each' /home/foreman/gems/gems/railties-5.0.4/lib/rails/configuration.rb:68:in `merge_into' /home/foreman/gems/gems/railties-5.0.4/lib/rails/engine.rb:507:in `block in app' /home/foreman/gems/gems/railties-5.0.4/lib/rails/engine.rb:504:in `synchronize' /home/foreman/gems/gems/railties-5.0.4/lib/rails/engine.rb:504:in `app' /home/foreman/gems/gems/railties-5.0.4/lib/rails/application/finisher.rb:37:in `block in <module:Finisher>' /home/foreman/gems/gems/railties-5.0.4/lib/rails/initializable.rb:30:in `instance_exec' /home/foreman/gems/gems/railties-5.0.4/lib/rails/initializable.rb:30:in `run' /home/foreman/gems/gems/railties-5.0.4/lib/rails/initializable.rb:55:in `block in run_initializers' /home/foreman/gems/gems/railties-5.0.4/lib/rails/initializable.rb:54:in `run_initializers' /home/foreman/gems/gems/railties-5.0.4/lib/rails/application.rb:352:in `initialize!' /home/foreman/gems/gems/railties-5.0.4/lib/rails/railtie.rb:193:in `public_send' /home/foreman/gems/gems/railties-5.0.4/lib/rails/railtie.rb:193:in `method_missing' /home/foreman/git/foreman/config/environment.rb:5:in `<top (required)>' /home/foreman/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /home/foreman/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /home/foreman/gems/gems/activesupport-5.0.4/lib/active_support/dependencies.rb:293:in `block in require' /home/foreman/gems/gems/activesupport-5.0.4/lib/active_support/dependencies.rb:259:in `load_dependency' /home/foreman/gems/gems/activesupport-5.0.4/lib/active_support/dependencies.rb:293:in `require' /home/foreman/gems/gems/railties-5.0.4/lib/rails/application.rb:328:in `require_environment!' /home/foreman/gems/gems/railties-5.0.4/lib/rails/application.rb:448:in `block in run_tasks_blocks' /home/foreman/gems/gems/rake-12.0.0/exe/rake:27:in `<top (required)>' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:74:in `load' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:74:in `kernel_load' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:27:in `run' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/cli.rb:365:in `exec' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/cli.rb:22:in `dispatch' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/cli.rb:13:in `start' /home/foreman/gems/gems/bundler-1.15.3/exe/bundle:30:in `block in <top (required)>' /home/foreman/gems/gems/bundler-1.15.3/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors' /home/foreman/gems/gems/bundler-1.15.3/exe/bundle:22:in `<top (required)>' /opt/rh/rh-ruby24/root/usr/bin/bundle:22:in `load' /opt/rh/rh-ruby24/root/usr/bin/bundle:22:in `<main>' Tasks: TOP => db:migrate => environment
Files
Updated by Daniel Lobato Garcia over 7 years ago
This is due to #10982 and we have to find another middleware to latch the ProxyAPI logging to.
Updated by Ohad Levy over 7 years ago
- Related to Feature #10982: Add logging to smart proxy requests (ProxyAPI) added
Updated by Daniel Lobato Garcia over 7 years ago
I'm able to run on development or production with Rails 5 just OK. Can you try and if it doesn't work sharing the Gemfile.lock?
Updated by Anonymous over 7 years ago
Ohad, what's the status here? I also can't reproduce.
Updated by Brett Maton over 7 years ago
I've run into a similar issue trying to upgrade 1.15.4 to 1.16.0-RC1
# scl enable tfm 'gem list rails' *** LOCAL GEMS *** apipie-rails (0.5.1) coffee-rails (4.1.0) gettext_i18n_rails (1.2.1) rails (4.2.5.1) rails-deprecated_sanitizer (1.0.3) rails-dom-testing (1.0.5) rails-html-sanitizer (1.0.3) rails-i18n (4.0.9) roadie-rails (1.1.1) sprockets-rails (3.2.0, 2.3.3) webpack-rails (0.9.8) x-editable-rails (1.5.5)
[[http://debugs.theforeman.org/foreman-debug-yXsD9.tar.xz]]
CentOS Linux release 7.4.1708 (Core) # uname -r 3.10.0-693.2.2.el7.x86_64
#rpm -qa | grep -i foreman foreman-1.16.0-0.1.RC1.el7.noarch foreman-cli-1.16.0-0.1.RC1.el7.noarch foreman-debug-1.16.0-0.1.RC1.el7.noarch foreman-installer-1.16.0-0.1.RC1.el7.noarch foreman-postgresql-1.16.0-0.1.RC1.el7.noarch foreman-proxy-1.16.0-0.1.RC1.el7.noarch foreman-selinux-1.16.0-0.3.RC1.el7.noarch tfm-rubygem-foreman_memcache-0.0.6-1.fm1_15.el7.noarch tfm-rubygem-foreman_setup-5.0.0-1.fm1_13.el7.noarch tfm-rubygem-hammer_cli_foreman-0.11.pre.develop-1.201705191236git0eeef86.el7.noarch tfm-rubygem-puppetdb_foreman-3.1.2-1.fm1_15.el7.noarch
Updated by Brett Maton over 7 years ago
Installer log file attached
Updated by Anonymous over 7 years ago
Brett, you're on RPMs with Rails 4.2, correct? That would be something different, then...
Updated by Iain Walmsley about 7 years ago
Seeing this issue aswell.
RPM Install, Foreman 1.16, Rauls 4.2.5, Memcached Plugin (works fine if I remove the plugin)
https://pastebin.mozilla.org/9074526
Any ideas? I currently use memcached so not keen on upgrading until this is resolved.
Updated by Anonymous about 7 years ago
- Project changed from Foreman to Plugins
just a shot into the dark:
does changing ActionDispatch::Session::CacheStore to ActionDispatch::Session::ActiveRecordStore in foreman_memcache's lib/foreman_memcache.rb fix this?
Updated by Anonymous about 7 years ago
- Subject changed from current develop branch fail to load under rails 5.0 to foreman_memcache is not compatible with 1.16
Updated by Ohad Levy about 7 years ago
since the memcache plugin change the session storage from db to memcache, the middleware is no longer present and the https://github.com/theforeman/foreman/blob/1.16-stable/config/application.rb#L181 line cant be fulfill.
this is defined at https://github.com/theforeman/foreman_memcache/blob/master/lib/foreman_memcache.rb#L16
Updated by Ohad Levy about 7 years ago
as a quick workaround you can simply do:
index 0995a2d..cbd2d69 100644
--- a/config/application.rb
+++ b/config/application.rb@ -172,7 +172,7
@ module Foreman
# Record request ID in logging MDC storage config.middleware.insert_before Rails::Rack::Logger, Middleware::TaggedLogging - config.middleware.insert_after ActionDispatch::Session::ActiveRecordStore, Middleware::SessionSafeLogging + config.middleware.insert_after ActionDispatch::Session::CacheStore, Middleware::SessionSafeLogging # Add apidoc hash in headers for smarter caching config.middleware.use Apipie::Middleware::ChecksumInHeaders
Updated by Scott Stonefield about 7 years ago
Ohad Levy wrote:
as a quick workaround you can simply do:
index 0995a2d..cbd2d69 100644
--- a/config/application.rb
+++ b/config/application.rb@ -172,7 +172,7
@ module Foreman[...]
I made the above changes and now receiving the following error:
no implicit conversion of nil into String (TypeError) /usr/share/foreman/config/initializers/assets.rb:73:in `join' /usr/share/foreman/config/initializers/assets.rb:73:in `block (4 levels) in <top (required)>' /usr/share/foreman/config/initializers/assets.rb:72:in `map' /usr/share/foreman/config/initializers/assets.rb:72:in `block (3 levels) in <top (required)>' /usr/share/foreman/config/initializers/assets.rb:69:in `each' /usr/share/foreman/config/initializers/assets.rb:69:in `block (2 levels) in <top (required)>' /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/lazy_load_hooks.rb:36:in `call' /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook' /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/lazy_load_hooks.rb:44:in `each' /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:30:in `instance_exec' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:30:in `run' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:55:in `block in run_initializers' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:226:in `block in tsort_each' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:429:in `each_strongly_connected_component_from' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:347:in `block in each_strongly_connected_component' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:345:in `each' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:345:in `call' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:345:in `each_strongly_connected_component' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:224:in `tsort_each' /opt/rh/rh-ruby22/root/usr/share/ruby/tsort.rb:203:in `tsort_each' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/initializable.rb:54:in `run_initializers' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/application.rb:352:in `initialize!' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/railtie.rb:194:in `public_send' /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/railtie.rb:194:in `method_missing' /usr/share/foreman/config/environment.rb:5:in `<top (required)>' /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' config.ru:3:in `block in <main>' /opt/rh/sclo-ror42/root/usr/share/gems/gems/rack-1.6.2/lib/rack/builder.rb:55:in `instance_eval' /opt/rh/sclo-ror42/root/usr/share/gems/gems/rack-1.6.2/lib/rack/builder.rb:55:in `initialize' config.ru:1:in `new' config.ru:1:in `<main>' /usr/share/passenger/helper-scripts/rack-preloader.rb:112:in `eval' /usr/share/passenger/helper-scripts/rack-preloader.rb:112:in `preload_app' /usr/share/passenger/helper-scripts/rack-preloader.rb:158:in `<module:App>' /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>' /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'
Thanks for any help on this issue.
-Scott
Updated by Iain Walmsley almost 7 years ago
Any likelihood you'll get the chance to look at this sometime soon?
Updated by Iain Walmsley almost 7 years ago
Could instead change #10982 to insert_before the Middleware following the session store? Not a neat solution at all but is there a good way to fix this in the plugin alone any more? I'm happy to raise a PR
e.g
https://github.com/theforeman/foreman/blob/develop/config/application.rb#L175
config.middleware.insert_after ActionDispatch::Session::ActiveRecordStore, Middleware::SessionSafeLogging
to
config.middleware.insert_before ActionDispatch::Flash, Middleware::SessionSafeLogging
as per below
# bin/rake middleware .... use ActiveRecord::Migration::CheckPending use ActionDispatch::Cookies use ActionDispatch::Session::ActiveRecordStore use Middleware::SessionSafeLogging use ActionDispatch::Flash use Rack::Head use Rack::ConditionalGet ...
Updated by Iain Walmsley almost 7 years ago
I'm not sure about the best approach to this but have submitted a PR to potentially make use of swap (http://guides.rubyonrails.org/rails_on_rack.html#configuring-middleware-stack) to replace the session store instead of setting CacheStore explictly?
PR - https://github.com/theforeman/foreman_memcache/pull/11
Updated by Iain Walmsley over 6 years ago
Believe this has now been addressed & merged;
https://github.com/theforeman/foreman_memcache/commit/a6f36f1341f97e2317fa653e1507faf38656158e