Foreman 3 Upgrade - uninitialized constant Environment

Problem:
When clicking on “Manage Locations” or “Manage Organizations” → “Edit” it result in
Oops, we’re sorry but something went wrong uninitialized constant Environment” - More details you can find in the attacment foreman3_uninitialized_constant.log (19.1 KB)

Expected outcome:
It is possible to edit the locations or organizations.

Foreman and Proxy versions:
Tested Foreman 3.0.1 and Foreman 3.1.0

Distribution and version:
Rhel7.9

Other relevant data:
We upgraded from 2.5.4 to 3.0.1 (problem occurs) to 3.1.0.

Temporary fix seems to be: remove “- Environment” from “ignore_types” in table “taxonomies” in the database.
I used: “update taxonomies set ignore_types = E’—\n- User\n- SmartProxy\n- Subnet\n- ComputeResource\n- Medium\n- ProvisioningTemplate\n- Ptable\n- Domain\n- Realm\n- Hostgroup\n’ where id=XXX;”

I have exactly the same problem, even the log looks the same.
Upgrade 2.x.x → 3.0.1 → 3.1.0
new Locations working fine, but my biggest with 5500+ Hosts ends up in this error.
mismatch report fails as well.

Could you please explain a little more detailed how to fix this?

I had a look into the DB using pgAdmin, but i am a little afraid removing the wrong things.
in your psql line id=XXX ist the location?

Thanks for help!

That was excatly what i’ve done. I used the psql command to update the taxonomies table directly in the database. But not sure if this can result in other errors, db constrain conficts, …

Perhaps somebody else can verify this?

Hi,

There is already fix for this, that should get into 3.1.1, which is still not out.
In the meantime you can apply Puppet Environment in taxonomy ignore_types by stejskalleos · Pull Request #8962 · theforeman/foreman · GitHub and run purge:puppet.

For the instances with the Puppet plugin installed I need to finish the patch to fix this, but in the meantime you can fix it from foreman-rake console by running the following snippet.

    organizations = Organization.where("ignore_types LIKE '%Environment%'")
    locations = Location.where("ignore_types LIKE '%Environment%'")

    User.as_anonymous_admin do
      (organizations + locations).each do |tax|
        new_types = tax.ignore_types.reject { |type| type == "Environment" }
        tax.update ignore_types: new_types
      end
    end