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

Fixes #20389 - Don't report a non numeric major version on debian sid #91

Merged
merged 1 commit into from Jul 27, 2017

Conversation

agx
Copy link
Member

@agx agx commented Jul 23, 2017

since this otherwise fails like

2017-07-23T15:39:32 07623536 [app] [W] Action failed
 | ActiveRecord::RecordInvalid: Validation failed: Major version is too long (maximum is 5 characters), Major version is not a number
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/validations.rb:79:in `raise_record_invalid'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/validations.rb:43:in `save!'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:291:in `block in save!'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:220:in `transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:291:in `save!'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/persistence.rb:51:in `create!'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_ansible-1.4.5/app/services/foreman_ansible/fact_parser.rb:14:in `operatingsystem'
…

Debian adds the numeric versions after the release to the
/etc/os-release:

http://metadata.ftp-master.debian.org/changelogs/main/b/base-files/base-files_10_changelog

The puppet fact parser uses s.th. similar.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • length of the first commit message line for f78ef06 exceeds 65 characters

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

Copy link
Member

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agx Thanks, can you add a test? To do so, take a facts_json that you want to import and put it here: https://github.com/theforeman/foreman_ansible/blob/master/test/unit/services/fact_parser_test.rb - that way we know it works "forever".

I'm fixing rubocop on other PR, but if you could fix the ones code climate mentions here that'd help a bit 😄 http://ci.theforeman.org/job/test_plugin_matrix/3479/database=postgresql,ruby=2.1,slave=fast/console

@agx
Copy link
Member Author

agx commented Jul 24, 2017

I would, but as I wrote in redmine running foreman from git is such a pita atm. When I enable the ansible module I can't even run the migrations (without it it works):

$ bundle exec rake db:migrate RAILS_ENV=test The Apipie cache is turned off. Enable it and run apipie:cache rake task to speed up API calls. rake aborted! ActiveSupport::DeprecationException: DEPRECATION WARNING: You are using a deprecated behavior, it will be removed in version 1.18, Plugin foreman_tasks must register assets via precompile_assets, not SETTINGS[:foreman_tasks]. (called from after_initialize at /var/scratch/src/foreman/foreman/app/registries/foreman/plugin/assets.rb:16) /var/scratch/src/foreman/foreman/app/registries/foreman/plugin/assets.rb:16:in `after_initialize' /var/scratch/src/foreman/foreman/app/registries/foreman/plugin.rb:67:in `register' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/foreman-tasks-0.10.0/lib/foreman_tasks/engine.rb:43:in `block in <class:Engine>' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:30:in `instance_exec' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:30:in `run' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:55:in `block in run_initializers' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:54:in `run_initializers' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:352:in `initialize!' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/railtie.rb:194:in `public_send' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/railtie.rb:194:in `method_missing' /var/scratch/src/foreman/foreman/config/environment.rb:5:in `<top (required)>' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `block in require' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:240:in `load_dependency' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:328:in `require_environment!' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:457:in `block in run_tasks_blocks' /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>' Tasks: TOP => db:migrate => environment (See full trace by running task with --trace)

so I guess I'll just keep this in the fork we run together with the other stuff and hope that it looks better in a couple of months.

Don't report a non numeric major version on debian sid

since this otherwise fails like

    2017-07-23T15:39:32 07623536 [app] [W] Action failed
     | ActiveRecord::RecordInvalid: Validation failed: Major version is too long (maximum is 5 characters), Major version is not a number
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/validations.rb:79:in `raise_record_invalid'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/validations.rb:43:in `save!'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:291:in `block in save!'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:220:in `transaction'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/transactions.rb:291:in `save!'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-4.2.9/lib/active_record/persistence.rb:51:in `create!'
     | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_ansible-1.4.5/app/services/foreman_ansible/fact_parser.rb:14:in `operatingsystem'
    …

Debian adds the numeric versions after the release to the
/etc/os-release:

    http://metadata.ftp-master.debian.org/changelogs/main/b/base-files/base-files_10_changelog

The puppet fact parser uses s.th. similar.
@agx
Copy link
Member Author

agx commented Jul 25, 2017

@dLobatog hacked around the errors by pruning the test db and using + ActiveSupport::Deprecation.behavior = [:stderr]

Testcase is attached, rubocop should be happy now too.

@dLobatog
Copy link
Member

Thanks @agx - tests passed locally, still working on fixing test_plugin_foreman_ansible_master in Jenkins..

@dLobatog dLobatog merged commit 41542e8 into theforeman:master Jul 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants