Ruby errors and warnings after foreman 1.17 upgrade


I tried upgrading to foreman 1.17 this morning (on CentOS 7.4). Those upgrades usually go pretty well.

Not this time: The rake jobs that are part of the upgrade failed with things like:

/opt/theforeman/tfm/root/usr/share/gems/gems/sequel-4.20.0/lib/sequel/database/schema_generator.rb:19: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/sequel-4.20.0/lib/sequel/database/schema_generator.rb:19: warning: constant ::Bignum is deprecated
/usr/share/foreman/lib/core_extensions.rb:183: warning: already initialized constant ActiveSupport::MessageEncryptor::DEFAULT_CIPHER
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/message_encryptor.rb:22: warning: previous definition of DEFAULT_CIPHER was here
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/appender.rb:139: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/logger.rb:295: warning: constant ::Fixnum is deprecated
rake aborted!
NoMethodError: undefined method `alias_method_chain' for HostsController:Class
Did you mean?  alias_method
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_host_rundeck-0.0.2/app/controllers/concerns/foreman_host_rundeck/hosts_controller_extensions.rb:6:in `block in <module:HostsControllerExtensions>'

When I search the web for “foreman alias_method_chain”, I find lots of issues replacing alias_method_chain with other constructs, so I guess that this language element is going away (and has actually gone away with my upgrade).

Alas, when I grep /opt/theforeman for alias_method_chain, I find a number of gems, for example sprocket, foreman_column_view, foreman_host_rundeck (which is likely the culprit here), oauth, foreman-tasks and even passenger itself that still use the language construct.

If alias_method_chain has actually gone away, how did it happen that the foreman 1.17 release still ships a number of gems that make use of the construct? Or am I doing things wrong?


Foreman 1.17 ships with Rails 5 which has removed alias_method_chain.
Unfortunately, looks like the foreman_host_rundeck plugin, which is no longer maintained, does make use of this method, and is incompatible with Foreman 1.17.
I’m afraid that unless a new maintainer steps up and fixes all the compatibility issues (there may be others besides this one), you will have to drop the plugin or you won’t be able to upgrade to newer versions.
There may be other plugins that need updating for 1.17 compatibility as well, I would expect that those that are maintained will release newer versions as these issues are found.

How does one know which plugins are maintained and which are not?
And how did unmaintained plugins make it into the “offiicial” 1.17 repo?

Thank you for bringing this issue to our attention. In most cases, unmaintained plugins will have their github repos archived.
I opened a discussion on the development board to see how we can better handle this situation: Unmaintaned/incompatible plugins in 1.17 repos

Thanks for forwarding. Setting the github repository archived is a quite final move, with the following consequences:

  • even most trivial patches won’t get filed any more, or they will rot away in a fork of the archive without anybody noticing, even the people neeting the patch.
  • it’s a clear sign of “we don’t care any more at all and will not even roll a new release if somebody else does everything else, if you want your one-liner in the module, you need to take it over including all reponsibility yourself”

I am not sure whether this is a signal a vendor actually wants to send, and I’m just mentioning that without taking any real criticism.

Turns out this was actually announced a couple of weeks ago, after a very long period (over two years) with no activity in the repo at all.
Like the announcement stated, if someone is interested in stepping up and maintaining the plugin, they are by all means welcome to do so and the repo will be unarchived. Maintaining a plugin requires some effort even to prevent such breakage caused by updated versions of Foreman, and there is a limit to the ability and interest people have in maintaining a project they no longer use. In my opinion, it is better to clearly indicate that a certain project is unmaintained, rather then letting it rot and have people put in time and effort to send patches that will never be reviewed.

Finally, I’m not sure as to what “vendor” exactly you are referring to. Foreman and its plugins are open source projects that are maintained by multiple people, some as part of their day job (at multiple companies) and some in their spare time. There is no one vendor that makes such decisions, nor does anyone provide you any guarantee that all plugins (or Foreman core, for that matter) will be maintained forever.
However, the upside of Foreman being open source is that you, or anyone else who wishes to do so, can pick up such unmaintained projects and bring them back to life.

I had also problems with the upgrade in the DB migration step:

$ sudo foreman-rake db:migrate
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
rake aborted!
NoMethodError: undefined method alias_method_chain' for #<Class:0x0000000e248b60> Did you mean? alias_method /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/dynamic_matchers.rb:22:inmethod_missing’
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_chef-0.6.0/app/models/foreman_chef/concerns/host_extensions.rb:9:in block in <module:HostExtensions>' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/concern.rb:120:inclass_eval’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/concern.rb:120:in append_features' /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_chef-0.6.0/lib/foreman_chef/engine.rb:91:ininclude’
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_chef-0.6.0/lib/foreman_chef/engine.rb:91:in block in <class:Engine>' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:413:ininstance_exec’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:413:in block in make_lambda' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:197:inblock (2 levels) in halting’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:601:in block (2 levels) in default_terminator' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:600:incatch’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:600:in block in default_terminator' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:198:inblock in halting’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:507:in block in invoke_before' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:507:ineach’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:507:in invoke_before' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:130:inrun_callbacks’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/reloader.rb:87:in prepare!' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application/finisher.rb:61:inblock in module:Finisher
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in instance_exec' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:inrun’
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:59:in block in run_initializers' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:58:inrun_initializers’
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:353:in initialize!' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:inpublic_send’
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:in method_missing' /usr/share/foreman/config/environment.rb:5:in<top (required)>’
/usr/share/foreman/vendor/ruby/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require' /usr/share/foreman/vendor/ruby/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:inrequire’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in block in require' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:inload_dependency’
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in require' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:329:inrequire_environment!’
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:445:in `block in run_tasks_blocks’
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

It seems that foreman_chef also uses alias_method_chain.

@Marek_Hulan it seems a new gem release of foreman_chef would be needed…

You are right. I checked github and there is already a fix for this:
But the latest gem is version 0.6. Who can release the gem?