Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidekiq tries to connect to redis during assets precompilation #4517

Closed
frankhuster opened this issue Mar 31, 2020 · 1 comment
Closed

Sidekiq tries to connect to redis during assets precompilation #4517

frankhuster opened this issue Mar 31, 2020 · 1 comment

Comments

@frankhuster
Copy link

ruby 2.5.3p105
sidekiq-pro 5.0.1
rails 5.2.2

Dockerfile

RUN RAILS_ASSETS_PRECOMPILE=true RAILS_ENV=production bin/rails assets:precompile

config/initializers/sidekiq.rb

#
# RAILS_ASSETS_PRECOMPILE is set to true in Dockerfile in order to prevent sidekiq
# from connecting to prod redis during the bin/rails assets:precompile step
#

unless ENV['RAILS_ASSETS_PRECOMPILE'] == "true"

  redis_configuration = {
    host: ENV.fetch("REDIS_HOST", Settings.redis.host), # allow redis host to be overridden by spec suite
    port: Settings.redis.port,
    id: nil # https://github.com/mperham/sidekiq/issues/3518
  }

  Sidekiq.configure_server do |config|
    config.redis = redis_configuration
  end

  Sidekiq.configure_client do |config|
    config.redis = redis_configuration
  end

  schedule_file = "config/schedule.yml"
  if File.exist?(schedule_file) && Sidekiq.server?
    Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
  end

end

GCP Build details

Step #1: INFO[0434] RUN RAILS_ASSETS_PRECOMPILE=true RAILS_ENV=production bin/rails assets:precompile 
Step #1: INFO[0434] cmd: /bin/sh                                 
Step #1: INFO[0434] args: [-c RAILS_ASSETS_PRECOMPILE=true RAILS_ENV=production bin/rails assets:precompile] 
Step #1: Yarn executable was not detected in the system.
Step #1: Download Yarn at https://yarnpkg.com/en/docs/install
Step #1: I, [2020-03-31T00:04:07.122499 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin-8db4f6c3dc2b51dd932c32ae09cd81c0e251c0e2831f61bd9848ee44180e258d.css
Step #1: I, [2020-03-31T00:04:07.125147 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin-8db4f6c3dc2b51dd932c32ae09cd81c0e251c0e2831f61bd9848ee44180e258d.css.gz
Step #1: I, [2020-03-31T00:04:07.127587 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin/nested_menu_arrow-15084d93c65c1964d7077700ea748bd2d70cfa2d4c19707c58a9c64e232dd442.gif
Step #1: I, [2020-03-31T00:04:07.129472 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin/nested_menu_arrow_dark-7c43b8e0a5f8823875f49a093c9d7a6b374f885b6f9cc248ae9cd7e6e9b29034.gif
Step #1: I, [2020-03-31T00:04:07.134616 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin/orderable-29374dbb55b0012d78a37c614d573bb3474f0779849b478a147d0f1845ca6617.png
Step #1: I, [2020-03-31T00:04:08.092376 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin/print-cf99cbf27fb92065a9eacd28e6fad48fa72cadaf6e0918790e8d35b11d8f99f6.css
Step #1: I, [2020-03-31T00:04:08.093155 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin/print-cf99cbf27fb92065a9eacd28e6fad48fa72cadaf6e0918790e8d35b11d8f99f6.css.gz
Step #1: I, [2020-03-31T00:04:29.108846 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin-ed93c5294bc24014836ef68c6be36b8fef606d7d83f228176676270095d5e072.js
Step #1: I, [2020-03-31T00:04:29.110142 #19940]  INFO -- : Writing /opt/app/public/assets/active_admin-ed93c5294bc24014836ef68c6be36b8fef606d7d83f228176676270095d5e072.js.gz
Step #1: I, [2020-03-31T00:04:36.600994 #19940]  INFO -- : Writing /opt/app/public/assets/application-4d1ef7d0cfe96708072801d2e2cb617ff1f79fa91dedf77820129bbdc6e3639e.js
Step #1: I, [2020-03-31T00:04:36.602202 #19940]  INFO -- : Writing /opt/app/public/assets/application-4d1ef7d0cfe96708072801d2e2cb617ff1f79fa91dedf77820129bbdc6e3639e.js.gz
Step #1: I, [2020-03-31T00:04:37.197677 #19940]  INFO -- : Writing /opt/app/public/assets/application-8db4f6c3dc2b51dd932c32ae09cd81c0e251c0e2831f61bd9848ee44180e258d.css
Step #1: I, [2020-03-31T00:04:37.198575 #19940]  INFO -- : Writing /opt/app/public/assets/application-8db4f6c3dc2b51dd932c32ae09cd81c0e251c0e2831f61bd9848ee44180e258d.css.gz
Step #1: /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:362:in `rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:343:in `establish_connection'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:106:in `block in connect'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:306:in `with_reconnect'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:105:in `connect'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/newrelic_rpm-5.7.0.350/lib/new_relic/agent/instrumentation/redis.rb:120:in `connect'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:381:in `ensure_connected'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:231:in `block in process'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:319:in `logging'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:230:in `process'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:196:in `call_pipelined'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:164:in `block in call_pipeline'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:306:in `with_reconnect'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis/client.rb:162:in `call_pipeline'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/newrelic_rpm-5.7.0.350/lib/new_relic/agent/instrumentation/redis.rb:99:in `call_pipeline'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis.rb:2416:in `block in pipelined'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis.rb:52:in `block in synchronize'
Step #1: 	from /usr/local/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis.rb:52:in `synchronize'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/redis-4.1.2/lib/redis.rb:2411:in `pipelined'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/sidekiq-6.0.6/lib/sidekiq/launcher.rb:104:in `block in flush_stats'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/sidekiq-6.0.6/lib/sidekiq.rb:97:in `block in redis'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:65:in `block (2 levels) in with'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:64:in `handle_interrupt'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:64:in `block in with'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:61:in `handle_interrupt'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/connection_pool-2.2.2/lib/connection_pool.rb:61:in `with'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/sidekiq-6.0.6/lib/sidekiq.rb:94:in `redis'
Step #1: 	from /opt/app/vendor/bundle/ruby/2.5.0/gems/sidekiq-6.0.6/lib/sidekiq/launcher.rb:103:in `flush_stats'
Step #1: error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/kaniko-project/executor" failed: step exited with non-zero status: 1

@j15e
Copy link

j15e commented Apr 1, 2020

See sidekiq-cron/sidekiq-cron#278 and #4502 should fix this problem

@mperham mperham closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants