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

Plugins do not yet support ruby 2.4 and therefore breaks on sensu 0.29 #3

Closed
nublaii opened this issue Apr 12, 2017 · 27 comments · Fixed by #5
Closed

Plugins do not yet support ruby 2.4 and therefore breaks on sensu 0.29 #3

nublaii opened this issue Apr 12, 2017 · 27 comments · Fixed by #5
Labels

Comments

@nublaii
Copy link

nublaii commented Apr 12, 2017

After upgrading sensu to 0.29 this plugin doesn't build properly.

The error I see from the check is this:

/opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem sensu-plugins-percona (>= 0.a) (Gem::GemNotFoundException) from /opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems.rb:298:in `activate_bin_path' from /opt/sensu/embedded/bin/check-wsrep-ready.rb:22:in `<main>'

If I try to install the plugin this is what I get:

[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] determining if Sensu gem 'sensu-plugins-percona' is already installed ...
false
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-percona"]
[SENSU-INSTALL] installing Sensu gem 'sensu-plugins-percona'
Fetching: mysql-2.9.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing sensu-plugins-percona:
	ERROR: Failed to build gem native extension.

    current directory: /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mysql-2.9.1/ext/mysql_api
/opt/sensu/embedded/bin/ruby -r ./siteconf20170412-9919-1iffwnx.rb extconf.rb
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

current directory: /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR=" clean

current directory: /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mysql-2.9.1/ext/mysql_api
make "DESTDIR="
compiling mysql.c
mysql.c: In function ‘stmt_bind_result’:
mysql.c:1320:74: error: ‘rb_cFixnum’ undeclared (first use in this function)
  else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger || argv[i] == rb_cFixnum)
                                                                          ^
mysql.c:1320:74: note: each undeclared identifier is reported only once for each function it appears in
Makefile:241: recipe for target 'mysql.o' failed
make: *** [mysql.o] Error 1

make failed, exit code 2

Gem files will remain installed in /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/mysql-2.9.1 for inspection.
Results logged to /opt/sensu/embedded/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0/mysql-2.9.1/gem_make.out
[SENSU-INSTALL] failed to install Sensu gem 'sensu-plugins-percona'
[SENSU-INSTALL] you can run the sensu-install command again with --verbose for more info
[SENSU-INSTALL] please take note of any failure messages above
[SENSU-INSTALL] make sure you have build tools installed (e.g. gcc)
[SENSU-INSTALL] trying to determine the Sensu plugin homepage for sensu-plugins-percona ...
homepage: https://github.com/sensu-plugins/sensu-plugins-percona

And looking online this seems to be the cause:

The mysql gem is one of many gems which doesn't like the unification of the integer types in Ruby 2.4.

Reference: http://stackoverflow.com/questions/41520996/mysql-gem-install-error-on-ruby-2-4

P.S. I do have libmysqlclient-dev installed.

@eoly
Copy link

eoly commented Apr 19, 2017

Ran into this same issue. Had to version lock to sensu-0.28.5-2.el7 for now.

@zroeder
Copy link

zroeder commented May 1, 2017

I'm finding a similar issue with embedded ruby on the mailer handler. Has anyone on the dev team looked into this?

