Bug 735810

Summary: SystemManagerRemote.setSystemConfiguration can invalidate the internal cache of system settings
Product: [Other] RHQ Project Reporter: Lukas Krejci <lkrejci>
Component: Core ServerAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: high    
Version: 4.1CC: hrupp, skondkar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 4.2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-07 19:27:37 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: 625146    

Description Lukas Krejci 2011-09-05 14:25:17 UTC
Description of problem:
SystemManagerRemote.setSystemConfiguration() method assumes that the Properties passed to it contain a superset of all the properties that are already defined in the database (i.e. it correctly handles the scenarios where the properties passed to it contain the same names or contain the same names and some new ones).

The cached properties that are then used in other places in the code are assigned to a copy of properties passed to this method. This results in the fact that the properties that are in the database but weren't in the passed in properties suddenly seem to have disappeared even though they are still present in the database.

This condition is intermittent because the system config cache is being reloaded every minute but still opens a window where the business layer reports inconsistent data.

Because setSystemConfiguration() is a remote method we should make it as robust as possible.

How reproducible:
always

Steps to Reproduce:
1.Using the CLI, log in as a user having at least MANAGE_SETTINGS privs:
var props = SystemManager.systemConfiguration;
pretty.print(props.get("CAM_BASE_URL");//prints out the URL of the server
props.remove("CAM_BASE_URL");
SystemManager.setSystemConfiguration(props, false);
props = SystemManager.systemConfiguration;
pretty.print(props.get("CAM_BASE_URL"); //prints nothing
//.... wait a couple of minutes
props = SystemManager.systemConfiguration;
pretty.print(props.get("CAM_BASE_URL"); //prints the URL again
  
Actual results:
see steps

Expected results:
no inconsistency in the reported properties

Additional info:

Comment 1 Lukas Krejci 2011-09-27 21:22:21 UTC
commit 72430377515c26d205d7664485fcb69d19db14e4
Author: Lukas Krejci <lkrejci>
Date:   Fri Sep 9 16:25:55 2011 +0200

    BZ-735810 - make sure to reload the system config cache after its update.

Comment 2 Sunil Kondkar 2011-09-30 11:11:18 UTC
Verified on build#449 (Version: 4.1.0-SNAPSHOT Build Number: 4d56f0b)

Created a user and assigned MANAGE_SETTINGS privileges to the user. Logged in to the CLI with the user.
Below are the steps followed.

var props = SystemManager.systemConfiguration;
pretty.print(props.get("CAM_BASE_URL"));       //prints out the URL of the server
props.remove("CAM_BASE_URL");
SystemManager.setSystemConfiguration(props, false);
props = SystemManager.systemConfiguration;
pretty.print(props.get("CAM_BASE_URL"));       //prints the URL of the server
//.... wait a couple of minutes
props = SystemManager.systemConfiguration;
pretty.print(props.get("CAM_BASE_URL"));       //prints the URL again

Comment 3 Mike Foley 2012-02-07 19:27:37 UTC
changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE