Project

General

Profile

Bug #13529

Duplicate permissions are allowed and not recognized

Added by Edward Clay over 4 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Hello,

I recently performed a yum upgrade on my katello/foreman server and evidently it upgraded me to a newer version of katello/foreman.

katello 2.4.0-7
foreman 1.10.1-1

I attempted a katello-install --upgrade and it failed with a permissions error. So I attempted the manual upgrade process found on http://www.katello.org/docs/2.2/upgrade/. It appears that the upgrade is failing on forman-rake db:migrate. I ran it with a --trace option and get the following.

  1. foreman-rake --trace db:migrate
    • Invoke db:migrate (first_time)
    • Invoke environment (first_time)
    • Execute environment
      API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
      rake aborted!
      some permissions were not found
      /usr/share/foreman/app/models/role.rb:132:in `add_permissions'
      /usr/share/foreman/app/models/role.rb:147:in `add_permissions!'
      /usr/share/foreman/app/services/foreman/plugin.rb:216:in `block in role'
      /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
      /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
      /usr/share/foreman/app/services/foreman/plugin.rb:214:in `role'
      /opt/theforeman/tfm/root/usr/share/gems/gems/ovirt_provision_plugin-1.0.1/lib/ovirt_provision_plugin/engine.rb:26:in `block (2 levels) in <class:Engine>'
      /usr/share/foreman/app/services/foreman/plugin.rb:64:in `instance_eval'
      /usr/share/foreman/app/services/foreman/plugin.rb:64:in `register'
      /opt/theforeman/tfm/root/usr/share/gems/gems/ovirt_provision_plugin-1.0.1/lib/ovirt_provision_plugin/engine.rb:17:in `block in <class:Engine>'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
      /usr/share/foreman/config/environment.rb:5:in `<top (required)>'
      /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
      /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
      /opt/rh/ruby193/root/usr/share/gems/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
      /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
      /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
      /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/application.rb:103:in `require_environment!'
      /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/application.rb:295:in `block (2 levels) in initialize_tasks'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `call'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `block in execute'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `each'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `execute'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in `block in invoke_with_call_chain'
      /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in `invoke_with_call_chain'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:176:in `block in invoke_prerequisites'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:174:in `each'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:174:in `invoke_prerequisites'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:157:in `block in invoke_with_call_chain'
      /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in `invoke_with_call_chain'
      /opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in `invoke'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in `invoke_task'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block (2 levels) in top_level'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `each'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block in top_level'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in `top_level'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in `block in run'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
      /opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in `run'
      /opt/rh/ruby193/root/usr/bin/rake:32:in `<main>'
      Tasks: TOP => db:migrate => environment

I'm not able to find the cause of this error and currently foreman is down.

db_migrate.log db_migrate.log 26.3 KB Edward Clay, 02/02/2016 05:36 PM

Related issues

Related to Discovery - Bug #9963: Upgrade from 1.2 to 2.0 fails with "some permissions were not found" ArgumentErrorClosed2015-03-31
Related to Discovery - Bug #9895: user can't vew discovery_rules with "Discovery Reader" roleClosed2015-03-25

Associated revisions

Revision 954abbaf (diff)
Added by Shlomi Zadok about 4 years ago

Fixes #13529 - Remove duplicate permissions
A migration which adds unique constraint
and removes duplicate permissions

History

#1 Updated by Edward Clay over 4 years ago

This might also be useful info from /var/log/foreman/db_migrate.log.
Performance on MRI may be improved with the concurrent-ruby-ext gem. Please see http://concurrent-ruby.com
rake aborted!
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (Could not find sqlite3 (~> 1.3.5) amongst [actionmailer-3.2.8, actionpack-3.2.8, activemodel-3.2.8, activerecord-3.2.8, activeresource-3.2.8, activesupport-3.2.8, addressable-2.3.6, algebrick-0.7.3, ancestry-2.0.0, anemone-0.7.2, angular-rails-templates-0.1.2, ansi-1.4.3, apipie-params-0.0.3, apipie-rails-0.2.6, archive-tar-minitar-0.5.2, arel-3.0.2, audited-3.0.0, audited-activerecord-3.0.0, autoparse-0.3.3, bastion-2.0.0, bigdecimal-1.1.0, builder-3.0.0, bundler-1.3.5, bundler_ext-0.3.0, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.3.3, commonjs-0.2.7, concurrent-ruby-0.9.0, concurrent-ruby-edge-0.1.0, daemons-1.1.4, deep_cloneable-2.0.2, deface-0.7.2, diff-lcs-1.1.3, docker-api-1.17.0, dynflow-0.8.5, erubis-2.7.0, excon-0.45.3, execjs-1.4.0, extlib-0.9.16, faraday-0.9.1, fast_gettext-0.9.2, fog-1.32.0, fog-aws-0.6.0, fog-core-1.32.0, fog-google-0.0.5, fog-json-1.0.2, fog-libvirt-0.0.2, fog-xml-0.1.2, foreigner-1.7.1, foreman-tasks-0.7.3, foreman_bootdisk-6.0.0, foreman_docker-1.4.1, foreman_gutterball-0.0.1, foreman_hooks-0.3.8, formatador-0.2.1, friendly_id-4.0.10.1, gettext_i18n_rails-1.2.1, google-api-client-0.8.2, haml-4.0.6, haml-rails-0.4, hashr-0.0.22, hike-1.2.1, hooks-0.2.2, hpricot-0.8.6, i18n-0.6.0, i18n_data-0.2.7, io-console-0.3, ipaddress-0.8.0, journey-1.0.4, jquery-ui-rails-4.1.2, json-1.5.5, justified-0.0.4, jwt-1.2.0, katello-2.3.1, launchy-2.4.3, ldap_fluff-0.3.7, less-2.5.1, less-rails-2.5.0, little-plugger-1.1.3, logging-1.8.2, mail-2.4.4, mime-types-1.19, minitest-2.5.1, multi_json-1.10.1, multipart-post-1.2.0, net-http-persistent-2.7, net-ldap-0.11, net-scp-1.1.0, net-ssh-2.6.7, netrc-0.7.7, nokogiri-1.5.11, oauth-0.4.7, polyglot-0.3.3, qpid_messaging-0.30.0, rabl-0.11.6, rack-1.4.1, rack-cache-1.2, rack-jsonp-1.3.1, rack-protection-1.2.0, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.2.8, railties-3.2.8, rake-0.9.2.2, rbovirt-0.0.35, rbvmomi-1.8.2, rdoc-3.9.5, rest-client-1.6.7, retriable-1.4.1, robotex-1.0.0, ruby-libvirt-0.5.2, ruby2ruby-2.1.3, ruby_parser-3.6.3, runcible-1.3.5, safemode-1.2.2, sass-3.4.9, scoped_search-3.2.1, secure_headers-1.4.1, sequel-4.20.0, sexp_processor-4.4.4, signet-0.6.0, sinatra-1.3.2, sprockets-2.12.3, sshkey-1.6.0, strong_parameters-0.2.1, thor-0.18.1, tilt-1.3.3, tire-0.6.2, treetop-1.4.10, trollop-2.0, turbolinks-2.5.3, tzinfo-0.3.33, validates_lengths_from_database-0.4.0, wicked-1.1.0, will_paginate-3.0.2])

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
Performance on MRI may be improved with the concurrent-ruby-ext gem. Please see http://concurrent-ruby.com
rake aborted!
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (Could not find sqlite3 (~> 1.3.5) amongst [actionmailer-3.2.8, actionpack-3.2.8, activemodel-3.2.8, activerecord-3.2.8, activeresource-3.2.8, activesupport-3.2.8, addressable-2.3.6, algebrick-0.7.3, ancestry-2.0.0, anemone-0.7.2, angular-rails-templates-0.1.2, ansi-1.4.3, apipie-params-0.0.3, apipie-rails-0.2.6, archive-tar-minitar-0.5.2, arel-3.0.2, audited-3.0.0, audited-activerecord-3.0.0, autoparse-0.3.3, bastion-2.0.0, bigdecimal-1.1.0, builder-3.0.0, bundler-1.3.5, bundler_ext-0.3.0, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.3.3, commonjs-0.2.7, concurrent-ruby-0.9.0, concurrent-ruby-edge-0.1.0, daemons-1.1.4, deep_cloneable-2.0.2, deface-0.7.2, diff-lcs-1.1.3, docker-api-1.17.0, dynflow-0.8.5, erubis-2.7.0, excon-0.45.3, execjs-1.4.0, extlib-0.9.16, faraday-0.9.1, fast_gettext-0.9.2, fog-1.32.0, fog-aws-0.6.0, fog-core-1.32.0, fog-google-0.0.5, fog-json-1.0.2, fog-libvirt-0.0.2, fog-xml-0.1.2, foreigner-1.7.1, foreman-tasks-0.7.3, foreman_bootdisk-6.0.0, foreman_docker-1.4.1, foreman_gutterball-0.0.1, foreman_hooks-0.3.8, formatador-0.2.1, friendly_id-4.0.10.1, gettext_i18n_rails-1.2.1, google-api-client-0.8.2, haml-4.0.6, haml-rails-0.4, hashr-0.0.22, hike-1.2.1, hooks-0.2.2, hpricot-0.8.6, i18n-0.6.0, i18n_data-0.2.7, io-console-0.3, ipaddress-0.8.0, journey-1.0.4, jquery-ui-rails-4.1.2, json-1.5.5, justified-0.0.4, jwt-1.2.0, katello-2.3.1, launchy-2.4.3, ldap_fluff-0.3.7, less-2.5.1, less-rails-2.5.0, little-plugger-1.1.3, logging-1.8.2, mail-2.4.4, mime-types-1.19, minitest-2.5.1, multi_json-1.10.1, multipart-post-1.2.0, net-http-persistent-2.7, net-ldap-0.11, net-scp-1.1.0, net-ssh-2.6.7, netrc-0.7.7, nokogiri-1.5.11, oauth-0.4.7, polyglot-0.3.3, qpid_messaging-0.30.0, rabl-0.11.6, rack-1.4.1, rack-cache-1.2, rack-jsonp-1.3.1, rack-protection-1.2.0, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.2.8, railties-3.2.8, rake-0.9.2.2, rbovirt-0.0.35, rbvmomi-1.8.2, rdoc-3.9.5, rest-client-1.6.7, retriable-1.4.1, robotex-1.0.0, ruby-libvirt-0.5.2, ruby2ruby-2.1.3, ruby_parser-3.6.3, runcible-1.3.5, safemode-1.2.2, sass-3.4.9, scoped_search-3.2.1, secure_headers-1.4.1, sequel-4.20.0, sexp_processor-4.4.4, signet-0.6.0, sinatra-1.3.2, sprockets-2.12.3, sshkey-1.6.0, strong_parameters-0.2.1, thor-0.18.1, tilt-1.3.3, tire-0.6.2, treetop-1.4.10, trollop-2.0, turbolinks-2.5.3, tzinfo-0.3.33, validates_lengths_from_database-0.4.0, wicked-1.1.0, will_paginate-3.0.2])

Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

See attached log file.

I believe I'm setup to use postgresql not sqlite.

#2 Updated by Eric Helms over 4 years ago

  • Project changed from Katello to Foreman
  • Subject changed from katello/foreman manua upgrade fails on foreman-rake db:migrate to Duplicate permissions are allowed and not recognized
  • Priority changed from High to Normal
  • Legacy Backlogs Release (now unused) deleted (113)

#3 Updated by Justin Sherrill over 4 years ago

I helped either this user or a user with the exact same issue on IRC. There are 2-3 issues that add together to cause this:

a) there is no uniqueness constraint on the permissions table for the permission name
b) The role code does not properly check for missing permissions, simply a mismatch in permission counts: https://github.com/theforeman/foreman/blob/develop/app/models/role.rb#L136

I'm not fully sure how duplicate permissions got inserted, as it seemed to be somewhere within the ovirt plugin. In IRC, i just had the user delete the duplicated permission and the problem was solved.

#4 Updated by Dominic Cleal over 4 years ago

  • Category set to DB migrations

#5 Updated by Lukas Zapletal about 4 years ago

  • Related to Bug #9963: Upgrade from 1.2 to 2.0 fails with "some permissions were not found" ArgumentError added

#6 Updated by Lukas Zapletal about 4 years ago

  • Related to Bug #9895: user can't vew discovery_rules with "Discovery Reader" role added

#7 Updated by Lukas Zapletal about 4 years ago

For the record, we had similar issue in Discovery, turned out to be a bug - we were missing resource_type for some permissions. Looks similarly for the ovirt plugin: https://github.com/theforeman/ovirt_provision_plugin/blob/master/lib/ovirt_provision_plugin/engine.rb

Not sure how to reproduce tho, user must create a permission and perhaps associate is somehow.

#8 Updated by Ohad Levy about 4 years ago

  • Assignee set to Shlomi Zadok
  • Bugzilla link set to 1357122

#9 Updated by The Foreman Bot about 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3653 added

#10 Updated by Shlomi Zadok about 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#11 Updated by Dominic Cleal about 4 years ago

  • Legacy Backlogs Release (now unused) set to 160

Also available in: Atom PDF