Bug 1451461

Summary: [5.7] when you spacewalk-repo-sync into multiple organizations, errata in the satellite have org_id based on last org used (but still being same errata)
Product: Red Hat Satellite 5 Reporter: Grant Gainey <ggainey>
Component: Satellite SynchronizationAssignee: Grant Gainey <ggainey>
Status: CLOSED ERRATA QA Contact: Ales Dujicek <adujicek>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 570CC: adujicek, jhutar, mmraka, satqe-list, tkasparek, tlestach
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-backend-2.3.3-50-sat,spacewalk-schema-2.3.2-31-sat,satellite-schema-5.7.0.32-1-sat Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1444519 Environment:
Last Closed: 2017-07-19 14:50:36 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:
Bug Depends On: 1444519    
Bug Blocks:    

Description Grant Gainey 2017-05-16 17:01:17 UTC
+++ This bug was initially created as a clone of Bug #1444519 +++

Description of problem:
When you spacewalk-repo-sync into multiple organizations, errata in the satellite have org_id based on last org used (but still being same errata)


Version-Release number of selected component (if applicable):
spacewalk-java-2.3.8-96.el6sat.noarch
satellite-schema-5.7.0.27-1.el6sat.noarch
spacewalk-backend-2.3.3-23.el6sat.noarch


How reproducible:
always


Steps to Reproduce:
1. Create channel A and repo http://dl.fedoraproject.org/pub/epel/6Server/x86_64/ (with filter set to "+freealut*" to make sync faster)
2. Create channel B and sync if from repo with same url&filter but in different organization now
3. Sync channel A in org 1 and channel B in org 2
4. Check in the DB org_id of the errata
5. Sync in org1 again
6. Check in the DB org_id of the errata
 

Actual results:
Errata's org_id is set based on in which organization sync was done last time. Check this (with different package than in steps to reproduce though):

(please ignore that path of packages in org2 does not start with "redhat/2/...", that is different issue)

rhnschema=# select P.id,P.org_id,P.path from rhnPackage P, rhnPackageName PN where P.name_id = PN.id and PN.name = 'powwow-devel';
   id   | org_id |                                                                        path                                                                         
--------+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------
 100594 |      1 | redhat/1/6ef/powwow-devel/1.2.16-1.el6/i686/6efc2c1cd00ef2e0e25b15cf36c407d393b31762626e771df471cc72820dc4e6/powwow-devel-1.2.16-1.el6.i686.rpm
 101454 |      1 | redhat/1/468/powwow-devel/1.2.16-1.el6/x86_64/468d1522aec3895b496235f6f3e01d85b48fc71834b9493c5c9a4f734cfe4404/powwow-devel-1.2.16-1.el6.x86_64.rpm
 121766 |      2 | redhat/1/6ef/powwow-devel/1.2.16-1.el6/i686/6efc2c1cd00ef2e0e25b15cf36c407d393b31762626e771df471cc72820dc4e6/powwow-devel-1.2.16-1.el6.i686.rpm
 128010 |      2 | redhat/1/468/powwow-devel/1.2.16-1.el6/x86_64/468d1522aec3895b496235f6f3e01d85b48fc71834b9493c5c9a4f734cfe4404/powwow-devel-1.2.16-1.el6.x86_64.rpm
(4 rows)

rhnschema=# select E.id,E.org_id,E.advisory from rhnErrata E, rhnErrataPackage EP where E.id = EP.errata_id and EP.package_id = 128010;
  id   | org_id |         advisory         
-------+--------+--------------------------
 30232 |      2 | CL-FEDORA-EPEL-2011-0114
 24764 |      2 | FEDORA-EPEL-2011-0114
 41807 |      1 | CM-FEDORA-EPEL-2011-0114
(3 rows)

##### Now we have ran spacewalk-repo-sync -c channel-in-org2-with-same-

rhnschema=# select E.id,E.org_id,E.advisory from rhnErrata E, rhnErrataPackage EP where E.id = EP.errata_id and EP.package_id = 128010;
  id   | org_id |         advisory         
-------+--------+--------------------------
 30232 |      2 | CL-FEDORA-EPEL-2011-0114
 24764 |      1 | FEDORA-EPEL-2011-0114
 41807 |      1 | CM-FEDORA-EPEL-2011-0114
(3 rows)


Expected results:
Maybe there should be 2 errata - one per organization? Or maybe org_id column in rhnErrata is not needed at all? Or this all works/behaves as expected?


