Bug 810204

Summary: Invalid destination regex of a calltime metric condition causes the reload of the condition cache of the whole agent to fail
Product: [Other] RHQ Project Reporter: Lukas Krejci <lkrejci>
Component: Alerts, Core ServerAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: urgent    
Version: unspecifiedCC: hrupp, loleary
Target Milestone: ---   
Target Release: RHQ 4.4.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 864259 (view as bug list) Environment:
Last Closed: 2013-09-01 09:58:51 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: 864259    

Description Lukas Krejci 2012-04-05 10:39:48 UTC
Description of problem:
When defining a calltime metric condition, one can specify a regular expression to limit the "destinations" that the condition is satisfied for.

When the regular expression is invalid, the exception causes the reloading of the whole condition cache for the whole agent to fail with an error message like this:

12:06:52,005 ERROR [AlertConditionCacheCoordinator] Error loading cache for agent[id=10001]
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 2
.**.*
  ^
        at java.util.regex.Pattern.error(Pattern.java:1713)
        at java.util.regex.Pattern.sequence(Pattern.java:1878)
        at java.util.regex.Pattern.expr(Pattern.java:1752)
        at java.util.regex.Pattern.compile(Pattern.java:1460)
        at java.util.regex.Pattern.<init>(Pattern.java:1133)
        at java.util.regex.Pattern.compile(Pattern.java:823)
        at org.rhq.enterprise.server.alert.engine.model.CallTimeDataCacheElement.<init>(CallTimeDataCacheElement.java:53)
        at org.rhq.enterprise.server.alert.engine.internal.AgentConditionCache.insertAlertConditionComposite(AgentConditionCache.java:202)
        at org.rhq.enterprise.server.alert.engine.internal.AgentConditionCache.loadCachesForAgent(AgentConditionCache.java:147)
        at org.rhq.enterprise.server.alert.engine.internal.AgentConditionCache.<init>(AgentConditionCache.java:105)
        at org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordinator.reloadCachesForAgent(AlertConditionCacheCoordinator.java:146)
        at org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerBean.reloadCachesForAgent(AlertConditionCacheManagerBean.java:106)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
        at org.rhq.enterprise.server.common.PerformanceMonitorInterceptor.monitorHibernatePerformance(PerformanceMonitorInterceptor.java:32)
        at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
...

The above error message was thrown when defining a calltime metric condition with a regex "*", which is an invalid regular expression but I assume a common mistake because it is a legal glob expression.

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

How reproducible:
always

Steps to Reproduce:
1. Inventory an AS4 with at least 1 WAR deployed
2. Go to the resource of the WAR
3. Define an alert with a single calltime condition (any type) with the regular expression "*" (without the quotes)
4. Save the alert
  
Actual results:
After a while, when the server reloads the condition cache, the above message appears in the server log

Expected results:
a more graceful failure - maybe just failing that single condition to reload - that seems to be the common case.

Additional info:

Comment 1 Lukas Krejci 2012-04-05 13:47:53 UTC
there is an info message being put into the server log for each condition that fails to load formatted along the lines of:

15:37:23,414 INFO  [AlertConditionCacheCoordinator] Failed to create CallTimeDataCacheElement with parameters: id=10011, operator=CHANGES, value=0.04, error message: The destination regular expression 'a[' is invalid: Unclosed character class near index 5
.*a[.*
     ^


master http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=commitdiff;h=02e78dd72fcfcfd92dabf5703207b5b43bb92dbd
Author: Lukas Krejci <lkrejci>
Date:   Thu Apr 5 13:01:39 2012 +0200

    [BZ 810204] - Make sure an invalid destination regex in calltime condition
    doesn't blow up the whole agent condition cache reloading.

Comment 2 Heiko W. Rupp 2013-09-01 09:58:51 UTC
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.