Class: Bosh::Director::DeploymentPlan::CompilationInstancePool
- Defined in:
- lib/bosh/director/deployment_plan/compilation_instance_pool.rb
Instance Method Summary collapse
- #delete_instances(number_of_workers) ⇒ Object
-
#initialize(instance_reuser, vm_creator, deployment_plan, logger, instance_deleter, max_instance_count) ⇒ CompilationInstancePool
constructor
A new instance of CompilationInstancePool.
- #with_reused_vm(stemcell) ⇒ Object
- #with_single_use_vm(stemcell) ⇒ Object
Constructor Details
#initialize(instance_reuser, vm_creator, deployment_plan, logger, instance_deleter, max_instance_count) ⇒ CompilationInstancePool
Returns a new instance of CompilationInstancePool.
4 5 6 7 8 9 10 11 |
# File 'lib/bosh/director/deployment_plan/compilation_instance_pool.rb', line 4 def initialize(instance_reuser, vm_creator, deployment_plan, logger, instance_deleter, max_instance_count) @instance_reuser = instance_reuser @logger = logger @instance_deleter = instance_deleter @max_instance_count = max_instance_count @instance_provider = InstanceProvider.new(deployment_plan, vm_creator, logger) @mutex = Mutex.new end |
Instance Method Details
#delete_instances(number_of_workers) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bosh/director/deployment_plan/compilation_instance_pool.rb', line 47 def delete_instances(number_of_workers) ThreadPool.new(:max_threads => number_of_workers).wrap do |pool| @instance_reuser.each do |instance_memo| pool.process do @instance_reuser.remove_instance(instance_memo) instance_plan = DeploymentPlan::InstancePlan.new( existing_instance: instance_memo.instance.model, instance: instance_memo.instance, desired_instance: DeploymentPlan::DesiredInstance.new, network_plans: [] ) destroy_instance(instance_plan) end end end end |
#with_reused_vm(stemcell) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bosh/director/deployment_plan/compilation_instance_pool.rb', line 13 def with_reused_vm(stemcell) begin instance_memo = obtain_instance_memo(stemcell) yield instance_memo.instance release_instance(instance_memo) rescue => e remove_instance(instance_memo) unless instance_memo.instance_plan.nil? if Config.keep_unreachable_vms @logger.info('Keeping reused compilation VM for debugging') else destroy_instance(instance_memo.instance_plan) end end raise e end end |
#with_single_use_vm(stemcell) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bosh/director/deployment_plan/compilation_instance_pool.rb', line 31 def with_single_use_vm(stemcell) begin keep_failing_vm = false instance_memo = InstanceMemo.new(@instance_provider, stemcell) yield instance_memo.instance rescue => e @logger.info('Keeping single-use compilation VM for debugging') keep_failing_vm = Config.keep_unreachable_vms raise e ensure unless instance_memo.instance.nil? || keep_failing_vm destroy_instance(instance_memo.instance_plan) end end end |