runner: do not remove whole instance root directory, but only instance home directories.

parent 8fbf647f
...@@ -11,6 +11,7 @@ import os ...@@ -11,6 +11,7 @@ import os
import sup_process import sup_process
import re import re
import shutil import shutil
import stat
import thread import thread
import time import time
import urllib import urllib
...@@ -464,13 +465,19 @@ def removeInstanceRoot(config): ...@@ -464,13 +465,19 @@ def removeInstanceRoot(config):
"""Clean instance directory and stop all its running processes""" """Clean instance directory and stop all its running processes"""
if os.path.exists(config['instance_root']): if os.path.exists(config['instance_root']):
svcStopAll(config) svcStopAll(config)
for root, dirs, _ in os.walk(config['instance_root']): for instance_directory in os.listdir(config['instance_root']):
for fname in dirs: instance_directory = os.path.join(config['instance_root'], instance_directory)
fullPath = os.path.join(root, fname) # XXX: hardcoded
if not os.access(fullPath, os.W_OK): if stat.S_ISSOCK(os.stat(instance_directory).st_mode) or os.path.isfile(instance_directory):
# Some directories may be read-only, preventing to remove files in it # Ignore non-instance related files
os.chmod(fullPath, 0744) continue
shutil.rmtree(config['instance_root']) for root, dirs, _ in os.walk(instance_directory):
for fname in dirs:
fullPath = os.path.join(root, fname)
if not os.access(fullPath, os.W_OK):
# Some directories may be read-only, preventing to remove files in it
os.chmod(fullPath, 0744)
shutil.rmtree(instance_directory)
def getSvcStatus(config): def getSvcStatus(config):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment