lib/dcmgr/node_modules/instance_ha.rb in wakame-vdc-dcmgr-11.06.0 vs lib/dcmgr/node_modules/instance_ha.rb in wakame-vdc-dcmgr-11.12.0

- old
+ new

@@ -3,11 +3,11 @@ module Dcmgr module NodeModules class InstanceHA < Isono::NodeModules::Base include Dcmgr::Logger - + initialize_hook do @thread_pool = Isono::ThreadPool.new(1, 'InstanceHA') event = Isono::NodeModules::EventChannel.new(node) event.subscribe('hva/fault_instance', '#') { |args| @thread_pool.pass { @@ -24,34 +24,45 @@ @thread_pool.shutdown end def restart_instance(inst) # terminate and cleanup + + # set boot_vol before instance is cleaned up. + case inst.image.boot_dev_type + when Models::Image::BOOT_DEV_SAN + boot_vol = inst.volume.find {|v| v.boot_dev == 1 } + end + begin - jobrpc.run("kvm-handle.#{inst.host_pool.node_id}", 'cleanup', inst.canonical_uuid) + jobrpc.run("hva-handle.#{inst.host_node.node_id}", 'cleanup', inst.canonical_uuid) rescue => e # termination may fail end - + # TODO: pick a new host node Isono::NodeModules::DataStore.barrier { inst.state = :failingover inst.save } # start a new backup instance - case inst.image.boot_dev_type - when Models::Image::BOOT_DEV_SAN - boot_vol = inst.volume.find {|v| v.boot_dev == 1 } - res = jobrpc.submit("kvm-handle.#{inst.host_pool.node_id}", 'run_vol_store', inst.canonical_uuid, boot_vol.canonical_uuid) - when Models::Image::BOOT_DEV_LOCAL - res = jobrpc.submit("kvm-handle.#{inst.host_pool.node_id}", 'run_local_store', inst.canonical_uuid) - else - raise "Unknown boot type" + begin + case inst.image.boot_dev_type + when Models::Image::BOOT_DEV_SAN + jobrpc.submit("scheduler", 'schedule_instance_ha', inst.canonical_uuid, boot_vol) + when Models::Image::BOOT_DEV_LOCAL + jobrpc.submit("scheduler", 'schedule_instance_ha', inst.canonical_uuid, nil) + else + raise "Unknown boot type" + end + rescue => e + # termination may fail end + logger.info("#{inst.canonical_uuid} has been restarted") end - + private def event @event ||= Isono::NodeModules::EventChannel.new(node) end