Bug 1896468

Summary: satellite clone fails while disassociate capsules from lifecycle environments
Product: Red Hat Satellite Reporter: Anand Agrawal <aagrawal>
Component: Satellite CloneAssignee: Anand Agrawal <aagrawal>
Status: CLOSED ERRATA QA Contact: Vladimír Sedmík <vsedmik>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: ahumbe, pcreech
Target Milestone: 6.9.0Keywords: PrioBumpGSS, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: satellite-clone-2.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1933169 (view as bug list) Environment:
Last Closed: 2021-04-21 14:48:24 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 Anand Agrawal 2020-11-10 16:04:04 UTC
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

Comment 1 Brad Buckingham 2020-11-16 16:07:07 UTC
Upstream PR: https://github.com/RedHatSatellite/satellite-clone/pull/377

Comment 3 Vladimír Sedmík 2021-01-21 12:25:32 UTC
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 7 errata-xmlrpc 2021-04-21 14:48:24 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 6.9 Satellite Maintenance 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/RHBA-2021:1312