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
(cherry picked from commit 46586a62df
)
This commit is contained in:
parent
f0ed3cb7b1
commit
a35313d561
|
@ -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()
|
||||
|
|
|
@ -337,3 +337,37 @@ 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("compat", [
|
||||
True, False
|
||||
])
|
||||
def test_move_nodes(mocker, mock_subprocess, 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)}
|
||||
|
||||
mocker.patch("octane.util.env.incompatible_provision_method",
|
||||
return_value=compat)
|
||||
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")
|
||||
env_util.move_nodes(env, nodes)
|
||||
assert mock_wait_for.called_once_with(nodes, 'provisioned')
|
||||
if compat:
|
||||
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 == []
|
||||
|
|
|
@ -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
|
||||
|
@ -284,6 +285,9 @@ def move_nodes(env, nodes):
|
|||
env_id = env.data['id']
|
||||
for node in nodes:
|
||||
node_id = node.data['id']
|
||||
if incompatible_provision_method(env):
|
||||
disk.create_configdrive_partition(node)
|
||||
disk.update_node_partition_info(node_id)
|
||||
subprocess.call(
|
||||
["fuel2", "env", "move", "node", str(node_id), str(env_id)])
|
||||
LOG.info("Nodes provision started. Please wait...")
|
||||
|
|
Loading…
Reference in New Issue