Bug 1678857 - Satellite throws an ISE when trying to clone a channel if the org does not have software entitlements to the parent channel
Summary: Satellite throws an ISE when trying to clone a channel if the org does not ha...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: WebUI
Version: 580
Hardware: All
OS: All
high
high
Target Milestone: ---
Assignee: Michael Mráka
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
: 1678856 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-19 18:45 UTC by Marcelo Moreira de Mello
Modified: 2022-03-13 17:00 UTC (History)
5 users (show)

Fixed In Version: spacewalk-java-2.5.14-131-sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-19 18:11:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Error message with multiple child channels without parent entitlement (121.60 KB, image/png)
2019-05-28 09:46 UTC, Radovan Drazny
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3945511 0 None None None 2019-02-27 13:52:50 UTC
Red Hat Product Errata RHBA-2019:1551 0 None None None 2019-06-19 18:11:18 UTC

Description Marcelo Moreira de Mello 2019-02-19 18:45:10 UTC
Description of problem:
Satellite throws an ISE when trying to clone a channel if the org does not have software entitlements to the parent channel. 

Traceback:

2019-02-18 10:48:30,902 [TP-Processor6] DEBUG net.rkbloom.logdriver.LogPreparedStatement - executing PreparedStatement: 'SELECT AC.channel_id AS ID,
       AC.channel_name AS NAME,
       rhn_channel.user_role_check(AC.channel_id, ?, 'subscribe') AS HAS_PERM,
       CASE rhn_channel.org_channel_setting(AC.channel_id, ?,'not_globally_subscribable') WHEN 0 THEN 1 ELSE NULL END AS GLOBALLY_SUBSCRIBABLE
  FROM rhnAvailableChannels AC
 WHERE AC.org_id = ?
ORDER BY UPPER(AC.channel_name)' with bind parameters: {1=141, 2=42, 3=42}
2019-02-18 10:48:30,933 [TP-Processor6] DEBUG net.rkbloom.logdriver.LogPreparedStatement - executing PreparedStatement: 'select Distinct C.id,
                   C.name,
                   C.label as channel_label,
                   C.parent_channel as parent_id,
                        (SELECT COUNT(P.package_id)
                          FROM rhnChannelPackage P
                          WHERE P.channel_id = C.id
                                ) AS package_count,
         C.org_id,
         (select org.name
            from web_customer org
            where org.id = C.org_id) as org_name,
         CA.name as arch_name
        from rhnChannel C inner join
         rhnUserChannel UC on UC.channel_id = C.id
        inner join rhnChannelArch CA ON CA.ID  = C.channel_arch_id
         where UC.user_id = ?' with bind parameters: {1=141}
2019-02-18 10:48:31,011 [TP-Processor6] WARN  org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class java.lang.NullPointerException
2019-02-18 10:48:31,011 [TP-Processor6] ERROR com.redhat.rhn.frontend.servlets.SessionFilter - Error during transaction. Rolling back
javax.servlet.ServletException: java.lang.NullPointerException
	at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
	at com.redhat.rhn.frontend.struts.RhnRequestProcessor.process(RhnRequestProcessor.java:105)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.redhat.rhn.frontend.servlets.AuthFilter.doFilter(AuthFilter.java:127)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
	at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.redhat.rhn.frontend.servlets.LocalizedEnvironmentFilter.doFilter(LocalizedEnvironmentFilter.java:67)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.redhat.rhn.frontend.servlets.EnvironmentFilter.doFilter(EnvironmentFilter.java:101)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.redhat.rhn.frontend.servlets.SessionFilter.doFilter(SessionFilter.java:57)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.redhat.rhn.frontend.servlets.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:97)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:299)
	at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
	at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
	at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
	at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
	at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
	at java.lang.Thread.run(Thread.java:812)
Caused by: 
java.lang.NullPointerException
	at com.redhat.rhn.frontend.action.channel.manage.CloneChannelAction.execute(CloneChannelAction.java:105)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
	... 40 more


Version-Release number of selected component (if applicable):
Satellite 5.8 
5.8.0.46-1.el6sat
spacewalk-java-2.5.14-120.el6sat.noarch

How reproducible:
100%

Steps to Reproduce:
1. Run cdn-sync to sync
   # cdn-sync -c rhel-x86_64-server-7 -c rhn-tools-rhel-x86_64-server-7
2. Create a new organization called TESTORG
2. Allocate a child entitlement to the new organization

   Admin -> Organizations -> TESTORG -> Subscriptions -> Software Channel Entitlements 

3. Chekc the option "List only synchronised channels"
4. Allocate 1 entitlement for "RHN Tools for RHEL Server (v. 7)" (only) do not include the base channel
5. Try to visit the clone page

   Channels -> Manage Software Channels -> Clone Channel


Actual results:

An ISE is displayed


Expected results:

WebUI show display friendly message reporting what needs to be fixed. 


Additional info:


// display channels that can be cloned
select Distinct C.id,
                   C.name,
                   C.label as channel_label,
                   C.parent_channel as parent_id,
                        (SELECT COUNT(P.package_id)
                          FROM rhnChannelPackage P
                          WHERE P.channel_id = C.id
                                ) AS package_count,
         C.org_id,
         (select org.name
            from web_customer org
            where org.id = C.org_id) as org_name,
         CA.name as arch_name
        from rhnChannel C inner join
         rhnUserChannel UC on UC.channel_id = C.id
        inner join rhnChannelArch CA ON CA.ID  = C.channel_arch_id
         where UC.user_id  = <USER_ID>;


 It makes sense the parent channel should have access, however on a multi-org environment with lots of entitlements it is complicated to troubleshoot. Having a check process either when the software entitlements are allocated or at the cloning page would be great.

Comment 1 Marcelo Moreira de Mello 2019-02-19 18:47:42 UTC
*** Bug 1678856 has been marked as a duplicate of this bug. ***

Comment 2 Marcelo Moreira de Mello 2019-02-19 19:06:42 UTC
spacewalk-java-2.5.14-128.el6sat.noarch also presents the issue

Comment 3 Marcelo Moreira de Mello 2019-02-19 21:51:36 UTC

satellite/java/code/src/com/redhat/rhn/frontend/action/channel/manage/CloneChannelAction.java


    99         // add all children
 >>100         for (ChannelTreeNode channel : channelTree) {
   101             if (!subscribableCids.contains(channel.getId()) || channel.isParent()) {
   102                 continue;
   103             }
   104             nameToId.put(channel.getName(), channel.getId());
   105             parentToChildren.get(channel.getParentId()).add(channel.getName());
   106         }
   107 


 So the SQL returns the data but the getParentId() via hibernate explodes..

Comment 4 Michael Mráka 2019-03-26 10:06:36 UTC
See also bug 1558684

Comment 5 Michael Mráka 2019-03-26 13:26:18 UTC
Fixed in spacewalk git by
commit 76542e1f4e0c4d2994de73e3aec861308470f772
    1678857 - show an error message when parent channel is not available

Comment 10 Michael Mráka 2019-05-23 09:43:47 UTC
Backported to SATELLITE-5.8 as
commit 0c7853aa9aa65f4020ec97e6b7a1d5fb9fd5c28e
    1678857 - show an error message when parent channel is not available

Comment 11 Radovan Drazny 2019-05-28 09:46:23 UTC
Created attachment 1574265 [details]
Error message with multiple child channels without parent entitlement

Reproduced the issue with spacewalk-java-2.5.14-129 using the reproducer from the initial report. After the update to spacewalk-java-2.5.14-130-sat the ISE is gone, but the fix doesn't work quite correctly. When there is more than one case of child channel with no entitlement for its parent channel in the org, the error message "multiplies". I have assigned three child channels without parents to the Testorg. See the attached screenshot for the resulting error message.

Comment 12 Michael Mráka 2019-05-29 09:22:00 UTC
Fixed in upstream spacewalk git by
commit 92355d387585473be5b2e0d2030e463e7431d22c
    1678857 - show all errors at once

Comment 13 Michael Mráka 2019-05-29 09:23:32 UTC
Backported to SATELLITE-5.8 as
commit 632f32bed8d5d4ec071dfecb667a65fe0ad8e9c1
    1678857 - show all errors at once

Comment 15 Radovan Drazny 2019-05-29 13:17:47 UTC
Verified on spacewalk-java-2.5.14-131. No ISE, and there is a single error message for each child channel without an entitlement to its parent.

VERIFIED

Comment 17 errata-xmlrpc 2019-06-19 18:11:14 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-2019:1551


Note You need to log in before you can comment on or make changes to this bug.