Project

General

Profile

Actions

Bug #2431

closed

Foreman MYSQL Error on hosts_and_Facts import when FQDN is missing

Added by Sam McLeod over 11 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Facts
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

hostnames removed for privacy's sake.

root@puppetmaster:~# rake -f /usr/share/foreman/Rakefile puppet:import:hosts_and_facts RAILS_ENV=production
Libvirt binding are missing - hypervisor management is disabled
Importing from /var/lib/puppet/yaml/facts
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved.net.au
Importing nameremoved
rake aborted!
Mysql::Error: Column 'name' cannot be null: INSERT INTO `hosts` (`model_id`, `serial`, `ip`, `location_id`, `certname`, `root_pass`, `build`, `enabled`, `mac`, `managed`, `updated_at`, `puppet_proxy_id`, `subnet_id`, `image_id`, `organization_id`, `last_freshcheck`, `use_image`, `domain_id`, `puppet_ca_proxy_id`, `name`, `disk`, `source_file_id`, `comment`, `operatingsystem_id`, `last_compile`, `owner_type`, `environment_id`, `medium_id`, `compute_resource_id`, `architecture_id`, `owner_id`, `image_file`, `puppet_status`, `installed_at`, `environment`, `ptable_id`, `hostgroup_id`, `uuid`, `created_at`, `last_report`) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, 0, 1, '', NULL, '2013-04-25 22:46:37', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, '2013-04-25 22:46:37', NULL)

Tasks: TOP => puppet:import:hosts_and_facts
(See full trace by running task with --trace)
root@puppetmaster:~# dpkg --list | grep foreman
ii  foreman                                    1.1.1+debian1                Systems management web interface
rc  foreman-mysql                              1.1.1+debian1                metapackage providing MySQL dependencies for Foreman
ii  foreman-proxy                              1.1+debian1                  RESTful proxies for DNS, DHCP, TFTP, and Puppet
root@puppetmaster:~# dpkg --list | grep puppet
ii  facter                                     1.6.18-1puppetlabs1          Ruby module for collecting simple facts about a host operating system
ii  hiera                                      1.1.2-1puppetlabs1           A simple pluggable Hierarchical Database.
ii  puppet                                     2.6.2-5+squeeze7             Centralized configuration management - agent startup and compatibility scripts
ii  puppet-common                              2.6.2-5+squeeze7             Centralized configuration management
iF  puppet-dashboard                           1.2.23-1puppetlabs1          Dashboard for Puppet
ii  puppetlabs-release                         1.0-5                        "Package to install Puppet Labs gpg key and apt repo" 
ii  puppetmaster                               2.6.2-5+squeeze7             Centralized configuration management - master startup and compatibility scripts
root@puppetmaster:~# cat /etc/debian_version 
6.0.7
root@puppetmaster:~# uname -a
Linux puppetmaster 3.2.0-0.bpo.4-686-pae #1 SMP Debian 3.2.35-2~bpo60+1 i686 GNU/Linux

root@puppetmaster:~# rails --version
Rails 2.3.5
root@puppetmaster:~# ruby --version
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]

I've tried looking through /var/lib/puppet/yaml/facts/* to see if I can find any yaml's with dodgy characters etc... but I can't see anything.
I believe this happened after upgrading foreman, but we only noticed the cron job failing a few days ago so I can't be certain.


Related issues 1 (0 open1 closed)

Has duplicate Foreman - Bug #3154: Failed to import facts: undefined method `downcase' for nil:NilClassDuplicate09/27/2013Actions
Actions #1

Updated by Sam McLeod over 11 years ago

OK we just fixed it - we removed all hosts that didn't have a FQDN, we found that once this was done there were actually duplicates of those hosts that existed with the FQDN.

Can close this one off.

Actions #2

Updated by Dominic Cleal over 11 years ago

  • Status changed from New to Closed

Thanks for finding the cause Sam!

Actions #3

Updated by Sam McLeod over 11 years ago

Hi,

I actually need this ticket re-opened.
Although deleting the hosts that the rake complains about worked, as soon as those hosts did their next puppet run forman's rake complained about those same hosts again.

I ran the yaml files for those hosts through several yaml syntax checkers and looked them over from top to bottom but I can't see any issues?

Actions #4

Updated by Dominic Cleal over 11 years ago

  • Status changed from Closed to Feedback

Do your host have an "fqdn" fact? The resolution of this changed in Facter 1.7.0 to use `hostname -f` which has broken a few (perhaps misconfigured) installations.

Actions #5

Updated by Sam McLeod over 11 years ago

Dominic Cleal wrote:

Do your host have an "fqdn" fact? The resolution of this changed in Facter 1.7.0 to use `hostname -f` which has broken a few (perhaps misconfigured) installations.

Hi Dominic,

Thanks for pointing us in the right direction.
The hosts were unaware of the fqdn's - they didn't have the fact at all.

We fixed this by added the fqdn to /etc/hosts on the 127.0.1.1 line.
This caused the fqdn fact to be created and then properly handed the information to foreman.

I'm not sure if this is a common issue but it may be other adding some more description error information to the rake task as to why it fails.

Actions #6

Updated by Dominic Cleal over 11 years ago

  • Subject changed from Foreman MYSQL Error on hosts_and_Facts import to Foreman MYSQL Error on hosts_and_Facts import when FQDN is missing
  • Category set to Facts
  • Status changed from Feedback to New
Actions #7

Updated by Dominic Cleal about 11 years ago

  • Description updated (diff)
  • Status changed from New to Ready For Testing
  • Target version set to 1.3.0

This PR from Ash Caire makes Foreman fall back to the certname if the FQDN's missing, which I'm pretty sure will fix the rake task too as they share a code path.

https://github.com/theforeman/foreman/pull/836

Actions #8

Updated by Anonymous about 11 years ago

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

Updated by Dominic Cleal about 11 years ago

  • Has duplicate Bug #3154: Failed to import facts: undefined method `downcase' for nil:NilClass added
Actions

Also available in: Atom PDF