Bug 786603

Summary: manageRootDir=true is broken - it isn't removing files at the dest dir level
Product: [Other] RHQ Project Reporter: Charles Crouch <ccrouch>
Component: ProvisioningAssignee: John Mazzitelli <mazz>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 4.2CC: hbrock, hrupp, mazz, skondkar, spinder
Target Milestone: ---   
Target Release: JON 3.0.1   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 784124 Environment:
Last Closed: 2013-09-03 11:14:37 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 784124    
Bug Blocks:    

Description Charles Crouch 2012-02-01 16:45:54 EST
+++ This bug was initially created as a clone of Bug #784124 +++

Deploy a bundle without manageRootDir or manageRootDir=true (which is the defualt).

See that it works. Today, me and jay are seeing it broken.

--- Additional comment from ccrouch@redhat.com on 2012-01-24 09:38:07 EST ---

We need to determine which versions this impacts

--- Additional comment from mazz@redhat.com on 2012-01-24 13:25:26 EST ---

looks like our unit tests in this area didn't cover this scenario.

We do have covered the scenario where, upon initial deployment, the manageRootDir=false:


but not the inverse. I just added:


and it does indeed fail.

What does this mean? It means if you have a destination directory (call it /dir/foo) and it isn't empty (i.e. it already has files in it), upon initial bundle deployment, those files will not be removed - they will remain even after the full bundle has been completely deployed.

It is possible that upon bundle upgrade, those files will be removed. I'll add some tests to confirm.

--- Additional comment from mazz@redhat.com on 2012-01-26 16:46:34 EST ---

fyi: There are several other unit test classes covering the deployment stuff in core/util module.

--- Additional comment from mazz@redhat.com on 2012-01-26 17:07:38 EST ---

The problem here is that when you do an INITIAL bundle deployment, and you asked that RHQ manage the destination directory, any files that happened to already exist in the deployment's destination directory were not touched. This should not have been. The dest dir should have started empty because we are being told that we should manage the full destination directory content - which means if there are files in here that are NOT part of the bundle should be removed. This happened correctly during a bundle UPDATE but not when we did the initial deployment for the first time.

Now, when we do the initial deployment AND we are to manage the destination directory, we will backup whatever files we find in the metadata directory's backup location, then we remove the files to get them out of the way. This ensures we start with a clean, empty destination directory.

The main change was done in org.rhq.core.util.updater.Deployer.performInitialDeployment

--- Additional comment from mazz@redhat.com on 2012-01-26 17:20:36 EST ---

git commit to master: 9946f3e2b2b4b0a86ebe001594818f016a4c4130

--- Additional comment from mazz@redhat.com on 2012-01-27 10:03:37 EST ---

forgot to fix a unit test... commited this to master: d8bd668

--- Additional comment from mfoley@redhat.com on 2012-01-31 13:32:23 EST ---

Bundles: https://tcms.engineering.redhat.com/run/33098/   ---COMPLETE
Comment 1 Charles Crouch 2012-02-01 16:48:41 EST
Fix needs to brought back from master and committed to the JON 3.0.1 branch (release/jon3.0.x), checked by engineering and then pushed to MODIFIED state, then finally ON_QA when its available in a build for QE
Comment 2 John Mazzitelli 2012-02-02 11:16:37 EST
release/jon3.0.x commit: 9eebf13
Comment 3 Simeon Pinder 2012-02-17 00:32:35 EST
Moving to ON_QA for testing with JON 3.0.1.GA RC5 or better:
Comment 4 Sunil Kondkar 2012-02-21 06:25:32 EST
Verified on JON 3.0.1.GA RC5 (Build Number: dd8a001:fbca611)

Deployed a bundle without manageRootDir and other with manageRootDir=true

Verified that the initial deployment creates a backup for the existing files in the destination directory and the files are removed from destination directory.

Below is the audit trail for initial deployment:

Added Files: 1
Deleted Files: 2
Changed Files: 0
Backed Up Files: 2
    helloworld.war -> /install/test/.rhqdeployments/10011/backup/helloworld.war
    test.txt -> /install/test/.rhqdeployments/10011/backup/test.txt
Restored Files: 0
Ignored Files: 0
Realized Files: 0
Was Cleaned?: false
Errors: 0

Also verified that the manageRootDir=true creates a backup during upgrade. Below is the deployment audit trail:

Added Files: 0
Deleted Files: 1
Changed Files: 1
Backed Up Files: 1
    testfile.txt -> /install/test/.rhqdeployments/10012/backup/testfile.txt
Restored Files: 0
Ignored Files: 0
Realized Files: 0
Was Cleaned?: false
Errors: 0
Comment 5 Heiko W. Rupp 2013-09-03 11:14:37 EDT
Bulk closing of old issues in VERIFIED state.