Removing Puppet environment fails

After upgrading to 3.0.1 I can’t anymore remove Puppet environment, although is “empty” to my understanding.
Error:
Failed to update environments and Puppet classes from the on-disk Puppet installation: PG::ForeignKeyViolation: ERROR: update or delete on table “environments” violates foreign key constraint “hosts_environment_id_fk” on table “hosts” DETAIL: Key (id)=(87) is still referenced from table “hosts”.

Should I manipulate the database manually? Safe to delete extra host row? UI doesn’t show any host in the environment in question.

Version 3.0.1-1.el7

BR: Mika Lehtonen

P.S. Where has the environment column disappeared from the host list? I found it useful.

@ezr-ondrej is already working on a fix for this.

1 Like

Should be fixed by https://github.com/theforeman/foreman_puppet/pull/225

So this was meant to be cleaned up in a migration, but it was not as https://github.com/theforeman/foreman/pull/8849 changes that.

So I’ll try to fix this asap, but in the meantime you’d have to:

UPDATE hosts SET environment_id = NULL

Note this is fine with the plugin installed as the environment information is stored in a host_puppet_facets table instead now and should be properly migrated there.

1 Like