{"timestamp":"2017-05-01T04:33:52.745000+0000","level":"error","message":"handler output","handler":{"command":"/opt/sensu/embedded/bin/handler-mailer.rb","type":"pipe","name":"default"},"event":{"id":"42aa4101-71fc-461a-a51b-501230ba1e9a"},"output":["/opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems.rb:270:in find_spec_for_exe': can't find gem sensu-plugins-mailer (>= 0.a) (Gem::GemNotFoundException)\n\tfrom /opt/sensu/embedded/lib/ruby/site_ruby/2.4.0/rubygems.rb:298:in activate_bin_path'\n\tfrom /opt/sensu/embedded/bin/handler-mailer.rb:22:in `

'\n"]}

@xblitz
Copy link

xblitz commented May 16, 2017

having the same problem here, cannot use this plugin with sensu 0.29

@majormoses
Copy link
Member

Sorry for the issues, I am not a maintainer on the sensu project itself though I have seen several plugins run into issues with 0.29 for now I will add testing for ruby 2.4 independently of troubleshooting any omnibus issues.

@majormoses
Copy link
Member

I tried real quick to get the mysql2 gem installed in ruby 2.4 locally (outside of the context of sensu and this gem) but ran into issues. I see there are upstream issues. so unfortunately I can only recommend pinning sensu until this is resolved.

@majormoses
Copy link
Member

the issue needs to be fixed upstream: brianmario/mysql2#835

@majormoses majormoses changed the title Error after update to sensu 0.29 because of ruby 2.4 Plugins do not yet support ruby 2.4 and therefore breaks on sensu 0.29 May 17, 2017
@sodabrew
Copy link

sodabrew commented Jul 6, 2017

@majormoses I'm still waiting on a reply in brianmario/mysql2#835 to continue helping sort out the problem. I am able to use Ruby 2.4 just fine, I am not sure what's going on with your installation.

You all should definitely drop the mysql gem and switch to mysql2 because it's maintained, unlike mysql.

@majormoses
Copy link
Member

majormoses commented Jul 6, 2017

@sodabrew I have now seen this having being debated before and have challenged other maintainers on this. Switching from ruby-mysql to mysql2 gem is a hotly debated subject in the sensu community and creates a divide amongst minimalists and those that just want something easy. Here are a list of issues that stem from this and then I will finish up with my thoughts based on some private discussions as well:

The Pros:

  • better mysql support
  • not using deprecated software
  • having a sane path forward

Cons:

  • requires a c compiler, some reasons people view it as a con:
    • it as a build tool and therefore has no need for it, there is merit to this in general. IMHO each check should be evaluated on a case by case basis with cost benefit analysis.
    • Argued security, if someone is in your systems and you are worried about a compiler you have missed the point; they are in your base killing your dudes.
    • is currently broken in 2.4 so until that is fixed I see no reason we would change something that is working to something that is broken.

My overall opinion is that we need to do it for several reasons:

  1. Path forward, we are also gonna have to make other hard decisions on dropping support of projects that the upstream maintainers no longer support. We need to do the right thing for the community even if some are unhappy about it.
  2. This is mysql we are talking install it on a fairly small fraction of most people's infrastructure, you can still limit the blast radius to just servers that monitor mysql.
  3. This has been kicked around so many times, if its a big enough deal then someone is gonna have to write another pure ruby implementation and get the rest of the ruby community to back it as the future

However we can not do this until 2.4 is working, all the plugins support 2.4, and make sure that we give the community to voice their opinions. We have to give everyone an upgrade path even if it requires breaking changes. If someone were to revive the project I would feel very differently about this.

@majormoses
Copy link
Member

@sensu-plugins/commit-bit here we go again...

@majormoses
Copy link
Member

I tried some testing again and I was able to successfully able to get it to install on 2.4.1 and we need to test and make sure it actually works in sensu but I am more supportive of this now.

@sodabrew
Copy link

sodabrew commented Jul 6, 2017

Thanks for the links, I will catch up on the discussion and see if there's anything useful I can add.

Oh, I see, you're not using the mysql gem, you're using the ruby-mysql gem. That actually makes sense to avoid a compiler, but yeah, both are unmaintained at this point in time unfortunately :(

To be honest, I was unaware of this work until just now: https://github.com/tmtm/ruby-mysql

It's rather impressive! I'm going to update this comparison section to mention it: https://github.com/brianmario/mysql2#benchmarks-and-comparison

@mbbroberg
Copy link

To be clear on the "here we go again..." @majormoses, I take it we're talking about upgrade to 0.29 causing challenges bc of ruby 2.4? If so, I'm with you there ✊

@majormoses
Copy link
Member

majormoses commented Jul 6, 2017

@mbbroberg technically its here we go again is on 2 fronts:

  • switching from ruby-mysql without the need of a c compiler to mysql2 which does require one
  • yes ruby 2.4 breaks all the things (though looks like we have a path forward now that was not present earlier)

@majormoses majormoses mentioned this issue Jul 13, 2017
3 tasks
@xblitz
Copy link

xblitz commented Aug 3, 2017

Any updates on this?

@majormoses
Copy link
Member

majormoses commented Aug 3, 2017

is this still a problem installing? From my tests it should install just fine.

EDIT: yes it is, the tests failed in the PR that was linked and I didnt realize that.

@majormoses
Copy link
Member

I'd suggest we try loosening the deps on mysql2 and see where that goes. I am not sure but I seem to recall that they did fix it in a newer version.

@majormoses
Copy link
Member

It looks like I am able to get it to install removing mysql but keeping mysql2. As that is a pretty massive change we probably want to do some testing to make sure it does not break all the things. @sodabrew anything specific I should look for in testing that are more likely to break?

@majormoses majormoses mentioned this issue Aug 3, 2017
5 tasks
@majormoses
Copy link
Member

I have submitted a PR that we can look at and do some testing to see how much if anything it breaks.

@majormoses
Copy link
Member

It installs with my change but we need to asses the breakage of this change before figuring out whether it is a breaking change or not.

@majormoses
Copy link
Member

@xblitz if you can provide me with some gists of the checks with input and output I will feel more comfortable merging this. Otherwise I am gonna have to setup a percona cluster and do some testing.

@majormoses
Copy link
Member

I took a closer look its a bit more work than I thought but I think I might have the time this weekend to take a crack at this.

@majormoses
Copy link
Member

@xblitz I have converted everything over to mysql2 gem in the linked PR can you pull it and do some basic validation? I did a very quick test using a single node cluster locally in docker.

@sodabrew
Copy link

sodabrew commented Aug 7, 2017

My main advice to the community is that you'll have a new and different set of support issues with the mysql2 gem, because it uses the native libmysqlclient library, regarding this dependency with various distributions, or people who forget to install the dependency, or who have upgraded or installed their own MySQL in a way that conflicts with the distribution's packages.

If Sensu builds and provides its own packages and its own corresponding MySQL client packages, you can pretty well sidestep the issue for most users!

@eheydrick
Copy link
Contributor

@sodabrew Good points. We have the same issue with the postgresql plugin. As I see it the options are 1) install the client into the embedded sensu or 2) install the client using a system package and link against that. or 3) install separate ruby and mysql from source or other packages and install the plugin into that ruby.

Shipping a mysql client with sensu (or perhaps as an add-on package) would certainly sidestep a lot of the issues though I'd be concerned about the maintainability of that. Now sensu has to track upstream versions and pull in security updates, etc.

We should add a note to the README with the recommended approach if/when installation issues are encountered.

@sodabrew
Copy link

sodabrew commented Aug 8, 2017

The MySQL Connector/C and MariaDB Connector/C are great alternatives, and have a far lower rate of updates. The vast majority of MySQL security patches apply to the server and not to the client code.

@xblitz
Copy link

xblitz commented Aug 8, 2017

It seems to work with the proposed changes, of course I already had the mysql client installed on the machine.

@majormoses
Copy link
Member

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

Successfully merging a pull request may close this issue.

8 participants