Commit 2527ee4e authored by Łukasz Nowak's avatar Łukasz Nowak

slap/standalone: Force remove partitions with chmod

In some cases partitions can chmod -w some paths, so use util.rmtree to
overcome this situation.
parent 66c13dde
Pipeline #10185 passed with stage
in 0 seconds
...@@ -60,7 +60,7 @@ from .interface.slap import IRequester ...@@ -60,7 +60,7 @@ from .interface.slap import IRequester
from ..grid.slapgrid import SLAPGRID_PROMISE_FAIL from ..grid.slapgrid import SLAPGRID_PROMISE_FAIL
from .slap import slap from .slap import slap
from ..util import dumps from ..util import dumps, rmtree
from ..grid.svcbackend import getSupervisorRPC from ..grid.svcbackend import getSupervisorRPC
...@@ -548,7 +548,7 @@ class StandaloneSlapOS(object): ...@@ -548,7 +548,7 @@ class StandaloneSlapOS(object):
self._logger.debug( self._logger.debug(
"removing partition no longer part of format spec %s", part) "removing partition no longer part of format spec %s", part)
# remove partition directory # remove partition directory
shutil.rmtree(part) rmtree(part)
# remove partition supervisor config, if it was not removed cleanly # remove partition supervisor config, if it was not removed cleanly
supervisor_conf = os.path.join( supervisor_conf = os.path.join(
self._instance_root, self._instance_root,
......
...@@ -111,6 +111,23 @@ class TestSlapOSStandaloneSetup(unittest.TestCase): ...@@ -111,6 +111,23 @@ class TestSlapOSStandaloneSetup(unittest.TestCase):
['slappart0'], ['slappart0'],
[cp.getId() for cp in standalone.computer.getComputerPartitionList()]) [cp.getId() for cp in standalone.computer.getComputerPartitionList()])
def test_reformat_less_chmod_files(self):
working_dir = tempfile.mkdtemp(prefix=__name__)
self.addCleanup(shutil.rmtree, working_dir)
standalone = StandaloneSlapOS(
working_dir, SLAPOS_TEST_IPV4, SLAPOS_TEST_PORT)
self.addCleanup(standalone.stop)
standalone.format(2, SLAPOS_TEST_IPV4, SLAPOS_TEST_IPV6)
# removing this directory should not be a problem
chmoded_dir_path = os.path.join(standalone.instance_directory, 'slappart1', 'directory')
os.mkdir(chmoded_dir_path)
os.chmod(chmoded_dir_path, 0o000)
standalone.format(1, SLAPOS_TEST_IPV4, SLAPOS_TEST_IPV6)
self.assertFalse(os.path.exists(chmoded_dir_path))
self.assertEqual(
['slappart0'],
[cp.getId() for cp in standalone.computer.getComputerPartitionList()])
def test_reformat_different_base_name(self): def test_reformat_different_base_name(self):
working_dir = tempfile.mkdtemp(prefix=__name__) working_dir = tempfile.mkdtemp(prefix=__name__)
self.addCleanup(shutil.rmtree, working_dir) self.addCleanup(shutil.rmtree, working_dir)
......
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