Bug 712429 - Plug-in configuration upgrade should contain resource name of conflicting resources in upgrade error/failure messages
Summary: Plug-in configuration upgrade should contain resource name of conflicting res...
Alias: None
Product: RHQ Project
Classification: Other
Component: Agent
Version: 4.1
Hardware: All
OS: All
high vote
Target Milestone: ---
: ---
Assignee: Lukas Krejci
QA Contact: Mike Foley
Depends On:
Blocks: jon3
TreeView+ depends on / blocked
Reported: 2011-06-10 15:10 UTC by Larry O'Leary
Modified: 2013-09-01 19:18 UTC (History)
2 users (show)

Clone Of:
Last Closed: 2013-09-01 19:18:59 UTC

Attachments (Terms of Use)

Description Larry O'Leary 2011-06-10 15:10:43 UTC
When performing an upgrade of Apache resource plug-in configuration and ambiguous resource keys are detected, the current message simply indicates that the vhost resource key is ambiguous and asks the user to manually correct the issue. For usability the message must include which resource (by name and key) is ambiguous with this resource. This will allow the user to easily resolve the ambiguity without having to open each resource and manually reviewing to find the problem resource.

Comment 1 Lukas Krejci 2011-06-10 15:21:42 UTC
This is a generic issue of the plugin container, not directly tied to apache plugin because the conflict resolution is done in plugin container, not the plugins themselves - they just report what the resource keys should look like.

Comment 2 Charles Crouch 2011-06-15 15:30:45 UTC
So does that mean we can or cannot fix this bug?

Comment 3 Lukas Krejci 2011-06-16 07:29:20 UTC
We can fix this, I just modified the bug title to not specifically mention apache because this needs (and can be) fixed generically for all plugins implementing resource upgrade.

Comment 4 Lukas Krejci 2011-06-16 17:35:09 UTC
commit ab97d23a233552d206f198f71bcdd711618a7bb0
Author: Lukas Krejci <lkrejci@redhat.com>
Date:   Thu Jun 16 19:26:15 2011 +0200

    BZ 712429 - giving out more useful error message in case of resource key conflict during the resource upgrade.
    The error message now contains the details of the resources given resource conflicts with so that the user can easily locate them.


An example of the error message given out:

java.lang.IllegalStateException: Upgrading the resource [Resource[id=10006, type=Apache Virtual Host, key=localhost.localdomain:0, name=Virtual Host localhost.localdomain:0, parent=localhost.localdomain Apache 2.2.17 (/home/metlos/Progs/apache-2.2.17/build/)]] using these updates [ResourceUpgradeRequest[resourceId = '10006', newResourceKey = 'injected-failure', newName = 'null', newDescription = 'null', upgradeErrorMessage = 'null', upgradeErrorStackTrace = 'null']] would render the inventory invalid because of the following reasons: After the upgrade, the following resources would have the same resource key which is illegal. This is an issue of either the old or the new version of the plugin 'Apache'. Please consult the documentation of the plugin to see what are the recommended steps to resolve this situation:
Resource[id=10005, type=Apache Virtual Host, key=, name=Virtual Host, parent=localhost.localdomain Apache 2.2.17 (/home/metlos/Progs/apache-2.2.17/build/)],
Resource[id=10007, type=Apache Virtual Host, key=, name=Virtual Host, parent=localhost.localdomain Apache 2.2.17 (/home/metlos/Progs/apache-2.2.17/build/)]
	at org.rhq.core.pc.upgrade.ResourceUpgradeDelegate.sendRequests(ResourceUpgradeDelegate.java:176)
	at org.rhq.core.pc.inventory.InventoryManager.activateAndUpgradeResources(InventoryManager.java:2714)
	at org.rhq.core.pc.inventory.InventoryManager.initialize(InventoryManager.java:228)
	at org.rhq.core.pc.PluginContainer.startContainerService(PluginContainer.java:425)
	at org.rhq.core.pc.PluginContainer.initialize(PluginContainer.java:279)
	at org.rhq.enterprise.agent.AgentMain.startPluginContainer(AgentMain.java:1867)
	at org.rhq.enterprise.agent.AgentMain.start(AgentMain.java:648)
	at org.rhq.enterprise.agent.AgentMain.main(AgentMain.java:418)

Comment 5 Mike Foley 2011-10-03 19:56:32 UTC
verified 10/3/2011 as follows:

1) wrote custom plugin
2) uploaded plugin
3) scan for updates, plugins update
4) discovered and inventoried resource
5) made configuration change 
6) upgraded plugin (version #, and some text)
7) uploaded updated plugin
8) scan for updates, plugins update
9) reviewed agent log for errors ... none
10) reviewed server log for errors ... none
11) reviewed UI to make sure it showed the configuration history

Comment 6 Larry O'Leary 2011-10-03 23:26:16 UTC
Not sure test steps cover this. This issue pertains to error messages that appear during the upgrade. The goal would be to ensure that reviewing the result in the UI, one can easily tell which resources the upgrade error pertained to.

Comment 7 Mike Foley 2011-10-04 14:16:44 UTC
code review of change 


String errorString = "Upgrading the resource [" + resource + "] using these updates ["
+                                + request + "] would render the inventory invalid because of the following reasons: "
+                                + upgradeErrors;

satisifies the verification

Comment 8 Lukas Krejci 2011-10-05 10:53:38 UTC
The code snippet above only differs in whitespace from the previous version, so I wouldn't call this verified.

The "meat" of the fix are the changes to the checkUpgradeValid() method, which produces the "upgradeErrors" in the code snippet above.

To verify this at runtime rather than just code inspection (choose whichever you see fit), you'd have to create a plugin which would have the following characteristics:

1) make sure your "original" version of the plugin discovers at least 2 resources of the same resource type under a single parent (i.e. 2 resources under a platform).

2) In the new version of the plugin, the discovery component of the resource type implements ResourceUpgradeFacet.

3) The upgrade() method on the discovery component needs to assign the same resource key to at least 2 pre-existing sibling resources (i.e. resources having the same parent resource). This creates the conflict.

4) When the agent updates the plugins, it should run the resource upgrade upon the start of the plugin container and should report the conflicts as resource errors on the conflicting resources. These should appear as the yellow warning triangles next to the availability icons on the resource details page and should contain the error message from which it would be clear what happened and what other resources are involved. Also the conflicting resources should be DOWN until the conflict clears.

Comment 9 Heiko W. Rupp 2013-09-01 19:18:59 UTC
Bulk closing of BZs that have no target version set, but which are ON_QA for more than a year and thus are in production for a long time.

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