设为首页 收藏本站
查看: 1626|回复: 0

[经验分享] OpenStack nova VM migration (live and cold) call flow

[复制链接]

尚未签到

发表于 2015-4-11 16:19:48 | 显示全部楼层 |阅读模式
  OpenStack nova compute supports two flavors of Virtual Machine (VM) migration:


  • Cold migration -- migration of a VM which requires the VM to be powered off during the migrate operation during which time the VM is inaccessible.
  • Hot or live migration -- zero down-time migration whereupon the VM is not powered off during the migration and thus remains accessible.
  
Understanding these VM migration operations from an OpenStack internals perspective can be a daunting task. I had the pleasure of digging into these flows in the latter part of 2013 and as part of that effort created a rough outline of the internal flows. Other's I've worked with found these flow outlines useful and thus they're provided below.

Note -- The outlines below were created based on the OpenStack source in late 2013 and thus reflect the state of OpenStack at that point in time.




Live Migration Flow:

  • nova.api.openstack.compute.contrib.admin_actions._migrate_live()
  • nova.compute.api.live_migrate()

    • update instance state to MIGRATING state
    • call into scheduler to live migrate (scheduler hint will be set to the host select (which may be none)).

  • nova.scheduler.manager.live_migration()
  • nova.scheduler.manager._schedule_live_migration()
  • nova.conductor.tasks.live_migrate.LiveMigrationTask.execute()

    • check that the instance is running
    • check that the instance's host is up
    • if destination host provided, check that it..

      • is different than the instance's host
      • is up
      • has enough memory
      • is compatible with the instance's host (i.e. hypervisor type and version)
      • passes live migration checks (call using amqp rpc into nova manager check_can_live_migrate_destination)

    • else destination host not provided, find a candidate destination host and check that it...

      • is compatible with the instance's host (i.e. hypervisor type and version)
      • passes live migration checks (call using amqp rpc into nova manager check_can_live_migrate_destination)

    • call using amqp rpc into nova manager live_migration
      Note: Migration data is initially set by check_can_live_migrate_destination and can be used for implementation specific parameters from this point.

  • nova.compute.manager.check_can_live_migrate_destination()

    • driver.check_can_live_migrate_destination()
    • call using amqp rpc into nova manager check_can_live_migrate_source
    • driver.check_can_live_migrate_destination_cleanup()

  • nova.compute.manager.check_can_live_migrate_source()

    • determine if the instance is volume backed and add result to the migration data
    • driver.check_can_live_migrate_source()

  • nova.compute.manager.live_migration()

    • if block migration request then driver.get_instance_disk_info()
    • call using amqp rpc into nova manager pre_live_migration

      • Error handler: _rollback_live_migration

    • driver.live_migration()

  • nova.compute.manager.pre_live_migration()

    • get the block device information for the instance
    • get the network information for the instance
    • driver.pre_live_migration()
    • setup networks on destination host by calling the network API setup_networks_on_host
    • driver.ensure_filtering_rules_for_instance()

  • nova.compute.manager._rollback_live_migration()

    • update instance state to ACTIVE state
    • re-setup networks on source host by calling the network API setup_networks_on_host
    • for each instance volume connection call using amqp rpc into nova manager remove_volume_connection
    • if block migration or volume backed migration without shared storage

      • call using amqp rpc into nova manager rollback_live_migration_at_destination


  • nova.compute.manager._post_live_migration()

    • driver.get_volume_connector()
    • for each instance volume connection call the volume API terminate_connection
    • driver.unfilter_instance()
    • call into conductor to network_migrate_instance_start which will eventually call the network API migrate_instance_start
    • call using amqp rpc into nova manager post_live_migration_at_destination
    • if block migration or not shared storage driver.destroy()
    • else driver.unplug_vifs()
    • tear down networks on source host by calling the network API setup_networks_on_host

  • nova.compute.manager.post_live_migration_at_destination()

    • setup networks on destination host by calling the network API setup_networks_on_host
    • call into conductor to network_migrate_instance_finish which will eventually call the network API migrate_instance_finish
    • driver.post_live_migration_at_destination()
    • update instance to ACTIVE state
    • setup networks on destination host by calling the network API setup_networks_on_host

  • nova.compute.manager.rollback_live_migration_at_destination()

    • tear down networks on destination host by calling the network API setup_networks_on_host
    • driver.destroy()

  • nova.compute.manager.remove_volume_connection()

    • call _detach_volume
    • driver.get_volume_connector()
    • remove the volume connection by calling the volume API terminate_connection

  • nova.compute.manager._detach_volume()

    • driver.detach_volume()

      • Since the live migration failed the VM should not be on the destination host.  So this should be a no-op.

    • If there is an exception detaching the volume then rollback the detach by calling the volume API roll_detaching



