Bug 601176 - [apache] '*' isn't handled in the vhost port specification
Summary: [apache] '*' isn't handled in the vhost port specification
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 3.0.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Lukas Krejci
QA Contact: Corey Welton
Depends On:
Blocks: jon-sprint11-bugs
TreeView+ depends on / blocked
Reported: 2010-06-07 12:02 UTC by Lukas Krejci
Modified: 2010-08-12 16:50 UTC (History)
0 users

Fixed In Version: 2.4
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-08-12 16:50:24 UTC

Attachments (Terms of Use)

Description Lukas Krejci 2010-06-07 12:02:10 UTC
Description of problem:

According to the apache documentation, '*' is allowed as a port specification (meaning that given vhost is valid on all ports).

When reading in a configuration file that contains a vhost defined with a '*' placeholder for a port, one gets the following exception in the agent.log:

2010-06-07 13:48:02,630 WARN  [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Failure during discovery for [Apache Virtual Host] Resources - failed after 34 ms.
java.lang.Exception: Discovery component invocation failed.
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:270)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.NumberFormatException: For input string: "*"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:470)
        at java.lang.Integer.parseInt(Integer.java:514)
        at org.rhq.plugins.apache.util.HttpdAddressUtility$Address.parse(HttpdAddressUtility.java:183)
        at org.rhq.plugins.apache.util.HttpdAddressUtility.getVirtualHostSampleAddress(HttpdAddressUtility.java:233)
        at org.rhq.plugins.apache.ApacheVirtualHostServiceDiscoveryComponent.discoverResources(ApacheVirtualHostServiceDiscoveryComponent.java:100)
        at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:266)
        ... 5 more

When trying to create a new vhost using RHQ UI and entering for example '*' as the resource name, one gets a similar exception complaining about the format of the resource name.

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

How reproducible:

Steps to Reproduce:
1. Manually edit /etc/httpd/conf/httpd.conf (or whatever the main apache conf file is for your instance).
2. Add the virtual host entry like the one below to the end of the file
3. Restart the apache server.
4. Run full discovery on the agent (discovery -f on the agent command line)


1. Select "Virtual Host" from the "Create New" dropdown on the apache server inventory page in the RHQ GUI.
2. Enter* as the resource name, fill in "Document Root" property.
3. Click Save
4. See that the creation fails with an error message about format of the resource name.

Actual results:
Unable to read in or create vhosts with '*' placeholder for the port spec.

Expected results:
Such vhosts should be discovered correctly as well as it should be possible to create them fro the UI.

Additional info:

An example vhost entry that causes the above exception:

   ServerName all-ports
   DocumentRoot /var/www/html

Comment 1 Lukas Krejci 2010-06-25 12:01:09 UTC
Fixed in commit 3617607ac9b93a68a790a8c465679cb74f9f11f1

Comment 2 Corey Welton 2010-06-29 15:28:48 UTC
I am returning this back to dev for one, maybe two, reasons.

1) If i make the following change manually

   ServerName all-ports
   DocumentRoot /var/www/html

The resulting value in the Configuration tab, "Server Name" field shows no asterisk.  

2) When I try to create a virtual host via GUI (parent resource > Inventory > Overview | "Create New", and I enter a string akin to*, the creation fails with the following message

Wrong format of virtual host resource name. - Cause: java.lang.NumberFormatException:For input string: "*"

Comment 3 Lukas Krejci 2010-07-01 22:48:44 UTC
ServerName not having a '*' is expected. If you look at the vhost definition, the ServerName directive contains no asterisk either.

Having asterisk in the ServerName is actually illegal. If you look in the docs http://httpd.apache.org/docs/2.2/mod/core.html#servername, you'll notice that the ServerName directive contains basically a URL string that the server should report itself as. Therefore an asterisk as a port number has no meaning in this context and the error message you mention is correct in that respect.

When creating the virtual host, you actually enter the virtual host ip:port (or whatever applicable as per docs http://httpd.apache.org/docs/2.2/mod/core.html#virtualhost (i.e.* in the above example) as the resource name of the newly created vhost. This is a confusing limitation of the UI...

Comment 4 Corey Welton 2010-07-02 12:08:11 UTC
Alright... QA Verified then.

Comment 5 Corey Welton 2010-08-12 16:50:24 UTC
Mass-closure of verified bugs against JON.

Note You need to log in before you can comment on or make changes to this bug.