-
Notifications
You must be signed in to change notification settings - Fork 10
conductor: Cross-HV resize preflight checks #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: cross-hv-reqspec-early-commit
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,13 +15,15 @@ | |||||
|
|
||||||
| from nova import availability_zones | ||||||
| from nova.compute import utils as compute_utils | ||||||
| from nova.compute import power_state | ||||||
| from nova.conductor.tasks import base | ||||||
| from nova.conductor.tasks import cross_cell_migrate | ||||||
| from nova import exception | ||||||
| from nova.i18n import _ | ||||||
| from nova import objects | ||||||
| from nova.scheduler.client import report | ||||||
| from nova.scheduler import utils as scheduler_utils | ||||||
| from nova.scheduler.filters import extra_specs_ops | ||||||
|
|
||||||
| LOG = logging.getLogger(__name__) | ||||||
|
|
||||||
|
|
@@ -113,6 +115,7 @@ def revert_allocation_for_migration(context, source_cn, instance, migration): | |||||
|
|
||||||
|
|
||||||
| class MigrationTask(base.TaskBase): | ||||||
|
|
||||||
| def __init__(self, context, instance, flavor, | ||||||
| request_spec, clean_shutdown, compute_rpcapi, | ||||||
| query_client, report_client, host_list, network_api): | ||||||
|
|
@@ -283,6 +286,18 @@ def _execute(self): | |||||
| self.request_spec.ensure_network_information(self.instance) | ||||||
| compute_utils.heal_reqspec_is_bfv( | ||||||
| self.context, self.request_spec, self.instance) | ||||||
| # For cross-hypervisor resize (VMware to KVM), sanitize the image | ||||||
| # properties directly on the canonical request_spec so the scheduler | ||||||
| # can select KVM/CH hosts. The returned dict of original values is | ||||||
| # stashed for the conductor to persist into MigrationContext before | ||||||
| # request_spec.save(). | ||||||
| self._old_image_properties = {} | ||||||
| src_hv = self._source_cn.hypervisor_type | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could |
||||||
| dest_hv = self.flavor.extra_specs.get('capabilities:hypervisor_type') | ||||||
| if dest_hv and not extra_specs_ops.match(src_hv, dest_hv): | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no test where |
||||||
| LOG.debug('Cross-hypervisor resize detected') | ||||||
| self._prep_cross_hv_resize(src_hv, dest_hv) | ||||||
|
|
||||||
| # On an initial call to migrate, 'self.host_list' will be None, so we | ||||||
| # have to call the scheduler to get a list of acceptable hosts to | ||||||
| # migrate to. That list will consist of a selected host, along with | ||||||
|
|
@@ -338,6 +353,25 @@ def _execute(self): | |||||
| node=node, clean_shutdown=self.clean_shutdown, | ||||||
| host_list=self.host_list) | ||||||
|
|
||||||
| def _prep_cross_hv_resize(self, src_hv: str, dest_hv: str): | ||||||
| if extra_specs_ops.match("VMware vCenter Server", src_hv) \ | ||||||
| and extra_specs_ops.match("CH", dest_hv): | ||||||
| if not self.request_spec.is_bfv: | ||||||
| raise exception.InvalidCrossHvResizePrecondition( | ||||||
| 'Must be BFV instance') | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if self.instance.power_state != power_state.RUNNING: | ||||||
| raise exception.InvalidCrossHvResizePrecondition( | ||||||
| 'Instance must be running for cross-hypervisor resize. ' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 'The compute service will take care of stopping the instance.') | ||||||
|
|
||||||
| self._old_image_properties = ( | ||||||
| compute_utils.sanitize_image_props_for_kvm( | ||||||
| self.request_spec)) | ||||||
|
|
||||||
| else: | ||||||
| raise exception.InvalidCrossHvResize( | ||||||
| src_hv_type=src_hv, dest_hv_type=dest_hv) | ||||||
|
|
||||||
| def _schedule(self): | ||||||
| selection_lists = self.query_client.select_destinations( | ||||||
| self.context, self.request_spec, [self.instance.uuid], | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2547,3 +2547,11 @@ class VolumeMigrationError(NovaException): | |||||||
| class InvalidGuestCpuNumaConfig(NovaException): | ||||||||
| msg_fmt = _('The guest is configured with a cell with id %(cell_id)s ' | ||||||||
| 'which the host does not provide.') | ||||||||
|
|
||||||||
|
|
||||||||
| class InvalidCrossHvResize(NovaException): | ||||||||
| msg_fmt = _('Resize from hypervisor type %(src_hv_type)s to ' | ||||||||
| '%(dest_hv_type)s is not allowed') | ||||||||
|
|
||||||||
| class InvalidCrossHvResizePrecondition(NovaException): | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
to make PEP8 happy I guess. |
||||||||
| msg_fmt = _('Cross-hypervisor resize precondition not met: %(reason)s') | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a test for this branch would also be nice: Verify the instance state is properly restored (not set to ERROR) when the exception fires and resets to the ACTIVE fallback.