Bug 753000 - Error on the initial snapshot when creating a drift profile on Windows
Summary: Error on the initial snapshot when creating a drift profile on Windows
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: drift
Version: unspecified
Hardware: Unspecified
OS: Unspecified
high
urgent
Target Milestone: ---
: JON 3.0.0,RHQ 4.3.0
Assignee: John Sanda
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: 707225
TreeView+ depends on / blocked
 
Reported: 2011-11-11 01:54 UTC by Deon Ballard
Modified: 2012-02-07 19:18 UTC (History)
1 user (show)

Fixed In Version: 4.3
Clone Of:
Environment:
Last Closed: 2012-02-07 19:18:01 UTC
Embargoed:


Attachments (Terms of Use)

Description Deon Ballard 2011-11-11 01:54:37 UTC
Description of problem:
I am trying to set up drift on my Windows 7 64-bit desktop. The drift detection fails when getting the initial snapshot with this error in the agent logs:

2011-11-10 19:41:24,293 ERROR [pool-3-thread-2] (rhq.core.pc.drift.DriftDetector)- Drift detection failed: Illegal/unsupported escape sequence near index 4
(C:\Users\elladeon\Documents\work\redhat\JON\trunk\Admin_Config\en-US/(.*[^/]*))
    ^
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 4
(C:\Users\elladeon\Documents\work\redhat\JON\trunk\Admin_Config\en-US/(.*[^/]*))
    ^
	at java.util.regex.Pattern.error(Unknown Source)
	at java.util.regex.Pattern.escape(Unknown Source)
	at java.util.regex.Pattern.atom(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.compile(Unknown Source)
	at java.util.regex.Pattern.<init>(Unknown Source)
	at java.util.regex.Pattern.compile(Unknown Source)
	at org.rhq.core.util.file.FileUtil.generateRegex(FileUtil.java:428)
	at org.rhq.core.pc.drift.FilterFileVisitor.<init>(FilterFileVisitor.java:86)
	at org.rhq.core.pc.drift.DriftDetector.generateSnapshot(DriftDetector.java:417)
	at org.rhq.core.pc.drift.DriftDetector.run(DriftDetector.java:117)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
2011-11-10 19:41:24,294 INFO  [pool-3-thread-2] (rhq.core.pc.drift.DriftDetector)- Reverting snapshot for DriftDetectionSchedule[resourceId: 10001, driftDefinitionId: 0, driftDefinitionName: Template-File System]

Path: C:\Users\elladeon\Documents\work\redhat\JON\trunk\Admin_Config\

Version-Release number of selected component (if applicable):
Version: 4.2.0.JON300-SNAPSHOT
Build Number: 19b0ceb

How reproducible:
Always.

Steps to Reproduce:
Create a drift definition for a Windows platform resource.

Comment 1 Deon Ballard 2011-11-11 03:25:50 UTC
I tried a pathname without an underscore, and got a different parse error:
http://pastebin.test.redhat.com/67641

That was for C:\Users\elladeon\Documents\work\redhat\freeipa-guide\ipa-admin.

I tried C:\Users\elladeon\Documents\work\test -- no hyphens or underscores -- and got the original error again.

2011-11-10 21:16:24,404 ERROR [pool-3-thread-1] (rhq.core.pc.drift.DriftDetector)- Drift detection failed: Illegal/unsupported escape sequence near index 4
(C:\Users\elladeon\Documents\work\test/(.*[^/]*))|(C:\Users\elladeon\Documents\work\test\drift/(.*[^/]*))
    ^
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 4
(C:\Users\elladeon\Documents\work\test/(.*[^/]*))|(C:\Users\elladeon\Documents\work\test\drift/(.*[^/]*))
    ^
	at java.util.regex.Pattern.error(Unknown Source)
	at java.util.regex.Pattern.escape(Unknown Source)
	at java.util.regex.Pattern.atom(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.group0(Unknown Source)
	at java.util.regex.Pattern.sequence(Unknown Source)
	at java.util.regex.Pattern.expr(Unknown Source)
	at java.util.regex.Pattern.compile(Unknown Source)
	at java.util.regex.Pattern.<init>(Unknown Source)
	at java.util.regex.Pattern.compile(Unknown Source)
	at org.rhq.core.util.file.FileUtil.generateRegex(FileUtil.java:428)
	at org.rhq.core.pc.drift.FilterFileVisitor.<init>(FilterFileVisitor.java:86)
	at org.rhq.core.pc.drift.DriftDetector.generateSnapshot(DriftDetector.java:417)
	at org.rhq.core.pc.drift.DriftDetector.run(DriftDetector.java:117)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)




Then I tried the short and simple C:\rhq\test and that worked. Detection ran as expected.

Comment 2 John Sanda 2011-11-11 21:48:47 UTC
It turns out that this problem has been around since we initially introduced filtering with drift definitions. When a definition is created with filters, those filters are compiled into regular expressions. The regular expressions are then used to determine which files to includes/exclude for drift monitoring. The problem is that we are not escaping backslashes which are of course used in paths on Windows platforms. 

Jay and I have discussed this and decided to normalize on using forward slashes everywhere. We already do this in some places but not in the paths for the base directory or filters.

Comment 3 Jay Shaughnessy 2011-11-15 03:07:49 UTC
There was definitely support lacking for windows paths in the base
directory and path filters.  

master commit 945cacd1ee63aa0a6a6743ffcbc941cda606d3cf


Test Notes:
Can be tested using any windows platform. Make sure you use filters.

Comment 4 Jay Shaughnessy 2011-11-15 03:35:24 UTC
release.x commit 63f8e66b055b487821151763e69119646ac352e5

Comment 5 Jay Shaughnessy 2011-11-16 16:43:33 UTC
Sorry, wrong release commit:

release3.x commit 338e7cf8d267bd6da9891a7ed5cfab2dd8f1d6f1

Comment 6 Mike Foley 2011-11-17 19:53:13 UTC
okay ... this looks good on windows.

1) no errors on inital snapshot
2) i am using filters ... and that is working  

4 test cases as follows:

base dir                path           pattern
----------------------------------------------
c:\foo                /mydir         no pattern
c:\foo                /mydir          txt
c:\foo                /mydir         **\*.txt
c:\foo                -----            -------

Comment 7 Mike Foley 2012-02-07 19:18:01 UTC
changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE


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