Class: Bosh::Director::InstanceUpdater::Preparer

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/instance_updater/preparer.rb

Instance Method Summary collapse

Constructor Details

#initialize(instance_plan, agent_client, logger) ⇒ Preparer

Returns a new instance of Preparer.



3
4
5
6
7
# File 'lib/bosh/director/instance_updater/preparer.rb', line 3

def initialize(instance_plan, agent_client, logger)
  @instance_plan = instance_plan
  @agent_client = agent_client
  @logger = logger
end

Instance Method Details

#prepareObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bosh/director/instance_updater/preparer.rb', line 9

def prepare
  instance = @instance_plan.instance
  # If resource pool has changed or instance will be recreated/detached
  # there is no point in preparing current VM for future since it will be destroyed.
  unless @instance_plan.needs_shutting_down? || instance.state == 'detached'

    apply_spec = DeploymentPlan::InstanceSpec.create_from_instance_plan(@instance_plan).as_apply_spec
    @agent_client.prepare(apply_spec)
  end
rescue RpcRemoteException => e
  if e.message =~ /unknown message/
    # It's ok if agent does not support prepare optimization
    @logger.warn("Ignoring prepare 'unknown message' error from the agent: #{e.inspect}")
  else
    # Prepare is really an optimization to a deployment process.
    # It should not prevent deploy from continuing on and trying to actually finish an update.
    @logger.warn("Ignoring prepare error from the agent: #{e.inspect}")
  end
end