Bug 816211

Summary: Agent plug-in container should log warnings and disable metric collection for metrics with invalid collection intervals
Product: [JBoss] JBoss Operations Network Reporter: Larry O'Leary <loleary>
Component: Plugin ContainerAssignee: Larry O'Leary <loleary>
Status: CLOSED NEXTRELEASE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: high    
Version: JON 3.0.1CC: hrupp, jshaughn
Target Milestone: ---   
Target Release: JON 3.0.2   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 786889 Environment:
Last Closed: 2013-09-06 02:42:59 UTC Type: Enhancement
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: 786889, 865160    
Bug Blocks: 818032    

Description Larry O'Leary 2012-04-25 13:51:07 UTC
+++ This bug was initially created as a clone of upstream RHQ Project Bug #786889 +++

If a metric collection interval is set to 0 seconds, the result is out of memory conditions for the agent and no metrics being successfully collected.

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

--- Additional comment from loleary on 2012-02-02 14:37:48 EST ---

Steps to reproduce:
#. Install server and agent
#. Start server and agent
#. Import platform, agent, and server into inventory
#. Navigate to the RHQ Server resource and find its resource ID
#. Obtain an inventory report from the agent for the RHQ Server resource
   inventory --id <resource_id of RHQ server> --xml --export /tmp/inventory.xml
#. In the report, locate the schedule with name jboss.system:type=ServerInfo:ActiveThreadCount and note its schedule-id
#. Select the RHQ Server's Monitoring tab
#. Select the Schedules sub-tab
#. Select the Active Thread Count metric and set its collection interval to 1 minute
#. Restart the server and agent to force the new collection interval to take affect
#. Confirm the Active Thread Count metric is being collected every minute
#. Navigate to the Test SQL page: http://localhost:7080/coregui/#Test/ServerAccess/SQL
#. Execute the following SQL:
   UPDATE rhq_measurement_sched SET coll_interval=0 WHERE id=<schedule-id-from-above>;
   Number of Rows Affected should be 1
#. Restart server and agent (agent should be started in debug mode)


Actual Result:
Agent log is filled with hundreds of thousands of: DEBUG [MeasurementManager.collector-1] (rhq.core.pc.measurement.MeasurementCollectorRunner)- Measurement collection is falling behind... Missed requested time by [211309ms]
No metrics are being collected for any of the scheduled metrics

Expected Result:
No Measurement collection is falling behind... Missed requested time by [211309ms] log messages in agent debug log
ActiveThreadCount metric should not be collected and a warning should appear in agent log stating that the collection interval is invalid so <resource id> metric <metric id> will not be collected
Other metrics continue to be collected as per their schedule.

--- Additional comment from ccrouch on 2012-02-06 11:38:55 EST ---

The agent should support 0 or -ve collection intervals.

--- Additional comment from ccrouch on 2012-02-06 11:40:55 EST ---

We need to spend sometime investigating how this could have gotten set to 0, without going into the DB

--- Additional comment from loleary on 2012-02-06 11:46:48 EST ---

I attempted to reproduce the issue which would have caused 0 without success. Additional information from the user who reported this seems to point to a possible inventory sync issue between server and agent. The reason I say this is the user reported the collection interval seemed to be correct from the server side but the export of inventory from the agent revealed the 0 interval. The user then executed the inventory sync command from the agent prompt and the agent side inventory (export agent-side inventory report) shows the schedule fixed itself.

--- Additional comment from jshaughn on 2012-04-09 09:46:50 EDT ---

I've also come up empty with respect to recreating this scenario. Although
the issue states that the DB values were valid, and the situation can
self-correct with a sync, I started by looking at whether we could somehow
store a bad value and propagate it to an agent. Although very unlikely it
seemed maybe possible. The following commit resulted to protect against it:

commit 6ff5d43b1b864bfecd7a352f7c72bc81bff56642

    Related to Bug 786889 which deals with invalid (low) schedule intervals
    reaching the agent.  Although it seems unlikely that the bad interval
    was stored in the db, there exist ways to store a bad value and it can
    in fact reach the agent.  Don't let that happen by fixing the
    interval verification in the SLSB code and blocking all values < the
    minimum collection interval.


Server-side we do some things with metric schedule setting that is a bit
hairy, whether it be template/group/resource, we do use negative, 0 and
positive values to indicate various enable/disable scenarios. Various attempts
to get these bad values to the agent didn't pan out, I don't see a way to 
make that happen.

So it seems the issue must somewhere be agent side but again, I don't see
it, so instead I plan to catch/report/correct a bad value being set.  At least
a prevention and copious logging may help us track this down.

--- Additional comment from jshaughn on 2012-04-09 15:06:59 EDT ---

commit aa65805371fd2f1901cc46aeff55e6866ad54eb7
commit f234f3ac5f157341cd2535342ecacf97f66cef1e (a tweak to the original commit)

Catch any attempt to set a metric collection interval to an invalid value.
If found, set it to 20 minutes and report the problem in the log as an
ERROR, with a lot of supporting info to help track down the cause.

--- Additional comment from jshaughn on 2012-04-17 10:40:18 EDT ---


Back to ON_DEV, I recreated on 3.0.0.  Investigating.

To reproduce I used AS4 WAR type and updated two out-of-box disabled metrics
simultaneously to enabled, not changing the interval.

I doubt several of the details above are relevant, most likely there is a
general issue with template metric manipulation.

Comment 1 Larry O'Leary 2012-04-26 14:55:09 UTC
Branch: release/jon3.0.x
commit a00eb5ee989cf5e0a91278ddf51f2ef1e7335b00
Author: Jay Shaughnessy <jshaughn>
Date:   Tue Apr 3 17:55:55 2012 -0400

    Related to Bug 786889 which deals with invalid (low) schedule intervals
    reaching the agent.  Although it seems unlikely that the bad interval
    was stored in the db, there exist ways to store a bad value and it can
    in fact reach the agent.  Don't let that happen by fixing the
    interval verification in the SLSB code and blocking all values < the
    minum collection interval.
    - Also, added test which failed to prove the issue, and now passes.
    (cherry-picked from 6ff5d43b1b864bfecd7a352f7c72bc81bff56642)
    
    [Bug 786889 - Agent plug-in container should log warnings and disable metric collection for metrics with invalid collection intervals]
    Catch any attempt to set a metric collection interval to an invalid value.
    If found, set it to 20 minutes and report the problem in the log as an
    ERROR, with a lot of supporting info to help track down the cause.
    (cherry-picked from aa65805371fd2f1901cc46aeff55e6866ad54eb7)
    
    Move a private util method I had in ResourceContainer to ThrowableUtil
    and use the new utility method.
    (cherry-picked from f234f3ac5f157341cd2535342ecacf97f66cef1e)

Comment 3 Larry O'Leary 2013-09-06 02:42:59 UTC
Closing as there will not be a 3.0.2 release. This issue has already been fixed in a later release or will be fixed in 3.2. See 'depends on' list for reference.