Improve partitions and disk metadata handling
Partitions schema and disk metadata at nodes must be updated only if they are scheduled for reprovisioning, and the provisioning method has changed to incompatible (i.e. from 'cobbler' to 'image') due to the shift of release version. Move logic that manages partitions from upgrade handlers to function that actually initiates the re-provisioning of node. This ensures that for every node this is applied only once and only if necessary. Change-Id: I28718564543e3ccd92d985bd79c76e509e8eae1f Closes-bug: 1585938 Closes-bug: 1575054
This commit is contained in:
parent
b5d884296c
commit
46586a62df
|
@ -17,7 +17,6 @@ import subprocess
|
|||
|
||||
from octane.handlers import upgrade
|
||||
from octane import magic_consts
|
||||
from octane.util import disk
|
||||
from octane.util import env as env_util
|
||||
from octane.util import node as node_util
|
||||
from octane.util import plugin
|
||||
|
@ -28,10 +27,6 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
class ComputeUpgrade(upgrade.UpgradeHandler):
|
||||
def prepare(self):
|
||||
env = self.node.env
|
||||
if env_util.incompatible_provision_method(env):
|
||||
disk.create_configdrive_partition()
|
||||
disk.update_node_partition_info(self.node.id)
|
||||
if not self.live_migration:
|
||||
self.preserve_partition()
|
||||
self.shutoff_vms()
|
||||
|
|
|
@ -355,3 +355,39 @@ def test_incompatible_provision_method(mocker,
|
|||
assert ("Cannot find version of environment {0}:"
|
||||
" attribute 'fuel_version' missing or has incorrect value"
|
||||
.format(mock_env.data["id"])) == exc_info.value.args[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("provision,compat", [
|
||||
(True, True,),
|
||||
(False, True),
|
||||
])
|
||||
def test_move_nodes(mocker, mock_subprocess, provision, compat):
|
||||
env = mock.Mock()
|
||||
env.data = {
|
||||
'id': 'test-id',
|
||||
}
|
||||
nodes = [mock.Mock(), mock.Mock()]
|
||||
|
||||
for idx, node in enumerate(nodes):
|
||||
node.data = {'id': str(idx)}
|
||||
|
||||
mock_create_configdrive = mocker.patch(
|
||||
"octane.util.disk.create_configdrive_partition")
|
||||
mock_update_node_partinfo = mocker.patch(
|
||||
"octane.util.disk.update_node_partition_info")
|
||||
mock_wait_for = mocker.patch(
|
||||
"octane.util.env.wait_for_nodes")
|
||||
mock_get_provision_method = mocker.patch(
|
||||
"octane.util.env.incompatible_provision_method")
|
||||
mock_get_provision_method.return_value = compat
|
||||
env_util.move_nodes(env, nodes, provision)
|
||||
if provision:
|
||||
assert mock_create_configdrive.call_args_list == \
|
||||
[mock.call(node) for node in nodes]
|
||||
assert mock_update_node_partinfo.call_args_list == \
|
||||
[mock.call(node.data["id"]) for node in nodes]
|
||||
mock_wait_for.assert_called_once_with(nodes, 'provisioned')
|
||||
else:
|
||||
assert mock_create_configdrive.call_args_list == []
|
||||
assert mock_update_node_partinfo.call_args_list == []
|
||||
assert mock_wait_for.call_args_list == []
|
||||
|
|
|
@ -29,6 +29,7 @@ from fuelclient.objects import task as task_obj
|
|||
from octane.helpers import tasks as tasks_helpers
|
||||
from octane.helpers import transformations
|
||||
from octane import magic_consts
|
||||
from octane.util import disk
|
||||
from octane.util import sql
|
||||
from octane.util import ssh
|
||||
from octane.util import subprocess
|
||||
|
@ -294,6 +295,9 @@ def move_nodes(env, nodes, provision=True, roles=None):
|
|||
for node in nodes:
|
||||
node_id = node.data['id']
|
||||
cmd_move_node = cmd + [str(node_id), str(env_id)]
|
||||
if provision and incompatible_provision_method(env):
|
||||
disk.create_configdrive_partition(node)
|
||||
disk.update_node_partition_info(node.data["id"])
|
||||
subprocess.call(cmd_move_node)
|
||||
if provision:
|
||||
LOG.info("Nodes provision started. Please wait...")
|
||||
|
|
Loading…
Reference in New Issue