Bug 746090

Summary: Listing/editing of probe suite systems is broken
Product: [Community] Spacewalk Reporter: Michael Zabriskie <accounts+redhat>
Component: ServerAssignee: Michael Mráka <mmraka>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 1.5CC: slukasik
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-java-1.6.62-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-22 16:49:29 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:
Bug Depends On:    
Bug Blocks: 723481    

Description Michael Zabriskie 2011-10-13 20:45:35 UTC
Since the following commit:

https://fedorahosted.org/spacewalk/browser/java/code/src/com/redhat/rhn/common/db/datasource/xml/Monitoring_queries.xml?rev=9103a4c0b5f7a715d37ddab1e7d7961d09edbb04

listing or editing of probe suite systems with an Oracle DB has thrown the following exception:

ORA-00904: "S"."ID": invalid identifier

I don't have a PostgreSQL instance of Spacewalk to test with.

I believe the following patch on Monitoring_queries.xml will correct the issue:

======================================================
@@ -164,8 +164,8 @@
            WHEN 5 THEN 'CRITICAL' END ) ST
            FROM  rhn_check_probe statcp
            LEFT JOIN rhn_probe_state statps
-             ON s.id = statcp.host_id
-          WHERE statcp.probe_id = statps.probe_id
+             ON statcp.probe_id = statps.probe_id
+          WHERE s.id = statcp.host_id
           GROUP BY s.id ) status
 FROM rhn_check_suites cs,
      rhn_check_suite_probe csp,
======================================================

Comment 1 Michael Mráka 2011-10-17 09:30:33 UTC
Another report of the same bug: https://www.redhat.com/archives/spacewalk-list/2011-October/msg00067.html

To reproduce :
Monitoring -> Probe Suites -> [Select one] -> Systems

We receive an Internal Server Error- Catalina provides a query:

SELECT distinct s.id, s.name,
( SELECT  (CASE
                   MAX(CASE statps.state
                       WHEN 'OK' THEN 1
                       WHEN 'PENDING' THEN 2
                       WHEN 'UNKNOWN' THEN 3
                       WHEN 'WARNING' THEN 4
                       WHEN 'CRITICAL' THEN 5 END)
           WHEN 1 THEN 'OK'
           WHEN 2 THEN 'PENDING'
           WHEN 3 THEN 'UNKNOWN'
           WHEN 4 THEN 'WARNING'
           WHEN 5 THEN 'CRITICAL' END ) ST
           FROM  rhn_check_probe statcp
           LEFT JOIN rhn_probe_state statps
             ON s.id = statcp.host_id
          WHERE statcp.probe_id = statps.probe_id
          GROUP BY s.id ) status
FROM rhn_check_suites cs,
     rhn_check_suite_probe csp,
     rhn_service_probe_origins spo,
     rhn_check_probe cp,
     rhn_probe_state ps,
     rhnServer s
WHERE cs.recid = ?
  and csp.check_suite_id = cs.recid
  and spo.origin_probe_id = csp.probe_id
  and cp.probe_id = spo.service_probe_id
  and ps.probe_id = cp.probe_id
  and s.id = cp.host_id
com.redhat.rhn.common.db.WrappedSQLException: ORA-00904: "S"."ID":
invalid identifier

I found the query in the following resource:
java/code/src/com/redhat/rhn/common/db/datasource/xml/Monitoring_queries.xml

Comment 2 Michael Mráka 2011-10-17 09:36:33 UTC
Fixed in spacewalk master by
commit 37f4aac214025b791e48c1df017113096d950570
    746090 - fixed join condition in query

Comment 3 Michael Zabriskie 2011-10-17 15:29:49 UTC
Thank you Michael. When would one expect this to hit the nightly repo? Or maybe it could be had from Koji?

Comment 4 Michael Zabriskie 2011-10-17 22:36:57 UTC
Got the latest RPM from nightly. This fixed the bug. Thanks again.

Comment 5 Milan Zázrivec 2011-12-22 16:49:29 UTC
Spacewalk 1.6 has been released.