Bug 663745

Summary: JON 241: If Apache plug-in fails to parse/load a discovered Apache configuration file, discovery of remaining Apache processes is halted
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: medium    
Version: 3.0.0CC: loleary, skondkar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 653695 Environment:
JON 2.4 Windows 2003 Apache HTTPD 2.2 Apache Plug-in
Last Closed: 2011-05-24 01:08:38 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: 616081    

Description Lukas Krejci 2010-12-16 18:14:13 UTC
+++ This bug was initially created as a clone of Bug #653695 +++

If more than one Apache process is running on a platform and discovery fails to load or parse the configuration file of one of the Apache instances, the entire discovery process is terminated leaving all Apache instances un-discovered.

This is due to an exception that can bubble up and break the loop which iterates through each Apache instance in org.rhq.plugins.apache.ApacheServerDiscoveryComponent.discoverResources(ResourceDiscoveryContext<PlatformComponent> discoveryContext) when loadParser(serverConfigFile.getAbsolutePath(), serverRoot) is invoked.

To reproduce (in JON 2.4):
  1) Install Apache on a Windows platform at its default location (for example: C:\Program Files\Apache Software Foundation\Apache2.2)

  2) Do not register Apache to start as a service, if it is, un-register it or set the service from Auto start to Manual start

  3) Move the httpd.conf file from the Apache conf directory to an alternate location (For example: from C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf to C:\Program Files\Apache Software Foundation\00368619\Apache2.2\conf\httpd.conf)

  4) Register an instance of Apache as a Windows Service and point it to the alternate configuration file (For example: "C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe" -k install -n "Apache_00368619" -f "C:\Program Files\Apache Software Foundation\00368619\Apache2.2\conf\httpd.conf")

  5) Have the Agent perform discovery

The result should be that the configuration file could not be found for the first process discovered and the real process (with alternate configuration) will not be discovered due to the first process failing to be discovered.

--- Additional comment from loleary on 2010-11-15 18:21:18 EST ---

Created attachment 460693 [details]
Proposed patch based off rhq master

Here is the proposed patch that will address this bug. It is confined to the specific test case described in the bug's original description.

Comment 1 Lukas Krejci 2010-12-16 18:47:19 UTC
commit 510edfa8fac2234ef186b837e8119f7708aa6d18
Author: Lukas Krejci <lkrejci>
Date:   Thu Dec 16 19:45:36 2010 +0100

    BZ 663745 - refactor the apache discovery to continue processing the rest of process scan results after an error during processing one of them.

Comment 2 Sunil Kondkar 2010-12-21 09:57:22 UTC
Verified on Jon241 build#52 (build number: 10966:3cea406)

1) Installed Apache 2.2.17 on a Windows platform at its default location (C:\Program Files\Apache Software Foundation\Apache2.2)

2) Set the Apache service from Auto start to Manual start.

3) Moved the httpd.conf file from the Apache conf directory to an alternate
location (For example: from C:\Program Files\Apache Software
Foundation\Apache2.2\conf\httpd.conf to C:\Program Files\Apache Software
Foundation\00368619\Apache2.2\conf\httpd.conf)

4) Registered an instance of Apache as a Windows Service and point it to the
alternate configuration file (For example: "C:\Program Files\Apache Software
Foundation\Apache2.2\bin\httpd.exe" -k install -n "Apache_00368619" -f
"C:\Program Files\Apache Software Foundation\00368619\Apache2.2\conf\httpd.conf")

Observed that the Apache server with alternate configuration (C:\Program Files\Apache Software Foundation\00368619\Apache2.2\conf\httpd.conf) is discovered.

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