Commit 89179c36 authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Fix calls to Update in TLMigrateInstance



Instead of modifying the primary node on an object and calling 'Update',
a new method was added to ConfigWriter.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 85dbff19
......@@ -582,8 +582,8 @@ class TLMigrateInstance(Tasklet):
self.feedback_fn("* instance running on secondary node (%s),"
" updating config" %
self.cfg.GetNodeName(self.target_node_uuid))
self.instance.primary_node = self.target_node_uuid
self.cfg.Update(self.instance, self.feedback_fn)
self.cfg.SetInstancePrimaryNode(self.instance.uuid,
self.target_node_uuid)
demoted_node_uuid = self.source_node_uuid
else:
self.feedback_fn("* instance confirmed to be running on its"
......@@ -789,10 +789,8 @@ class TLMigrateInstance(Tasklet):
raise errors.OpExecError("Could not finalize instance migration: %s" %
msg)
self.instance.primary_node = self.target_node_uuid
# distribute new instance config to the other nodes
self.cfg.Update(self.instance, self.feedback_fn)
self.cfg.SetInstancePrimaryNode(self.instance.uuid, self.target_node_uuid)
self.instance = self.cfg.GetInstanceInfo(self.instance_uuid)
result = self.rpc.call_instance_finalize_migration_dst(
self.target_node_uuid, self.instance, migration_info, True)
......@@ -886,9 +884,8 @@ class TLMigrateInstance(Tasklet):
if not ShutdownInstanceDisks(self.lu, self.instance, ignore_primary=True):
raise errors.OpExecError("Can't shut down the instance's disks")
self.instance.primary_node = self.target_node_uuid
# distribute new instance config to the other nodes
self.cfg.Update(self.instance, self.feedback_fn)
self.cfg.SetInstancePrimaryNode(self.instance.uuid, self.target_node_uuid)
self.instance = self.cfg.GetInstanceInfo(self.instance_uuid)
# Only start the instance if it's marked as up
if self.instance.admin_state == constants.ADMINST_UP:
......
......@@ -1930,6 +1930,18 @@ class ConfigWriter(object):
"""
return self._UnlockedGetInstanceNames(inst_uuids)
@_ConfigSync()
def SetInstancePrimaryNode(self, inst_uuid, target_node_uuid):
"""Sets the primary node of an existing instance
@param inst_uuid: instance UUID
@type inst_uuid: string
@param target_node_uuid: the new primary node UUID
@type target_node_uuid: string
"""
self._UnlockedGetInstanceInfo(inst_uuid).primary_node = target_node_uuid
def _UnlockedGetInstanceNames(self, inst_uuids):
return [self._UnlockedGetInstanceName(uuid) for uuid in inst_uuids]
......
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