Bug 2123439

Summary: Once purged, there is no way to reenable puppet features successfully in Satellite 6.12
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: PuppetAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.12.0   
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: 2022-09-07 15:48:43 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 2022-09-01 17:28:16 UTC
Description of problem:

After using "satellite-maintain" to purge the puppet data, There is no way we can enable it back using the installer-based steps from Puppet guide 

Version-Release number of selected component (if applicable):

Red Hat Satellite 6.12 
Red Hat Satellite 6.11

How reproducible:

Always


Steps to Reproduce:
1. Install a fresh Satellite 6.12

2. Enable puppet features

# satellite-installer --enable-foreman-plugin-puppet --enable-foreman-cli-puppet --foreman-proxy-puppet true --foreman-proxy-puppetca true --foreman-proxy-content-puppet true --enable-puppet --puppet-server true --puppet-server-foreman-ssl-ca /etc/pki/katello/puppet/puppet_client_ca.crt --puppet-server-foreman-ssl-cert /etc/pki/katello/puppet/puppet_client.crt --puppet-server-foreman-ssl-key /etc/pki/katello/puppet/puppet_client.key

3. Purge puppet data completely:

# satellite-maintain plugin purge-puppet --remove-all-data


4. Repeat step to enable back puppet features.


Actual results:

At Step 4, Installer fails on db:migrate step:

~~
2022-09-01 22:26:47 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-09-01 22:26:50 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-09-01 22:26:50 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
Package versions are locked. Continuing with unlock.
2022-09-01 22:27:00 [NOTICE] [configure] Starting system configuration.
2022-09-01 22:27:11 [NOTICE] [configure] 250 configuration steps out of 2132 steps complete.
2022-09-01 22:27:28 [NOTICE] [configure] 500 configuration steps out of 2132 steps complete.
2022-09-01 22:27:31 [NOTICE] [configure] 750 configuration steps out of 2136 steps complete.
2022-09-01 22:27:39 [NOTICE] [configure] 1000 configuration steps out of 2145 steps complete.
2022-09-01 22:27:47 [NOTICE] [configure] 1250 configuration steps out of 2149 steps complete.
2022-09-01 22:28:20 [ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-09-01 22:28:20 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-09-01 22:28:38 [NOTICE] [configure] 1500 configuration steps out of 2149 steps complete.
2022-09-01 22:28:40 [NOTICE] [configure] 1750 configuration steps out of 3000 steps complete.
2022-09-01 22:28:41 [NOTICE] [configure] 2000 configuration steps out of 3000 steps complete.
2022-09-01 22:28:41 [NOTICE] [configure] 2250 configuration steps out of 3000 steps complete.
2022-09-01 22:28:41 [NOTICE] [configure] 2500 configuration steps out of 3000 steps complete.
2022-09-01 22:29:00 [NOTICE] [configure] 2750 configuration steps out of 3000 steps complete.
2022-09-01 22:29:12 [NOTICE] [configure] System configuration has finished.
~~


db:migrate itself fails :

~~
2022-09-01 22:28:20 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns:
2022-09-01 22:28:20 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: == 20121018152459 CreateHostgro
upClasses: migrating ===========================
2022-09-01 22:28:20 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: -- rename_table(:hostgroups_pup
petclasses, :hostgroup_classes)
2022-09-01 22:28:20 [ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-09-01 22:28:20 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-09-01 22:28:20 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: Evaluated in 33.49 seconds
~~


It happens as The migration code 20121018152459_create_hostgroup_classes.foreman_puppet.rb tries to rename hostgroups_puppetclasses relation to hostgroup_classes assuming the hostgroups_puppetclasses will exist but It does not exist at this point.


It's because the purge:puppet rake being executed as a part of step 3 and it drops those tables as can be seen in https://github.com/theforeman/foreman/blob/3.1-stable/lib/tasks/cleanup.rake#L19-L71 .


Expected results:

If we can disable puppet feature completely, then we should be able to enable it back as well. 


Additional info:

I tested later and the same issue can be reproduced in Satellite 6.11 as well.

And to add on, Manual execution of db:seed also fails:

~~~
# foreman-rake db:seed
rake aborted!
Foreman::PermissionMissingException: ERF73-0602 [Foreman::PermissionMissingException]: some permissions were not found: ["view_puppetclasses", "import_puppetclasses", "view_environments", "import_environments", "view_external_parameters", "create_external_parameters", "edit_external_parameters", "destroy_external_parameters"]
/usr/share/foreman/app/models/role.rb:336:in `permission_records'
/usr/share/foreman/app/models/role.rb:155:in `add_permissions'
/usr/share/foreman/app/models/role.rb:208:in `add_permissions!'
/usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:102:in `block (3 levels) in include_permissions_for_role'
/usr/share/foreman/app/models/concerns/authorizable.rb:103:in `skip_permission_check'
/usr/share/foreman/app/registries/foreman/plugin/rbac_support.rb:101:in `block (2 levels) in include_permissions_for_role'
/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'

~~~

Comment 1 Vladimír Sedmík 2022-09-02 07:00:52 UTC
This issue was reported against 6.11.0 already: https://bugzilla.redhat.com/show_bug.cgi?id=2087067

Keeping this BZ open for 6.12 fix and BZ#2087067 for 6.11.z cherrypick.

Comment 2 Brad Buckingham 2022-09-07 14:40:33 UTC
Sayan,

Do you agree that this is a duplicate of bug 2087067?  Thanks!

Comment 3 Sayan Das 2022-09-07 14:51:18 UTC
Hello 

Yes, this bug has the same request as bug 2087067 .

I haven't closed this one due to the proposal made in Comment 1 i.e. keep the new one for 6.12 and use the old one for 6.11.z.

But feel free to take the appropriate action as needed.


-- Sayan

Comment 4 Brad Buckingham 2022-09-07 15:48:43 UTC
Thanks Sayan!  I'll close as a duplicate and propose the other for both releases.  We prefer not to track multiple bugzillas for different releases, until the bugzilla is selected for a specific release.

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