Project

General

Profile

Bug #10642

Migration of unmanaged host can fail on primary interface

Added by Marek Hulán over 6 years ago. Updated over 3 years ago.

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

Description

If there's unmanaged host with interface that has IP set to it's primary interface but is not marked as primary the migration ends up in invalid state because db/migrate/20140910153654_move_host_nics_to_interfaces.rb creates new interface (skipping validations) with this IP and marks it primary. Then second migration - 20150508124600_copy_unmanaged_hosts_to_interfaces.rb - runs but here it finds the existing one from previous migration and tries to set it's hostname and save it. Unfortunately it's not FakeNic instance so it runs validations and fails on IP uniqueness validation. We can either try to skip saving of interface if it didn't change or improve detection of existing primary interface (probably in both migrations). Setting as release 1.8.2, all users with unmanaged hosts with interfaces created by puppet will hit this.

Migration error that pops up

==  CopyUnmanagedHostsToInterfaces: migrating =================================
-- Migrating Unmanaged Host interfaces to standalone Interfaces
rake aborted!
An error has occurred, all later migrations canceled:

Validation failed: IP address has already been taken


Related issues

Related to Foreman - Bug #10403: Smart Class Parameter Overrides using the FQDN fact as a match no longer applies the overrideClosed2015-05-06
Related to Foreman - Feature #10260: Allow interfaces management for unmanaged hostsClosed2015-04-24
Related to Foreman - Bug #10571: LDAP authentication management errorResolved2015-05-21

Associated revisions

Revision 19d684dd (diff)
Added by Marek Hulán over 6 years ago

Fixes #10642 - save the interface regardless of validation errors

Revision 15055fe8 (diff)
Added by Marek Hulán over 6 years ago

Fixes #10642 - save the interface regardless of validation errors

(cherry picked from commit 19d684ddf481c5ce8b30d234db28e8c336ccc272)

History

#1 Updated by Marek Hulán over 6 years ago

  • Related to Bug #10403: Smart Class Parameter Overrides using the FQDN fact as a match no longer applies the override added

#2 Updated by Simon Mügge over 6 years ago

For us this issue blocks working around that issue: http://projects.theforeman.org/issues/10571

We should db:migrate to get rid of the LDAP issue (users can't log in) but we can't db:migrate because of all our unmanaged hosts and the migration breaking.

#3 Updated by Marek Hulán over 6 years ago

  • Related to Feature #10260: Allow interfaces management for unmanaged hosts added

#4 Updated by The Foreman Bot over 6 years ago

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

#5 Updated by Marek Hulán over 6 years ago

The fix will make migration pass keeping interface in potentially invalid state. Invalid IP issue can then be changed through API (we can't do it automatically). Here's howto use API to fix that

# first find out the id of failing interface (identifier reported by migration)
curl --user 'admin:$adminpw' 'https://$foreman_url/api/v2/hosts/$host_fqdn/interfaces'
# update the interface identified by $id with real IP
curl -X PUT -H 'Content-Type: application/json' --user 'admin:$adminpw' -d '{"interface":{"ip":"$real_ip"}}' 'https://$foreman_url/api/v2/hosts/$host_fqdn/interfaces/$id'

In related task I'll allow interface management from WebUI.

#6 Updated by Marek Hulán over 6 years ago

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

#7 Updated by Marek Hulán over 6 years ago

  • Related to Bug #10571: LDAP authentication management error added

Also available in: Atom PDF