Bug #10571
closedLDAP authentication management error
Description
We upgraded an existing Foreman installation from 1.7.4 to 1.8.1 (Debian Wheezy, packages from http://deb.theforeman.org/) with an LDAP authentication source configured ("Automatically create accounts in Foreman" is enabled). After the upgrade, logging into foreman still works as expected, but trying to administer this authentication (Menu "Administer" -> "LDAP Authentication" -> click on the configured authentication) gives the error message "undefined method `usergroup_sync' for #<AuthSourceLdap:0x0000000b86e100>".
Here is the full stack trace:
NoMethodError
undefined method `usergroup_sync' for #<AuthSourceLdap:0x0000000b86e100>
app/helpers/layout_helper.rb:68:in `block in checkbox_f'
app/helpers/layout_helper.rb:169:in `block (3 levels) in field'
app/helpers/layout_helper.rb:168:in `block (2 levels) in field'
app/helpers/layout_helper.rb:158:in `block in field'
app/helpers/layout_helper.rb:157:in `field'
app/helpers/layout_helper.rb:66:in `checkbox_f'
app/views/auth_source_ldaps/_form.html.erb:30:in `block in app_views_auth_source_ldaps_form_html_erb__4138428480327788799_98702680'
app/helpers/layout_helper.rb:273:in `form_for'
app/views/auth_source_ldaps/_form.html.erb:3:in `_app_views_auth_source_ldaps__form_html_erb__4138428480327788799_98702680'
app/views/auth_source_ldaps/edit.html.erb:3:in `_app_views_auth_source_ldaps_edit_html_erb__1072392262963724023_98690780'
app/controllers/concerns/application_shared.rb:13:in `set_timezone'
app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'
Updated by Dominic Cleal over 9 years ago
- Status changed from New to Feedback
Please try running "foreman-rake db:migrate" and then restart apache2.
Updated by Christian Kaenzig over 9 years ago
Dominic Cleal wrote:
Please try running "foreman-rake db:migrate" and then restart apache2.
Hi. Yes, that solved the problem, thank you very much!
More specifically, given the output of the migration script, it looks like a column was missing in the database:
AddUsergroupSyncToAuthSources: migrating ================================-- add_column(:auth_sources, :usergroup_sync, :boolean, {:null=>false, :default=>true})
-> 0.4205s
AddUsergroupSyncToAuthSources: migrated (0.4209s) =======================
I had to clean several hosts from foreman as the migration script often failed with "Validation failed: IP address has already been taken" although I couldn't find any duplicates in IP addresses by searching in facts. This is not an issue for me however as Foreman is only populated by Puppet reports and is not used as an ENC. My guess is that if the DB migration script was run by a package post-install script (I'm not sure of that), it probably failed and left the database unmigrated.
Thanks again, the issue is now solved for me.
Updated by Dominic Kaiser over 9 years ago
So I have confirmed the same behavior. I tried to complete the same upgrade process from 1.7.2 to 1.8.1 and found that db:migrate does not complete. Running foreman-rake db:migrate does not complete as it says:
-- Migrated adnetdb02.ourdomainblahblah.net-eth0 to nics
rake aborted!
I am running foreman as an ENC so to delete a bunch of hosts is not the ideal solution to try to get the script to work with all hosts. I am running this on Centos 6.6. I have a few hundred hosts so deleting hosts until I get to the script finishing does not work for me. I have never had an issue before with upgrades.
Here is full output from --trace
- Invoke db:migrate (first_time)
- Invoke environment (first_time)
- Execute environment
- Invoke db:load_config (first_time)
- Execute db:load_config
- Execute db:migrate
CopyUnmanagedHostsToInterfaces: migrating ===============================
-- Migrating Unmanaged Host interfaces to standalone Interfaces
-- Migrated cfm01.inapnym.ourdomainblahblah.net-eth7 to nics
-- Migrated util01.inapnym.ourdomainblahblah.net-eth0 to nics
-- Migrated adnetdb01.inapnym.ourdomainblahblah.net-eth0 to nics
-- Migrated intra001.inapnym.ourdomainblahblah.net-eth0 to nics
-- Migrated jgw.inapnym.ourdomainblahblah.net-eth7 to nics
-- Migrated adnetdb02.inapnym.ourdomainblahblah.net-eth0 to nics
rake aborted!
An error has occurred, all later migrations canceled:
Validation failed: IP address has already been taken
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:56:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:in `block in save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
/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'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:in `save!'
/usr/share/foreman/db/migrate/20150508124600_copy_unmanaged_hosts_to_interfaces.rb:36:in `block in up'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation/delegation.rb:6:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation/delegation.rb:6:in `each'
/usr/share/foreman/db/migrate/20150508124600_copy_unmanaged_hosts_to_interfaces.rb:21:in `up'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/opt/rh/ruby193/root/usr/share/ruby/benchmark.rb:280:in `measure'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:410:in `block in migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:389:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:528:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:777:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:777:in `ddl_transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:719:in `block in migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:570:in `up'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:551:in `migrate'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>'
/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: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
Found this issue because initially the ldap did not work did a google search and found this. From this message: undefined method `usergroup_sync' for #<AuthSourceLdap:0x0000000b86e100>
Updated by Marek Hulán over 9 years ago
This might be caused by #10642, which is fixed in upcoming 1.8.2. Could you please retry with 1.8.2 (should be released soon).
Updated by Marek Hulán over 9 years ago
- Related to Bug #10642: Migration of unmanaged host can fail on primary interface added
Updated by Dominic Kaiser over 9 years ago
Ok thanks peeps! That did it updated to 1.7.5 then did the upgrade to 1.8.2 and all went fine! That was fast and worked perfectly.
Thanks again,
Dominic Kaiser