summaryrefslogtreecommitdiff
path: root/hooks
diff options
authorGuillermo Gonzalez <guillermo.gonzalez@canonical.com>2015-05-27 10:06:54 -0300
committerGuillermo Gonzalez <guillermo.gonzalez@canonical.com>2015-05-27 10:06:54 -0300
commit43f214381873213887b04c639a178efd25f08e5f (patch)
tree33a6ed2fefbd8a5430991c88bbf507f056ce12d4 /hooks
parente7cb3c31920fe3c364f260f95129fd13177381d0 (diff)
Add flag to signal when the new_mongo_dir was just created and migrate existing data directory
Diffstat (limited to 'hooks')
-rwxr-xr-xhooks/hooks.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py
index 941caed..e388d46 100755
--- a/hooks/hooks.py
+++ b/hooks/hooks.py
@@ -1581,9 +1581,11 @@ def config_changed_volume_apply():
# Create a directory structure below "new" mount_point
curr_dir_stat = os.stat(data_directory_path)
+ new_mongo_dir_just_created = False
if not os.path.isdir(new_mongo_dir):
juju_log("mkdir %s" % new_mongo_dir)
os.mkdir(new_mongo_dir)
+ new_mongo_dir_just_created = True
# copy permissions from current data_directory_path
os.chown(new_mongo_dir, curr_dir_stat.st_uid, curr_dir_stat.st_gid)
os.chmod(new_mongo_dir, curr_dir_stat.st_mode)
@@ -1595,7 +1597,7 @@ def config_changed_volume_apply():
if not stop_hook():
juju_log("stop_hook() failed - can't migrate data.")
return False
- if not os.path.exists(new_mongo_dir):
+ if not os.path.exists(new_mongo_dir) or new_mongo_dir_just_created:
juju_log("migrating mongo data {}/ -> {}/".format(
data_directory_path, new_mongo_dir))
# void copying PID file to perm storage (shouldn't be any...)