diff options
| author | Rick Harris <rconradharris@gmail.com> | 2011-09-21 22:14:15 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-09-21 22:14:15 +0000 |
| commit | d865a2a97c013a811c2c6baad00fa1eb95406c8d (patch) | |
| tree | e8a8881f91717d2f16b4de995f774e92f168e7b5 /plugins | |
| parent | 221509abcdef0077e8c592c5e0a6ae3add78b007 (diff) | |
| parent | 4fb602fcbc2a7b0681e79454fe7c3f01110b1f0e (diff) | |
This patch adds instance progress which is used by the OpenStack API to indicate how far along the current executing action is (BUILD/REBUILD, MIGRATION/RESIZE).
For the first cut, we decided to keep it simple and compute progress by counting discrete steps. This is not ideal since some steps, in particular, steps which involve transferring large amounts of data over the network, take *much* longer than others. A better approximation would account for the data-transferred to the destination host, since in most cases, this dominates the time spent.
In addition to adding progress, this patch:
- Allows resizes to use same host for source and destination which is useful for dev environments without a second host. This is enabled by the --allow_resize_to_same_host flag.
- Fixes a bug in the glance and migration XenAPI plugins where the VHDs were being copied into the SR in the wrong order. Before the base-copy was copied first meaning it was possible for snapwatchd to see the base-copy before the dependent cow was present. It was treat the base_copy as an unreferenced parent, and GC it.
- Additional refactoring and cleanups.
Diffstat (limited to 'plugins')
| -rwxr-xr-x | plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 6 | ||||
| -rwxr-xr-x | plugins/xenserver/xenapi/etc/xapi.d/plugins/migration | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index 1a9ac37e9..950b78707 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -211,7 +211,11 @@ def _import_vhds(sr_path, staging_path, uuid_stack): snap_info = prepare_if_exists(staging_path, 'snap.vhd', image_info[0]) if snap_info: - paths_to_move.append(snap_info[0]) + # NOTE(sirp): this is an insert rather than an append since the + # 'snapshot' vhd needs to be copied into the SR before the base copy. + # If it doesn't, then there is a possibliity that snapwatchd will + # delete the base_copy since it is an unreferenced parent. + paths_to_move.insert(0, snap_info[0]) # We return this snap as the VDI instead of image.vhd vdi_return_list.append(dict(vdi_type="os", vdi_uuid=snap_info[1])) else: diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration index ac1c50ad9..4ec3dc7af 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration @@ -48,7 +48,7 @@ def move_vhds_into_sr(session, args): # Discover the copied VHDs locally, and then set up paths to copy # them to under the SR - source_image_path = "%s/instance%d" % ('/images/', instance_id) + source_image_path = "/images/instance%d" % instance_id source_base_copy_path = "%s/%s.vhd" % (source_image_path, old_base_copy_uuid) source_cow_path = "%s/%s.vhd" % (source_image_path, old_cow_uuid) @@ -74,9 +74,12 @@ def move_vhds_into_sr(session, args): (new_cow_path, new_base_copy_path)) subprocess.call(shlex.split('/usr/sbin/vhd-util modify -n %s -p %s' % (new_cow_path, new_base_copy_path))) + logging.debug('Moving VHDs into SR %s' % sr_path) - shutil.move("%s/%s.vhd" % (temp_vhd_path, new_base_copy_uuid), sr_path) - shutil.move("%s/%s.vhd" % (temp_vhd_path, new_cow_uuid), sr_path) + # NOTE(sirp): COW should be copied before base_copy to avoid snapwatchd + # GC'ing an unreferenced base copy VDI + shutil.move(new_cow_path, sr_path) + shutil.move(new_base_copy_path, sr_path) logging.debug('Cleaning up temporary SR path %s' % temp_vhd_path) os.rmdir(temp_vhd_path) @@ -93,7 +96,7 @@ def transfer_vhd(session, args): vhd_path = "%s.vhd" % vdi_uuid source_path = "%s/%s" % (sr_path, vhd_path) - dest_path = '%s:%sinstance%d/' % (host, '/images/', instance_id) + dest_path = '%s:/images/instance%d/' % (host, instance_id) logging.debug("Preparing to transmit %s to %s" % (source_path, dest_path)) |
