Bug #3468
host deletion fails when token exists
Description
This has happened when I tried to destroy the host
x ERROR: update or delete on table "hosts" violates foreign key constraint "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(63) is still referenced from table "tokens". If you feel this is an error with Foreman itself, please open a new issue with Foreman ticketing system, You would probably need to attach the Full trace and relevant log entries. PG::Error ERROR: update or delete on table "hosts" violates foreign key constraint "tokens_host_id_fk" on table "tokens" DETAIL: Key (id)=(63) 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'
Related issues
Associated revisions
Fixes #3468 - Move token expiry to scope to avoid FK issues
(cherry picked from commit 585f328e6bbe9e8f429ddb2ccc97fb119da959b7)
Conflicts:
app/models/host/managed.rb
History
#1
Updated by Dominic Cleal over 9 years ago
Heh, #3379 too, but I couldn't reproduce it. Maybe I didn't have foreign keys working properly?
#2
Updated by Dominic Cleal over 9 years ago
- Related to Bug #3379: It's not possible to destroy hosts that have entries in the tokens table added
#3
Updated by Martin Bacovsky over 9 years ago
- Description updated (diff)
I fixed the misleading information in the description
I cen reproduce it when I set token expiration to 1 min and try to delete the host after that time.
#4
Updated by Martin Bacovsky over 9 years ago
To workaround this issue just cancel the build before deletion
#5
Updated by Greg Sutcliffe over 9 years ago
- Status changed from New to Assigned
- Assignee set to Greg Sutcliffe
- Target version set to 1.10.0
#6
Updated by Dominic Cleal over 9 years ago
- Status changed from Assigned to Ready For Testing
- Legacy Backlogs Release (now unused) set to 3
#7
Updated by Greg Sutcliffe over 9 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 585f328e6bbe9e8f429ddb2ccc97fb119da959b7.
Fixes #3468 - Move token expiry to scope to avoid FK issues