Additional info:
This bug is meant for discussion, if this behaviour (2 channels/2 repos (with same url though)/2 same packages in /var/satellite for 2 organizations but only one errata) is sane.

Note this is connected to bug 1444072.

--- Additional comment from Michael Mráka on 2017-05-02 04:23:47 EDT ---

Fixed in upstream spacewalk git by
commit 2b861e4d90c27061a071db3758c6fceabd983cb7
    1444519 - allow sync of the same erratum to more orgs

--- Additional comment from Michael Mráka on 2017-05-03 10:23:15 EDT ---

NULL org issue fixed in spacewalk
commit 267d7c275a481390e2be29ac4c116f8ff8d74205
    1444519 - fix index behaviour on NULL org

--- Additional comment from Ales Dujicek on 2017-05-04 02:53:33 EDT ---

1) it breaks schema upgrade on Oracle:

'SATELLITE-SCHEMA-5.7-TO-SATELLITE-SCHEMA-5.8/009-RHNERRATA-UNIQ.SQL.ORACL
--------------------------------------------------------------------------
satellite-schema-5.7-to-satellite-schema-5.8/009-rhnErrata-uniq.sql.oracle


Index dropped.


Index dropped.

CREATE UNIQUE INDEX rhn_errata_advisory_name_org_uq
                    *
ERROR at line 1:
ORA-00972: identifier is too long


2) indexes were not changed in schema/spacewalk/common/tables/rhnErrata.sql
is that correct?

--- Additional comment from Michael Mráka on 2017-05-04 05:45:33 EDT ---

Oracle index name fix in spacewalk
commit 4a7ac87ef95c82c7bd6593f58f4a743676f0c0a6
    1444519 - update schema definition and shorten index name

--- Additional comment from Michael Mráka on 2017-05-09 07:20:28 EDT ---

Fix for cdn-sync
ERROR: duplicate key value violates unique constraint "rhn_errata_advname_uq" DETAIL:  Key (advisory_name)=(RHBA-2015:1776) already exists.

spacewalk git:
commit db1d83698b4370ec3a68640448e9bb70a552c383
    1444519 - org_id column can hold NULL

Comment 1 Grant Gainey 2017-05-16 17:02:00 UTC
Cloned for 5.7 backport

Comment 5 Ales Dujicek 2017-06-29 08:44:58 UTC
reproduced on
satellite-schema-5.7.0.27-1.el6sat.noarch
spacewalk-backend-2.3.3-49.el6sat.noarch
spacewalk-java-2.3.8-158.el6sat.noarch

steps bz1444519#c0
errata org_id changed after sync in the other organization:
# select E.id,E.org_id,E.advisory,EP.package_id from rhnErrata E, rhnErrataPackage EP where E.id = EP.errata_id and EP.package_id in (1,3,8,11);
 id | org_id |       advisory        | package_id
----+--------+-----------------------+------------
  1 |      1 | FEDORA-EPEL-2011-0073 |          3
  1 |      1 | FEDORA-EPEL-2011-0073 |          1
  1 |      1 | FEDORA-EPEL-2011-0073 |          8
  1 |      1 | FEDORA-EPEL-2011-0073 |         11
# select E.id,E.org_id,E.advisory,EP.package_id from rhnErrata E, rhnErrataPackage EP where E.id = EP.errata_id and EP.package_id in (1,3,8,11);
 id | org_id |       advisory        | package_id
----+--------+-----------------------+------------
  1 |      2 | FEDORA-EPEL-2011-0073 |          3
  1 |      2 | FEDORA-EPEL-2011-0073 |          1
  1 |      2 | FEDORA-EPEL-2011-0073 |          8
  1 |      2 | FEDORA-EPEL-2011-0073 |         11


with package versions:
satellite-schema-5.7.0.31-1.el6sat.noarch
spacewalk-backend-2.3.3-52.el6sat.noarch

each org has it own errata:

# select E.id,E.org_id,E.advisory,EP.package_id from rhnErrata E, rhnErrataPackage EP where E.id = EP.errata_id and EP.package_id in (1,3,8,11);
 id | org_id |       advisory        | package_id
----+--------+-----------------------+------------
  1 |      1 | FEDORA-EPEL-2011-0073 |          3
  1 |      1 | FEDORA-EPEL-2011-0073 |          1
  2 |      2 | FEDORA-EPEL-2011-0073 |          8
  2 |      2 | FEDORA-EPEL-2011-0073 |         11

verified

Comment 11 errata-xmlrpc 2017-07-19 14:50:36 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, 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-2017:1771