diff --git a/client-cli/pvc.py b/client-cli/pvc.py index 0f72fb4d..4ecd0daf 100755 --- a/client-cli/pvc.py +++ b/client-cli/pvc.py @@ -563,7 +563,7 @@ def vm_move(domain, target_node, selector): ) @click.option( '-f', '--force', 'force_migrate', is_flag=True, default=False, - help='Force migrate an already migrated VM.' + help='Force migrate an already migrated VM; does not replace an existing previous node value.' ) def vm_migrate(domain, target_node, selector, force_migrate): """ diff --git a/client-common/vm.py b/client-common/vm.py index 52f59edd..7a34ce2a 100644 --- a/client-common/vm.py +++ b/client-common/vm.py @@ -444,6 +444,10 @@ def migrate_vm(zk_conn, domain, target_node, selector, force_migrate, is_cli=Fal common.stopZKConnection(zk_conn) return False, 'ERROR: VM "{}" is already running on node "{}".'.format(domain, current_node) + # Don't overwrite an existing last_node when using force_migrate + if last_node and force_migrate: + current_node = last_node + zkhandler.writedata(zk_conn, { '/domains/{}/state'.format(dom_uuid): 'migrate', '/domains/{}/node'.format(dom_uuid): target_node, diff --git a/docs/manuals/api.md b/docs/manuals/api.md index d1b2d3e0..3763b225 100644 --- a/docs/manuals/api.md +++ b/docs/manuals/api.md @@ -249,7 +249,7 @@ If `selector` is specified, the automatic node determination will use `selector` Attempting to `migrate` an already-migrated VM will return a failure. -If `flag_force` is specified, migrate the VM even if it has already been migrated. The previous node value will be replaced with the current node; e.g. if VM `test` was on `pvchv1`, then `migrate`ed to `pvchv2`, then `flag_force` `migrate`ed to `pvchv3`, the `previous_node` would then be `pvchv2`. This can be repeated indefinitely. Note however that `move` is almost always better and more consistent than repeated `flag_force` `migrate` actions. +If `flag_force` is specified, migrate the VM even if it has already been migrated. The previous node value will not be replaced; e.g. if VM `test` was on `pvchv1`, then `migrate`ed to `pvchv2`, then `flag_force` `migrate`ed to `pvchv3`, the `previous_node` would still be `pvchv1`. This can be repeated indefinitely. #### `/api/v1/vm//unmigrate` * Methods: `POST`