Hi Lukas,
I'll send you the db in a separate e-mail, it's 2.5 MB and I don't want
to spam it to the list 
From the foreman-rake console
irb(main):002:0> host = Host::Discovered.find_by_name("test1.netbulae.test")
=> #<Host::Discovered id: 4, name: "test1.netbulae.test", last_compile:
nil, last_report: "2016-10-03 13:35:41", updated_at: "2016-10-03
13:35:41", created_at: "2016-09-28 14:13:13", root_pass:
"*********************************", architecture_id: 1,
operatingsystem_id: 3, environment_id: 1, ptable_id: 81, medium_id: nil,
build: false, comment: "", disk: "", installed_at: nil, model_id: 2,
hostgroup_id: 1, owner_id: 1, owner_type: "Usergroup", enabled: true,
puppet_ca_proxy_id: nil, managed: true, use_image: nil, image_file: nil,
uuid: nil, compute_resource_id: nil, puppet_proxy_id: nil, certname:
nil, image_id: nil, organization_id: 1, location_id: 2, type:
"Host::Discovered", otp: nil, realm_id: nil, compute_profile_id: nil,
provision_method: nil, content_source_id: 1, grub_pass:
"*********************************", content_view_id: 2,
lifecycle_environment_id: 1, global_status: 0, lookup_value_matcher:
"fqdn=test1.netbulae.test", discovery_rule_id: nil>
irb(main):003:0> host.destroy # will fail perhaps
NoMethodError: undefined method operatingsystem' for #<Host::Discovered:0x00000003fcef60> from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activemodel-4.2.5.1/lib/active_model/attribute_methods.rb:433:in
method_missing'
from
/usr/share/foreman/app/models/concerns/orchestration/tftp.rb:16:in tftp?' from /usr/share/foreman/app/models/concerns/orchestration/tftp.rb:156:in
queue_tftp_destroy'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:432:in
block in make_lambda' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:145:in
call'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:145:in
block in halting_and_conditional' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
call'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
block in call' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
each'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
call' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:92:in
run_callbacks'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in
_run_destroy_callbacks' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/callbacks.rb:292:in
destroy'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:281:in
block in destroy' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:351:in
block in with_transaction_returning_status'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in
transaction' ... 42 levels... from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
each'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
execute' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in
block in invoke_with_call_chain'
from /opt/rh/rh-ruby22/root/usr/share/ruby/monitor.rb:211:in
mon_synchronize' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in
invoke_with_call_chain'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in
invoke' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in
invoke_task'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block (2 levels) in top_level' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
each'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block in top_level' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in
run_with_threads'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in
top_level' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in
block in run'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in
standard_exception_handling' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in
run'
from /opt/rh/rh-ruby22/root/usr/bin/rake:33:in `<main>'
irb(main):004:0> HostStatus.delete(:host_id => host.id)
NoMethodError: undefined method delete' for HostStatus:Module from (irb):4 from /opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/commands/console.rb:110:in
start'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in
start' from /usr/share/foreman/lib/tasks/console.rake:8:in
block in <top
(required)>'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in
call' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:240:in
block in execute'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
each' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
execute'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in
block in invoke_with_call_chain' from /opt/rh/rh-ruby22/root/usr/share/ruby/monitor.rb:211:in
mon_synchronize'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in
invoke_with_call_chain' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in
invoke'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in
invoke_task' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block (2 levels) in top_level'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
each' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block in top_level'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in
run_with_threads' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in
top_level'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in
block in run' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in
standard_exception_handling'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in
run' from /opt/rh/rh-ruby22/root/usr/bin/rake:33:in
<main>'
irb(main):005:0> host.destroy # should work
NoMethodError: undefined method operatingsystem' for #<Host::Discovered:0x00000003fcef60> from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activemodel-4.2.5.1/lib/active_model/attribute_methods.rb:433:in
method_missing'
from
/usr/share/foreman/app/models/concerns/orchestration/tftp.rb:16:in tftp?' from /usr/share/foreman/app/models/concerns/orchestration/tftp.rb:156:in
queue_tftp_destroy'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:432:in
block in make_lambda' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:145:in
call'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:145:in
block in halting_and_conditional' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
call'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
block in call' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
each'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:504:in
call' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:92:in
run_callbacks'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in
_run_destroy_callbacks' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/callbacks.rb:292:in
destroy'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:281:in
block in destroy' from /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/transactions.rb:351:in
block in with_transaction_returning_status'
from
/opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in
transaction' ... 42 levels... from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
each'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:235:in
execute' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:179:in
block in invoke_with_call_chain'
from /opt/rh/rh-ruby22/root/usr/share/ruby/monitor.rb:211:in
mon_synchronize' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:172:in
invoke_with_call_chain'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/task.rb:165:in
invoke' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:150:in
invoke_task'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block (2 levels) in top_level' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
each'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:106:in
block in top_level' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:115:in
run_with_threads'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:100:in
top_level' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:78:in
block in run'
from
/opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:176:in
standard_exception_handling' from /opt/rh/rh-ruby22/root/usr/share/gems/gems/rake-10.4.2/lib/rake/application.rb:75:in
run'
from /opt/rh/rh-ruby22/root/usr/bin/rake:33:in
`<main>'irb(main):006:0>
Met vriendelijke groet, With kind regards,
Jorick Astrego
Netbulae Virtualization Experts
···
On 10/03/2016 04:41 PM, Lukas Zapletal wrote:
>> I found this similar issue
>> (http://projects.theforeman.org/issues/15374) and implemented the
>> patches from github
>> (https://github.com/theforeman/foreman/pull/3672).
> All good, so far :-)
>
>> So now I'm trying to delete it and get another error:
>> ERROR: update or delete on table "hosts" violates foreign key
>> constraint "host_status_hosts_host_id_fk" on table "host_status"
>> DETAIL: Key (id)=(4) is still referenced from table "host_status".
>>
>> I managed to mess things up again and I try to avoid messing in the
>> database to remove it ;-)
> This one is new tho.
>
> Run foreman-rake console and do:
>
> host = Host::Discovered.find_by_name("my.host.xyz")
> host.destroy # will fail perhaps
> HostStatus.delete(:host_id => host.id)
> host.destroy # should work
>
> Weird state, discovered host have no host_status association. If you
> can send me database dump (if thats reasonable size) that could help.
>
>
Tel: 053 20 30 270 info@netbulae.eu Staalsteden 4-3A KvK 08198180
Fax: 053 20 30 271 www.netbulae.eu 7547 TA Enschede BTW NL821234584B01