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

Distribution gems affects OpenNebula #4304

Closed
7 tasks
vholer opened this issue Mar 5, 2020 · 3 comments
Closed
7 tasks

Distribution gems affects OpenNebula #4304

vholer opened this issue Mar 5, 2020 · 3 comments

Comments

@vholer
Copy link
Contributor

vholer commented Mar 5, 2020

Description
Although we are using our own gem location (/usr/share/one/gems-dist) with all packaged Ruby dependencies to simplify installation and isolate from gems installed in the system (via distribution packages or gem tool), it looks like we still might be affected by clashing gems installed in the system. E.g., Sinatra and Rack on Debian-like systems:

root@ubuntu1804-kvm-ssh-5-10-3-828bf-0:~# dpkg -l | egrep '(-rack|sinatra)'
ii  opennebula-rubygem-rack               2.0.7-5.10.3-1                              all          Rack provides a minimal, modular and adaptable interface for developing
ii  opennebula-rubygem-rack-protection    2.0.7-5.10.3-1                              all          Protect against typical web attacks, works with all Rack apps, including Rails.
ii  opennebula-rubygem-sinatra            2.0.7-5.10.3-1                              all          Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort.
ii  ruby-rack                             1.6.4-4ubuntu0.1                            all          modular Ruby webserver interface
ii  ruby-rack-protection                  1.5.3-2+deb9u1build0.18.04.1                all          Protects against typical web attacks for Rack apps
ii  ruby-sinatra                          1.4.8-1                                     all          Ruby web-development dressed in a DSL

root@ubuntu1804-kvm-ssh-5-10-3-828bf-0:~# GEM_HOME=/usr/share/one/gems-dist/ GEM_PATH=/usr/share/one/gems-dist irb
irb(main):001:0> require 'sinatra'
/usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/show_exceptions.rb:16: warning: already initialized constant Rack::ShowExceptions::CONTEXT
/usr/lib/ruby/vendor_ruby/rack/showexceptions.rb:16: warning: previous definition of CONTEXT was here
/usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/show_exceptions.rb:114: warning: already initialized constant Rack::ShowExceptions::TEMPLATE
/usr/lib/ruby/vendor_ruby/rack/showexceptions.rb:115: warning: previous definition of TEMPLATE was here
=> true

irb(main):002:0> use Rack::Session::Pool, :key => 'sunstone'
Traceback (most recent call last):
       12: from /usr/bin/irb:11:in `<main>'
       11: from (irb):2
       10: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
        9: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
        8: from /usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/session/pool.rb:6:in `<top (required)>'
        7: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
        6: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
        5: from /usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:10:in `<top (required)>'
        4: from /usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:12:in `<module:Rack>'
        3: from /usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:14:in `<module:Session>'
        2: from /usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:200:in `<module:Abstract>'
        1: from /usr/share/one/gems-dist/gems/rack-2.0.7/lib/rack/session/abstract/id.rb:202:in `<class:Persisted>'
NameError (uninitialized constant Rack::Session::Abstract::Persisted::RACK_SESSION)

Expected behavior
Wrong version of (Rack/Sinatra) gem installed system-wide doesn't affect OpenNebula (Sunstone).

Details

  • Version: 5.10.0

Progress Status

  • Branch created
  • Code committed to development branch
  • Testing - QA
  • Documentation
  • Release notes - resolved issues, compatibility, known issues
  • Code committed to upstream release/hotfix branches
  • Documentation committed to upstream release/hotfix branches
@mreschke
Copy link

mreschke commented Apr 9, 2020

I am performing a fresh install of OpenNebula 5.10 on Debian 9 and ran into this exact issue. I cannot start systemctl start opennebula-sunstone or run it manually /usr/bin/ruby /usr/lib/one/sunstone/sunstone-server.rb. I just installed OpenNebula according to http://docs.opennebula.io/5.10/deployment/opennebula_installation/frontend_installation.html#ignc and I did NOT install_gems. I performed the exact same install (via ansible, so 100% exact) on a fresh Debian 10 system and sunstone starts perfectly. Is there no way to get sunstone working on Debian 9 right now, even with a patch to one of the RB files? I just performed an upgrade on a production debian 9 system from 5.6 to 5.10 and now I can't start sunstone. Would hate to reverse the upgrade just for this issue.

@mreschke
Copy link

mreschke commented Apr 9, 2020

Just an FYI, my hacky fix for my Debian 9 upgraded system.

I installed rbenv as the oneadmin user and rbenv install 2.5.5 on Debian 9 instead of the 2.3.3 and changed the /usr/bin/ruby symlink to point to /var/lib/one/.rbenv/shims/ruby. Unlinked the /usr/share/one/gems and ran the ./install_gems on the context of my oneadmin's rbenv 2.5.5 shell. Now my sudo systemctl start opennebula-sunstone or sudo /usr/bin/ruby /usr/lib/one/sunstone/sunstone-server.rb now works without the Rack error.

@vholer vholer self-assigned this Apr 14, 2020
vholer pushed a commit that referenced this issue Apr 21, 2020
Remove vendor_ruby and site_ruby directories from $LOAD_PATH, so
that distribution gems installed directly into loadable path
without need to use rubygems are not loaded by require.
rsmontero pushed a commit that referenced this issue Apr 22, 2020
Remove vendor_ruby and site_ruby directories from $LOAD_PATH, so
that distribution gems installed directly into loadable path
without need to use rubygems are not loaded by require.
vholer pushed a commit to OpenNebula/docs that referenced this issue Apr 22, 2020
vholer pushed a commit to OpenNebula/docs that referenced this issue Apr 22, 2020
rsmontero pushed a commit to OpenNebula/docs that referenced this issue Apr 22, 2020
rsmontero pushed a commit to OpenNebula/docs that referenced this issue Apr 22, 2020
rsmontero pushed a commit to OpenNebula/docs that referenced this issue Apr 22, 2020
@vholer
Copy link
Contributor Author

vholer commented Apr 23, 2020

Fixed in master (target stable 5.12.0) by removing vendor / site directories d064ee6.

For 5.10.x, the workaround is to uninstall clashing distribution packages
http://docs.opennebula.io/5.10/intro_release_notes/release_notes/known_issues.html#opennebula-services-fail-to-start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants