您的位置:首页 > 其它

nova instance启动中的同步与异步

2016-01-07 09:33 218 查看

instance create:
nova/api/servers.create -- self.compute_api.create -- self.compute_task_api.build_instances
-- self.conductor_compute_rpcapi.build_instances(conductorp/api.py) --  cctxt.cast(context, 'build_instances', **kw)
从nova api到conductor的调用为异步
conductor manager 里面:
1. hosts = self._schedule_instances:
-- self.scheduler_client.select_destinations -- self.scheduler_rpcapi.select_destinations -- cctxt.call(ctxt, 'select_destinations'
从conductor调用select_destinations到scheduler采用同步

所以,当FilterScheduler有异常:

            reason = _('There are not enough hosts available.')
            raise exception.NoValidHost(reason=reason)

scheduler manager 中利用@messaging.expected_exceptions(exception.NoValidHost)

把该异常传回给conductor,conductor在这里捕获该异常并把状态设置为ERROR:

except Exception as exc:
updates = {'vm_state': vm_states.ERROR, 'task_state': None}
for instance in instances:
self._set_vm_state_and_notify(
context, instance.uuid, 'build_instances', updates,
exc, request_spec)
return

出错为:

nova.scheduler.utils [^[[01;36mreq-7ceeb23a-1d2e-401b-bbb7-2d8058715e82 ^[[00;36madmin admin^[[01;33m] ^[[01;35m^[[01;33mFailed to compute_task_build_instances: No valid host was found. There are not enough hosts available.
Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py", line 150, in inner
return func(*args, **kwargs)

File "/opt/stack/nova/nova/scheduler/manager.py", line 71, in select_destinations
filter_properties)

File "/opt/stack/nova/nova/scheduler/filter_scheduler.py", line 81, in select_destinations
raise exception.NoValidHost(reason=reason)

NoValidHost: No valid host was found. There are not enough hosts available.
^[[00m
2016-01-07 02:26:32.496 ^[[01;33mWARNING nova.scheduler.utils [^[[01;36mreq-7ceeb23a-1d2e-401b-bbb7-2d8058715e82 ^[[00;36madmin admin^[[01;33m] ^[[01;35m[instance: 47b93a3e-b7d1-428f-9b7c-edd80c0735db] ^[[01;33mSetting instance to ERROR state.^[[00m

2. self.compute_rpcapi.build_and_run_instance:
cctxt.cast(ctxt, 'build_and_run_instance -- utils.spawn_n -- eventlet.spawn_n
从conductor调用到compute为异步调用

 

其他:

conductor/rpcapi/ComputeTaskAPI中,对conductor的远程调用

migrate_server为同步

其他build_instances/unshelve_instance/rebuild_instance均为异步

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: