Project

General

Profile

Bug #5505

Non-admin cannot remove hostgroup without removing associated puppet classes first: ERROR: update or delete on table "hostgroups" violates foreign key constraint "hostgroup_classes_hostgroup_id_fk"

Added by Petter Hassberg almost 6 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

In foreman 1.4.2 when creating a user in a role associated with the following perms:

view_hostgroups
create_hostgroups
edit_hostgroups
destroy_hostgroups

If that user is not also an admin, when deleting a hostgroup with puppet classes added to it, foreman throws this error:

ERROR: update or delete on table "hostgroups" violates foreign key constraint "hostgroup_classes_hostgroup_id_fk" on table "hostgroup_classes" DETAIL: Key (id)=(130) is still referenced from table "hostgroup_classes".
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.

PGError
ERROR: update or delete on table "hostgroups" violates foreign key constraint "hostgroup_classes_hostgroup_id_fk" on table "hostgroup_classes" DETAIL: Key (id)=(130) is still referenced from table "hostgroup_classes".
app/controllers/hostgroups_controller.rb:80:in `destroy'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'
Back

If same user edits the target hostgroup, and deselects all associated puppet modules (so that there are no references to hostgroup from puppetclasses table), and then tries again it is successful.

This looks related to Bug #3595

History

#1 Updated by Dominic Cleal over 5 years ago

  • Status changed from New to Resolved

Reported resolved via IRC, thanks.

Also available in: Atom PDF