Bug 1997186

Summary: [regression] data.yml is referring to old sync plain id which does not exist in katello_sync_plans
Product: Red Hat Satellite Reporter: Joniel Pasqualetto <jpasqual>
Component: Satellite MaintainAssignee: Eric Helms <ehelms>
Status: CLOSED ERRATA QA Contact: Griffin Sullivan <gsulliva>
Severity: high Docs Contact:
Priority: high    
Version: 6.9.0CC: ahumbe, apatel, egolov, ehelms, gsulliva, kgaikwad, msunil, ngalvin, pcreech, pdwyer, qfz769, rcavalca, risantam, rrajput, saydas
Target Milestone: 6.13.0Keywords: PrioBumpGSS, Regression, Triaged, Upgrades, WorkAround
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-foreman_maintain-1.2.6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2175007 (view as bug list) Environment:
Last Closed: 2023-05-03 13:21:03 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 Joniel Pasqualetto 2021-08-24 15:01:19 UTC
Description of problem:
foreman-maintain will try to re-enable sync plans that don't exist anymore if there are references to them on the data.yml file.

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

Satellite 6.9

How reproducible:


Steps to Reproduce:
1. Create 2 sync plans
2. Disable sync plans using foreman-maintain:

~~~
# foreman-maintain advanced procedure run sync-plans-disable
Running ForemanMaintain::Scenario
================================================================================
disable active sync plans: 
\ Total 2 sync plans are now disabled.                                [OK]      
--------------------------------------------------------------------------------
~~~

3. Remove one of the sync-plans

~~~
# hammer sync-plan delete --id 4
Sync plan destroyed.
~~~

4. Try enabling sync plans back:

~~~
# foreman-maintain advanced procedure run sync-plans-enable
Running ForemanMaintain::Scenario
================================================================================
re-enable sync plans: 
| re-enabling sync plans                                              [FAIL]    
Could not update the sync plan:
  Could not find sync_plan resource with id 4. Potential missing permissions: edit_sync_plans
--------------------------------------------------------------------------------
Scenario [ForemanMaintain::Scenario] failed.

The following steps ended up in failing state:

  [sync-plans-enable]

Resolve the failed steps and rerun
the command. In case the failures are false positives,
use --whitelist="sync-plans-enable"
~~~

Actual results:
Fail to re-enable sync plans

Expected results:
All valid sync plans would be enabled

Additional info:

BZ#1717020 was about the exact same thing and is supposed to be fixed on 6.6, however we can see it in 6.9.

Comment 2 qfz769 2022-11-11 16:02:57 UTC
I am on 6.11.4 and having this issue still..

Going with this work around while waiting for a solution - not great not terrible.
https://access.redhat.com/solutions/6967460

Red Hat, when do you expect it to be fixed?

Comment 3 Sayan Das 2022-11-11 16:24:37 UTC
Hello,

There is a much better solution present than what is documented in the KB.

A) mv /var/lib/foreman-maintain/data.yml /tmp/

B) use "hammer sync-plan list" to check the current list of sync plans and note down their IDs

C) Use "hammer sync-plan update --id X --enabled true" to enable the sync plans manually [ if found any disabled ] [ here X should be replaced by ID of the sync plan ]

D) Now fix satellite-maintain :

# satellite-maintain advanced procedure run sync-plans-disable

# cat /var/lib/foreman-maintain/data.yml 

  --> It should record the ID of currently present sync plans under "disabled" section


# satellite-maintain advanced procedure run sync-plans-enable

# cat /var/lib/foreman-maintain/data.yml 

  --> It should record the ID of currently present sync plans under "enabled" section


And now, you are good to normally use satellite-maintain or foreman-maintain command for upgrade or backup or restore without needing to whitelist any steps.

Comment 4 qfz769 2022-11-11 22:04:47 UTC
hehe fixed!

Thank you - works like a charm :)

Comment 6 Griffin Sullivan 2023-03-14 17:31:15 UTC
Verified on 6.13 snap 14

Deleting sync plans when disabled does not disrupt foreman-maintain's ability to enable the right sync plans.

Steps to Reproduce:

1. Create 2 sync plans

2. # foreman-maintain advanced procedure run sync-plans-disable

3. # hammer sync-plan delete --id 3

4. # foreman-maintain advanced procedure run sync-plans-enable

Results:

Running ForemanMaintain::Scenario
================================================================================
re-enable sync plans: 
| Total 1 sync plans are now enabled.                                 [OK]      
--------------------------------------------------------------------------------


You can also see the proper list of enabled and disabled sync plans in /var/lib/foreman-maintain/data.yml

Comment 9 errata-xmlrpc 2023-05-03 13:21:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.13 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2097