Cold Migration Flow:

  • nova.api.openstack.compute.servers._resize()
  • nova.api.openstack.compute.contrib.admin_actions._migrate()
  • nova.compute.api.resize()

    • if flavor_id is not passed, migrate host only and keep the original flavor
    • else flavor_id is given, migrate host and resize to new flavor
    • lookup the image for the instance by calling the image API show
    • check quota headroom and reserve
    • update instance to RESIZE_PREP state
    • determine if the instance's current host should be ignored as a migration target and update filter properties for the scheduler accordingly
    • call into scheduler to prep_resize

  • nova.scheduler.manager.prep_resize()

    • call scheduler driver to schedule_prep_resize
    • if no valid host was found then update instance to ACTIVE state and rollback quota reservation
    • if error occurred then update instance to ERROR state and rollback quota reservation

  • nova.scheduler.filter_scheduler.schedule_prep_resize()

    • run through scheduler filters to select host
    • call using amqp rpc into nova manager prep_resize

  • nova.compute.manager.prep_resize()

    • if no node specified call driver.get_available_nodes()
    • call _prep_resize

      • if an exception occurs then call into scheduler to prep_resize again if possible


  • nova.compute.manager._prep_resize()

    • if same host is used then ensure that the same host is allowed (as per configuration)
    • call using amqp rpc into nova manager resize_instance

  • nova.compute.manager.resize_instance()

    • get network and instance information
    • update instance to RESIZE_MIGRATING state
    • get block device information
    • call driver.migrate_disk_and_power_off()
    • call _terminate_volume_connections
    • call into conductor to network_migrate_instance_start which will eventually call the network API migrate_instance_start
    • update instance to RESIZE_MIGRATED state
    • call using amqp rpc into nova manager finish_resize

  • nova.compute.manager._terminate_volume_connections()

    • if there is a volume connection to terminate

      • driver.get_volume_connector()
      • for each volume connection remove the connection by calling the volume API terminate_connection


  • nova.compute.manager.finish_resize()

    • call _finish_resize
    • if successful commit the quota reservation
    • else rollback the quota reservation and update instance to ERROR state

  • nova.compute.manager._finish_resize()

    • if the flavor is changing then update the instance with the new flavor
    • setup networks on destination host by calling the network API setup_networks_on_host
    • call into conductor to network_migrate_instance_finish which will eventually call the network API migrate_instance_finish
    • update instance to RESIZE_FINISHED state
    • refresh and get block device information
    • driver.finish_migration()
    • update instance to RESIZED state


Cold migration confirm flow:

  • nova.api.openstack.compute.servers._action_confirm_resize()
  • nova.compute.api.confirm_resize()

    • reserve quota for decrease in resource usage
    • call amqp rpc into nova manager confirm_resize

  • nova.compute.manager.confirm_resize()

    • tear down networks on source host by calling the network API setup_networks_on_host
    • driver.confirm_migration()
    • update instance to ACTIVE (or possibly STOPPED) state
    • commit the quota reservation


Cold migration revert flow:


    • nova.api.openstack.compute.servers._action_revert_resize()
    • nova.compute.api.revert_resize()

      • reserve quota for increase in resource usage
      • update instance task state to RESIZE_REVERTING
      • call amqp rpc into nova manager revert_resize

    • nova.compute.manager.revert_resize()

      • tear down networks on destination host by calling the network API setup_networks_on_host
      • call into conductor to network_migrate_instance_start which will eventually call the network API migrate_instance_start
      • get block device information
      • driver.destroy()
      • call _terminate_volume_connections
      • drop resize resources claimed on destination
      • call amqp rpc into nova manager finish_revert_resize

    • nova.compute.manager.finish_revert_resize()

      • update instance back to pre-resize values
      • re-setup networks on source host by calling the network API setup_networks_on_host
      • refresh and get block device information
      • driver.finish_revert_migration()
      • update instance to RESIZE_REVERTING state
      • call into conductor to network_migrate_instance_finish which will eventually call the network API migrate_instance_finish
      • update instance to ACTIVE (or possibly STOPPED) state
      • commit the quota usage


  Source: http://bodenr.blogspot.com/2014/03/openstack-nova-vm-migration-live-and.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-56081-1-1.html 上篇帖子: 探索 OpenStack 之(12):cinder-api Service 处理 HTTP Request 的过程分析 下篇帖子: openstack horizon api step by step
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表