Bug 1933169

Summary: satellite clone fails while disassociate capsules from lifecycle environments
Product: Red Hat Satellite Reporter: James Jeffers <jjeffers>
Component: Satellite CloneAssignee: Anand Agrawal <aagrawal>
Status: CLOSED ERRATA QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.8.0CC: ahumbe, pcreech, zhunting
Target Milestone: 6.8.5Keywords: PrioBumpGSS, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1896468 Environment:
Last Closed: 2021-03-31 19:38:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description James Jeffers 2021-02-25 20:44:43 UTC
+++ This bug was initially created as a clone of Bug #1896468 +++

Description of problem:
Following errors occurs while running satellite clone

~~
2020-11-10 11:02:49,593 p=48208 u=root |  fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["psql", "foreman", "-c", "delete from katello_capsule_lifecycle_environments where capsule_id in (select smart_proxy_id from features_smart_proxies where feature_id = (select id from features where features.name = 'Pulp Node'));"], "delta": "0:00:00.012455", "end": "2020-11-10 11:02:49.575174", "msg": "non-zero return code", "rc": 1, "start": "2020-11-10 11:02:49.562719", "stderr": "ERROR:  relation \"features_smart_proxies\" does not exist\nLINE 1: ...s where capsule_id in (select smart_proxy_id from features_s...\n                                                             ^", "stderr_lines": ["ERROR:  relation \"features_smart_proxies\" does not exist", "LINE 1: ...s where capsule_id in (select smart_proxy_id from features_s...", "                                                             ^"], "stdout": "", "stdout_lines": []}
~~~


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

6.8
How reproducible:


Steps to Reproduce:
1. run satellite-clone
2.
3.

Actual results:
Fails with above error

Expected results:
It should succeed

Additional info:
Table name in the source code refrers as features_smart_proxies. I think it should be smart_proxy_features

--- Additional comment from  on 2020-11-16T16:07:07Z 

Upstream PR: https://github.com/RedHatSatellite/satellite-clone/pull/377

--- Additional comment from  on 2021-01-13T13:58:36Z 

Fixed in https://github.com/RedHatSatellite/satellite-clone/pull/379 and released upstream in https://github.com/RedHatSatellite/satellite-clone/archive/2.0.0.tar.gz

--- Additional comment from  on 2021-01-21T12:25:32Z 

Verified with satellite-clone-2.0.1-1.el7sat.noarch from snap 9, having source 6.8 Sat + Capsule with assigned LCE

# satellite-clone -y
...
TASK [satellite-clone : Disassociate capsules with lifecycle environments (to avoid the cloned Satellite server talking with live capsules)] *************************************************************************************************
Thursday 21 January 2021  05:17:27 -0500 (0:00:00.026)       0:50:06.511 ****** 
changed: [localhost]

stdout: All Capsules are unassociated with any lifecycle environments. This is to avoid any syncing errors with your original Satellite and any interference with existing infrastructure. To reverse these changes, run the following commands, making sure to replace the credentials with your own.
hammer -u admin -p changeme --csv capsule content add-lifecycle-environment --id 2 --lifecycle-environment-id 3
...
PLAY RECAP **************************************************************************************
localhost                  : ok=71   changed=27   unreachable=0    failed=0 


Also tried the fallback command manually and it seems to work properly (no errors):

[root@target ~]# su - postgres
-bash-4.2$ psql foreman -c "delete from katello_capsule_lifecycle_environments where capsule_id in (select smart_proxy_id from smart_proxy_features where feature_id = (select id from features where features.name = 'Pulp Node'));"
DELETE 0
-bash-4.2$ echo $?
0

Comment 2 Vladimír Sedmík 2021-03-15 12:50:57 UTC
Verified with satellite-clone-2.0.1-1.el7sat.noarch from snap 1 of 6.8.5, having source 6.8 Sat + Capsule with assigned LCE

# satellite-clone -y
...
TASK [satellite-clone : Disassociate capsules with lifecycle environments (to avoid the cloned Satellite server talking with live capsules)] *************************************
Monday 15 March 2021  05:52:03 -0400 (0:00:00.023)       0:46:36.684 ********** 
changed: [localhost]

stdout: All Capsules are unassociated with any lifecycle environments. This is to avoid any syncing errors with your original Satellite and any interference with existing infrastructure. To reverse these changes, run the following commands, making sure to replace the credentials with your own.
hammer -u admin -p changeme --csv capsule content add-lifecycle-environment --id 2 --lifecycle-environment-id 1
...
PLAY RECAP ***********************************************************************************************************************************************************************
localhost                  : ok=71   changed=27   unreachable=0    failed=0

Comment 6 errata-xmlrpc 2021-03-31 19:38:10 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 (Satellite Maintenance 6.8.5 Async Bug Fix Update), 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/RHBA-2021:1056