Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1663334

Summary: System Overview and System Group pages don't show the correct update status
Product: [Community] Spacewalk Reporter: ppanon-avi <Paul-Andre.Panon>
Component: WebUIAssignee: Michael Mráka <mmraka>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 2.8CC: dcidfw, ggainey, ranmses
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: spacewalk-java-2.10.12-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-19 12:16:04 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:    
Bug Blocks: 1802137    

Description ppanon-avi 2019-01-03 21:35:27 UTC
Description of problem: in the Systems->System Overview and System Groups pages, the Updates column shows green even if systems in the group have updates pending with associated Security Advisory or other Advisory Errata.


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

All since at least Spacewalk 2.5


How reproducible:




Steps to Reproduce:
1. Allow systems to remain out of date after a repo sync so that updates with associated security vulnerabilities are pending.

2. 

3.

Actual results:

view the System Overview or System group pages. Click on the update green check mark for a group and see that there may be multiple updates and errata pending if the systems haven't yet been updated.

Expected results:

The Updates column should have a different icon if systems in the group have outstanding updates: a yellow warning if some updates are bug fixes or product enhancements, a red exclamation mark if one or more of the updates have an associated Security Advisory.

Additional info:
The views use Dataset lists composed of the dto/SystemGroupOverview and populated by the com.redhat.rhn.frontend.action.systems.SystemGroupListSetupAction
The SystemGroupOverview dto contains mostSevereErrata private property which is used by the JSP to determine which icon should be displayed for the updates column.

However the SystemGroupListSetupAction uses the SystemManager.groupListWithServerCount method, which in turns appear to use the following query in common/db/datasource/xml/SystemGroup_queries.xml

<mode name="visible_to_user_and_counts" class="com.redhat.rhn.frontend.dto.SystemGroupOverview">
  <query params="user_id">
    select * from (
    SELECT SG.id AS ID, SG.name AS NAME,
       (SELECT COUNT(*)
          FROM rhnServerGroupMembers SGM WHERE SGM.server_group_id = SG.id
           AND EXISTS (SELECT 1
                         FROM rhnServerFeaturesView SFV
                        WHERE SFV.server_id = SGM.server_id
                          AND SFV.label = 'ftr_system_grouping')) AS SERVER_COUNT
      FROM rhnServerGroup SG, rhnUserManagedServerGroups UMSG
     WHERE UMSG.user_id = :user_id
       AND UMSG.server_group_id = SG.id
       AND SG.group_type IS NULL
    ) x
    ORDER BY UPPER(NAME)
  </query>
</mode>

That query doesn't populate/return any values for a mostSevereErrata column. The  missing columns are presumably treated as null, which leads to the green icon being displayed by default.

Not sure if the best approach is to modify the above mode or to create a new mode for the SystemGroupOverview, in order to add a subselect to populate a mostSevereErrata column.

Comment 1 ppanon-avi 2019-01-04 01:57:03 UTC
I tried to look at how it was handled for the Systems view. It's more complex there because the Updates column display is in the SystemListHelper.setSystemStatusDisplay property. The base SQL query for the System list also primarily pulls key information, but it also includes elaborator queries that populate the other fields for each row in the SystemOverview list

<mode name="visible_to_user" class="com.redhat.rhn.frontend.dto.SystemOverview">
  <query name="available_to_user" />
  <elaborator name="system_overview" />
  <elaborator name="system_config_files_with_diffs" />
  <elaborator name="entitlements"/>
  <elaborator name="is_virtual_guest" />
  <elaborator name="is_virtual_host" />
</mode>

<query name="system_overview" params="">
  SELECT SERVER_ID AS ID, OUTDATED_PACKAGES, SERVER_NAME, security_errata, bug_errata, enhancement_errata,
          SERVER_ADMINS, GROUP_COUNT, MODIFIED, CHANNEL_LABELS, CHANNEL_ID, HISTORY_COUNT,
          unique_crash_count, total_crash_count, LAST_CHECKIN_DAYS_AGO, PENDING_UPDATES, OS, RELEASE,
          SERVER_ARCH_NAME, LAST_CHECKIN, LOCKED
  FROM  rhnServerOverview
  WHERE  server_id IN (%s)
ORDER BY  UPPER(COALESCE(SERVER_NAME, '(none)')), SERVER_ID
</query>



So rather than try to modify the existing query for the SystemGroupOverview "visible_to_user_and_counts" mode, it probably makes more sense to populate the mostSevereErrata property of dto.SystemGroupOverview with a decorator query for that mode as well. Something like 

<query name="system_group_overview" params="">
 SELECT GROUP_ID AS ID, GROUP_NAME, GROUP_ADMINS,
        CASE
            WHEN security_errata > 0 THEN 'Security Advisory'
            WHEN bug_errata > 0 THEN 'Bug Fix Advisory'
            WHEN enhancement_errata > 0 THEN 'Product Enhancement Advisory'
            ELSE ''
        END AS "mostSevereErrata"
      FROM rhnServerGroupOverview
      WHERE group_id IN (%s)
      ORDER BY UPPER(GROUP_NAME)
</query>

Comment 2 ppanon-avi 2019-01-04 02:07:18 UTC
Woops I meant an elaborator query, not a decroator query. The mode would also need to be modified to add the elaborator query. I'm guessing that it also would no longer need the ORDER By clause if it's in the elaborator.

<mode name="visible_to_user_and_counts" class="com.redhat.rhn.frontend.dto.SystemGroupOverview">
  <query params="user_id">
    SELECT SG.id AS ID, SG.name AS NAME,
       (SELECT COUNT(*)
          FROM rhnServerGroupMembers SGM WHERE SGM.server_group_id = SG.id
           AND EXISTS (SELECT 1
                         FROM rhnServerFeaturesView SFV
                        WHERE SFV.server_id = SGM.server_id
                          AND SFV.label = 'ftr_system_grouping')) AS SERVER_COUNT
      FROM rhnServerGroup SG, rhnUserManagedServerGroups UMSG
     WHERE UMSG.user_id = :user_id
       AND UMSG.server_group_id = SG.id
       AND SG.group_type IS NULL
  </query>
  <elaborator name="system_group_overview" />
</mode>

Comment 3 dcidfw 2019-04-17 20:25:11 UTC
Hi,

We have the same issue after we migrate Spacewalk to 2.8 in Redhat 7. Could anyone please advice if there is any fix on it.

Thanks
Sushant

Comment 4 ranmses 2019-05-09 19:14:04 UTC
Hello,

Same here on Spacewalk 2.9, but just in the System Groups page (Overview page is fine).

Any thoughts?

Regards,

Ranmsés.

Comment 5 Michael Mráka 2019-08-21 12:14:54 UTC
Fixed by https://github.com/spacewalkproject/spacewalk/pull/700

commit a5010b34234bea6c56335d05fa126c3dfe2a028c
    Fix to display right errata status in System Group view

Comment 6 Michael Mráka 2020-03-19 12:16:04 UTC
Spacewalk 2.10 has been released.
https://github.com/spacewalkproject/spacewalk/wiki/ReleaseNotes210