Bug 656476

Summary: JON241: [apache] Plugin fails to work if the httpd.conf contains an Include directive with non-existent path
Product: [Other] RHQ Project Reporter: Lukas Krejci <lkrejci>
Component: PluginsAssignee: Lukas Krejci <lkrejci>
Status: CLOSED CURRENTRELEASE QA Contact: Corey Welton <cwelton>
Severity: medium Docs Contact:
Priority: high    
Version: 3.0.0CC: rtimaniy
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 656496 (view as bug list) Environment:
Last Closed: 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: 616081, 656496    

Description Lukas Krejci 2010-11-23 20:21:22 UTC
Description of problem:

Exception during discovery:

2010-11-23 19:56:30,012 WARN  [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Failure during discovery for [Apache Virtual Host] Resources - failed after 26 ms.
java.lang.Exception: Discovery component invocation failed.
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:283)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.rhq.plugins.apache.parser.ApacheParserException: java.lang.IllegalStateException: Could not list files in /etc/httpd/bogus
        at org.rhq.plugins.apache.parser.ApacheConfigReader.searchFile(ApacheConfigReader.java:62)
        at org.rhq.plugins.apache.parser.ApacheConfigReader.buildTree(ApacheConfigReader.java:19)
        at org.rhq.plugins.apache.ApacheServerComponent.loadParser(ApacheServerComponent.java:883)
        at org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent.discoverResources(ApacheVirtualHostServiceDiscoveryComponent.java:77)
        at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:279)
        ... 5 more
Caused by: java.lang.IllegalStateException: Could not list files in /etc/httpd/bogus
        at org.rhq.augeas.util.Glob.match(Glob.java:132)
        at org.rhq.plugins.apache.parser.ApacheParserImpl.getIncludeFiles(ApacheParserImpl.java:48)
        at org.rhq.plugins.apache.parser.ApacheParserImpl.addDirective(ApacheParserImpl.java:25)
        at org.rhq.plugins.apache.parser.ApacheConfigReader.searchFile(ApacheConfigReader.java:50)
        ... 12 more


Exception during measurement collection:
2010-11-23 20:04:42,301 WARN  [MeasurementManager.collector-1] (rhq.core.pc.measurement.MeasurementCollectorRunner)- Failure to collect measurement data for Resource[id=10227, type=Apache Virtual Host, key=localhost.localdomain:443, name=127.0.0.1:443, parent=127.0.0.1:80] - cause: org.rhq.rhqtransform.AugeasRhqException:java.lang.IllegalStateException: java.lang.IllegalStateException: java.lang.IllegalStateException: Could not list files in /etc/httpd/bogus -> java.lang.IllegalStateException:java.lang.IllegalStateException: java.lang.IllegalStateException: Could not list files in /etc/httpd/bogus -> java.lang.IllegalStateException:java.lang.IllegalStateException: Could not list files in /etc/httpd/bogus -> java.lang.IllegalStateException:Could not list files in /etc/httpd/bogus

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

How reproducible:
always

Steps to Reproduce:
1. edit the httpd.conf to contain an Include directive with a non-existing path
2. run discovery or try to edit configuration of already inventoried apache server (after having enabled Augeas support in its connection properties), watch agent.log for measurement collections.
  
Actual results:
discovery fails with an exception in the description, configuration fails, measurement collection fails

Expected results:
the plugin should work even though the httpd fails to start with such invalid configuration so that the user can use the plugin to try and investigate the situation...

Additional info:

Comment 1 Lukas Krejci 2010-11-23 21:16:36 UTC
commit ae99b5bc0bf42909308a9d1efc09cee77d06ffc1
Author: Lukas Krejci <lkrejci>
Date:   Tue Nov 23 22:09:27 2010 +0100

    a couple of robustness enhancements to the apache plugin:
    BZ 656449 - use the matching algorithm between SNMP values and augeas nodes also
      when matching the vhost node by resource key, because resource key
      in RHQ 3 is based on the SNMP value.
    BZ 652247 - Log the SNMP errors only on DEBUG level during discovery because SNMP isn't
      required for it to work.
    BZ 656476 - Do not fail the discovery if a non-existent directory is used in an Include directive
    BZ 652247, BZ 656491 - Do not choke on invalid/unresolvable hostnames in VirtualHost or ServerName directives

Comment 2 Rajan Timaniya 2010-11-29 14:33:48 UTC
Verified on JON 2.4.1 build #28 (Revision: 10957)

1. Edited the httpd.conf to contain an Include directive with a non-existing path
2. Run discovery or try to edit configuration of already inventoried apache
server (after having enabled Augeas support in its connection properties),
watch agent.log for measurement collections.

Observation:
Plugin works even though the httpd fails to start with such invalid
configuration so that the user can use the plugin to try and investigate the
situation.

Comment 3 Corey Welton 2011-05-24 01:11:00 UTC
Bookkeeping - closing bug - fixed in recent release.

Comment 4 Corey Welton 2011-05-24 01:11:01 UTC
Bookkeeping - closing bug - fixed in recent release.