Bug 1124969

Summary: org.rhq.cassandra.util.ConfigEditor cannot be used on files owned by another user
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: AgentAssignee: RHQ Project Maintainer <rhq-maint>
Status: NEW --- QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.12CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
May have been covered in another diff? none

Description Elias Ross 2014-07-30 18:41:23 UTC
Description of problem:

RHQ agent if not run as root user fails to discover Cassandra processes because of this error:

2014-07-30 18:26:25,640 WARN  [InventoryManager.discovery-1] (InventoryManager)- Failure during discovery for [RHQ Storage Node] Resources - failed after 11 ms.
java.lang.Exception: Discovery component invocation failed.
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:309)
        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:662)
Caused by: org.rhq.cassandra.util.ConfigEditorException: Failed to create /cassandra/d1/conf/.cassandra.yaml.bak
        at org.rhq.cassandra.util.ConfigEditor.createBackup(ConfigEditor.java:84)
        at org.rhq.cassandra.util.ConfigEditor.load(ConfigEditor.java:42)
        at org.rhq.plugins.cassandra.CassandraNodeDiscoveryComponent.getDetails(CassandraNodeDiscoveryComponent.java:152)
        at org.rhq.plugins.cassandra.CassandraNodeDiscoveryComponent.scanForResources(CassandraNodeDiscoveryComponent.java:84)
        at org.rhq.plugins.storage.StorageNodeDiscoveryComponent.discoverResources(StorageNodeDiscoveryComponent.java:53)
        at sun.reflect.GeneratedMethodAccessor9173.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:305)
        ... 5 more
Caused by: java.io.FileNotFoundException: /cassandra/d1/conf/.cassandra.yaml.bak (Permission denied)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
        at org.rhq.cassandra.util.ConfigEditor.copyFile(ConfigEditor.java:183)
        at org.rhq.cassandra.util.ConfigEditor.createBackup(ConfigEditor.java:82)
        ... 13 more

Note that this instance of Cassandra is NOT managed by RHQ (not an RHQ storage node).

The fix is to only do the backup if the settings are saved. Patch coming...

Comment 1 Elias Ross 2015-06-24 23:33:05 UTC
Created attachment 1042887 [details]
May have been covered in another diff?