Well messing around with the pxe template being used by a host with
tokens enabled might have caused an issue.
I attempted to change the URL from the hardcoded form to the foreman_url
function (BTW thanks Greg for the suggestion), but changing that didn't
make the token string appear. Then I tried to put the old URL back with
the host.token function, which caused the token string to show up blank
in the preview. So I decided to delete the host and try again (worked
the first time I changed to using host.token), but now Foreman is giving
me a 500 error and doesn't remove the host:
Started DELETE "/hosts/wcse-esx93.dealer.ddc" for 10.128.208.63 at
2013-11-13 17:09:12 +0000
Processing by HostsController#destroy as HTML
Parameters:
{"authenticity_token"=>"J4JQ5A8T8EAbOWanp24FnaVm/B7WRx8CXx5oidFtm6A=",
"id"=>"wcse-esx93.dealer.ddc"}
Operation FAILED: ERROR: update or delete on table "hosts" violates
foreign key constraint "tokens_host_id_fk" on table "tokens"
DETAIL: Key (id)=(131) is still referenced from table "tokens".
Rendered common/500.html.erb within layouts/application (7.6ms)
Completed 500 Internal Server Error in 422ms (Views: 14.3ms |
ActiveRecord: 27.7ms)
Full trace:
PGError
ERROR: update or delete on table "hosts" violates foreign key constraint
"tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(131) is still
referenced from table "tokens".
app/controllers/hosts_controller.rb:120:in destroy' app/models/concerns/foreman/thread_session.rb:33:in
clear_thread'
Thoughts?
···
--
_____________________
Phil Gardner
PGP Key ID 0xFECC890C
OTR Fingerprint 6707E9B8 BD6062D3 5010FE8B 36D614E3 D2F80538
OK, I got around this by canceling the build process and "unmanaging"
the host. It then let me delete the system without issue. Sorry for the
noise.
···
On 11/13/2013 12:19 PM, Phil Gardner wrote:
> Well messing around with the pxe template being used by a host with
> tokens enabled might have caused an issue.
>
> I attempted to change the URL from the hardcoded form to the foreman_url
> function (BTW thanks Greg for the suggestion), but changing that didn't
> make the token string appear. Then I tried to put the old URL back with
> the host.token function, which caused the token string to show up blank
> in the preview. So I decided to delete the host and try again (worked
> the first time I changed to using host.token), but now Foreman is giving
> me a 500 error and doesn't remove the host:
>
>
> Started DELETE "/hosts/wcse-esx93.dealer.ddc" for 10.128.208.63 at
> 2013-11-13 17:09:12 +0000
> Processing by HostsController#destroy as HTML
> Parameters:
> {"authenticity_token"=>"J4JQ5A8T8EAbOWanp24FnaVm/B7WRx8CXx5oidFtm6A=",
> "id"=>"wcse-esx93.dealer.ddc"}
> Operation FAILED: ERROR: update or delete on table "hosts" violates
> foreign key constraint "tokens_host_id_fk" on table "tokens"
> DETAIL: Key (id)=(131) is still referenced from table "tokens".
>
> Rendered common/500.html.erb within layouts/application (7.6ms)
> Completed 500 Internal Server Error in 422ms (Views: 14.3ms |
> ActiveRecord: 27.7ms)
>
>
> Full trace:
>
> PGError
> ERROR: update or delete on table "hosts" violates foreign key constraint
> "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(131) is still
> referenced from table "tokens".
> app/controllers/hosts_controller.rb:120:in `destroy'
> app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
>
> Thoughts?
–
Phil Gardner
PGP Key ID 0xFECC890C
OTR Fingerprint 6707E9B8 BD6062D3 5010FE8B 36D614E3 D2F80538
> Well messing around with the pxe template being used by a host with tokens
> enabled might have caused an issue.
>
> I attempted to change the URL from the hardcoded form to the foreman_url
> function (BTW thanks Greg for the suggestion), but changing that didn't make
> the token string appear. Then I tried to put the old URL back with the
> host.token function, which caused the token string to show up blank in the
> preview. So I decided to delete the host and try again (worked the first
> time I changed to using host.token), but now Foreman is giving me a 500
> error and doesn't remove the host:
>
>
> Started DELETE "/hosts/wcse-esx93.dealer.ddc" for 10.128.208.63 at
> 2013-11-13 17:09:12 +0000
> Processing by HostsController#destroy as HTML
> Parameters:
> {"authenticity_token"=>"J4JQ5A8T8EAbOWanp24FnaVm/B7WRx8CXx5oidFtm6A=",
> "id"=>"wcse-esx93.dealer.ddc"}
> Operation FAILED: ERROR: update or delete on table "hosts" violates foreign
> key constraint "tokens_host_id_fk" on table "tokens"
> DETAIL: Key (id)=(131) is still referenced from table "tokens".
>
> Rendered common/500.html.erb within layouts/application (7.6ms)
> Completed 500 Internal Server Error in 422ms (Views: 14.3ms | ActiveRecord:
> 27.7ms)
>
>
> Full trace:
>
> PGError
> ERROR: update or delete on table "hosts" violates foreign key constraint
> "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(131) is still
> referenced from table "tokens".
> app/controllers/hosts_controller.rb:120:in destroy' > app/models/concerns/foreman/thread_session.rb:33:in
clear_thread'
>
> Thoughts?
If you take the system out of build mode, can you delete it?
sounds like a bug to me, that until build mode is toggled, the token
does not get deleted.
Ohad
···
On Wed, Nov 13, 2013 at 7:19 PM, Phil Gardner wrote:
> --
> _____________________
> Phil Gardner
> PGP Key ID 0xFECC890C
> OTR Fingerprint 6707E9B8 BD6062D3 5010FE8B 36D614E3 D2F80538
>
> --
> You received this message because you are subscribed to the Google Groups
> "Foreman users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to foreman-users+unsubscribe@googlegroups.com.
> To post to this group, send email to foreman-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/foreman-users.
> For more options, visit https://groups.google.com/groups/opt_out.
Thats exactly what I ended up doing. Stupid thunderbird not syncing all
of my folders. Sorry for missing your reply 
···
On 11/13/2013 12:31 PM, Ohad Levy wrote:
> On Wed, Nov 13, 2013 at 7:19 PM, Phil Gardner wrote:
>> Well messing around with the pxe template being used by a host with tokens
>> enabled might have caused an issue.
>>
>> I attempted to change the URL from the hardcoded form to the foreman_url
>> function (BTW thanks Greg for the suggestion), but changing that didn't make
>> the token string appear. Then I tried to put the old URL back with the
>> host.token function, which caused the token string to show up blank in the
>> preview. So I decided to delete the host and try again (worked the first
>> time I changed to using host.token), but now Foreman is giving me a 500
>> error and doesn't remove the host:
>>
>>
>> Started DELETE "/hosts/wcse-esx93.dealer.ddc" for 10.128.208.63 at
>> 2013-11-13 17:09:12 +0000
>> Processing by HostsController#destroy as HTML
>> Parameters:
>> {"authenticity_token"=>"J4JQ5A8T8EAbOWanp24FnaVm/B7WRx8CXx5oidFtm6A=",
>> "id"=>"wcse-esx93.dealer.ddc"}
>> Operation FAILED: ERROR: update or delete on table "hosts" violates foreign
>> key constraint "tokens_host_id_fk" on table "tokens"
>> DETAIL: Key (id)=(131) is still referenced from table "tokens".
>>
>> Rendered common/500.html.erb within layouts/application (7.6ms)
>> Completed 500 Internal Server Error in 422ms (Views: 14.3ms | ActiveRecord:
>> 27.7ms)
>>
>>
>> Full trace:
>>
>> PGError
>> ERROR: update or delete on table "hosts" violates foreign key constraint
>> "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(131) is still
>> referenced from table "tokens".
>> app/controllers/hosts_controller.rb:120:in `destroy'
>> app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
>>
>> Thoughts?
>
> If you take the system out of build mode, can you delete it?
>
> sounds like a bug to me, that until build mode is toggled, the token
> does not get deleted.
>
> Ohad
–
Phil Gardner
PGP Key ID 0xFECC890C
OTR Fingerprint 6707E9B8 BD6062D3 5010FE8B 36D614E3 D2F80538
This is a known issue (Bug #3468: host deletion fails when token exists - Foreman) which
I'm currently working on fixing. Hope to have a patch by the end of the
week 
Greg
···
On 13 November 2013 17:35, Phil Gardner wrote:
PGError
ERROR: update or delete on table “hosts” violates foreign key constraint
"tokens_host_id_fk" on table “tokens” DETAIL: Key (id)=(131) is still
referenced from table “tokens”.
app/controllers/hosts_controller.rb:120:in destroy' app/models/concerns/foreman/thread_session.rb:33:in
clear_thread`