Bug 1849111

Summary: Red Hat Satellite upgrade to 6.6 fails if duplicate permissions are present in foreman database
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: Satellite MaintainAssignee: Anurag Patel <apatel>
Status: CLOSED DUPLICATE QA Contact: Jameer Pathan <jpathan>
Severity: high Docs Contact:
Priority: high    
Version: 6.6.0CC: aagrawal, apatel, kagarwal, kgaikwad
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-06-19 17:29:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sayan Das 2020-06-19 16:15:46 UTC
Description of problem:

Red Hat Satellite upgrade to 6.6 fails with the following errors if duplicate permissions are present in the foreman database.

~~~
satellite.log:

[ERROR 2020-01-29T20:50:09 main]  /Stage[main]/Foreman_proxy::Register/Foreman_smartproxy[satellite.example.com]: Could not evaluate: Proxy satellite.example.com cannot be retrieved: unknown error (response 500)
[ERROR 2020-01-29T20:50:09 main] /usr/share/foreman-installer/modules/foreman/lib/puppet/provider/foreman_smartproxy/rest_v3.rb:7:in `proxy'
[ERROR 2020-01-29T20:50:09 main] /usr/share/foreman-installer/modules/foreman/lib/puppet/provider/foreman_smartproxy/rest_v3.rb:13:in `id'


production.log:

2020-01-29T20:50:09 [W|app|] Could not create role 'Ansible Roles Manager': ERF73-0602 [Foreman::PermissionMissingException]: some permissions were not found:

2020-01-29T20:50:09 [E|app|] Cannot continue because some permissions were not found, please run rake db:seed and retry
2020-01-29T20:50:24 [W|app|] Could not create role 'Ansible Roles Manager': ERF73-0602 [Foreman::PermissionMissingException]: some permissions were not found: ["view_ansible_variables", "edit_ansible_variables", "destroy_ansible_variables", "create_ansible_variables", "import_ansible_variables", :view_ansible_variables, :create_ansible_variables, :import_ansible_variables, :edit_ansible_variables, :destroy_ansible_variables]
2020-01-29T20:50:24 [E|app|] Cannot continue because some permissions were not found, please run rake db:seed and retry



foreman-rake console
irb(main):036:0> Permission.pluck(:id,:name)
..
..
[309, "edit_settings"], [310, "cockpit_hosts"], [311, "view_ansible_variables"], [312, "edit_ansible_variables"], [313, "edit_ansible_variables"], [314, "destroy_ansible_variables"], [315, "create_ansible_variables"], [316, "import_ansible_variables"]]

         --> From 311 to 316, there were six permissions listed among which "edit_ansible_variables" was duplicate.
~~~

As soon as we manually delete the permission with id 313 and re-execute the satellite-installer, the upgrade will be completed successfully.


Version-Release number of selected component (if applicable):
Satellite 6.5 > 6.6 upgrade


How reproducible:

In customer environments 



Additional Info or Request:

The request here is to include a check\fix for duplicate permissions in foreman-maintain itself which can be detected during execution of "foreman-maintain upgrade check" or "satellite-maintain upgrade check" to avoid any manual troubleshooting.

Comment 2 Anand Agrawal 2020-06-19 17:29:55 UTC

*** This bug has been marked as a duplicate of bug 1849110 ***