13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/bosh/director/job_updater.rb', line 13
def update
@logger.info("Deleting no longer needed instances")
delete_unneeded_instances
instances = []
@job.instances.each do |instance|
instances << instance if instance.changed?
end
if instances.empty?
@logger.info("No instances to update for `#{@job.name}'")
return
end
@logger.info("Found #{instances.size} instances to update")
event_log_stage = @event_log.begin_stage("Updating job", instances.size, [ @job.name ])
ThreadPool.new(:max_threads => @job.update.max_in_flight).wrap do |pool|
num_canaries = [ @job.update.canaries, instances.size ].min
@logger.info("Starting canary update num_canaries=#{num_canaries}")
update_canaries(pool, instances, num_canaries, event_log_stage)
@logger.info("Waiting for canaries to update")
pool.wait
@logger.info("Finished canary update")
if @job.should_halt?
@logger.warn("Halting deployment due to a canary failure")
halt
end
@logger.info("Continuing the rest of the update")
update_instances(pool, instances, event_log_stage)
end
@logger.info("Finished the rest of the update")
if @job.should_halt?
@logger.warn("Halting deployment due to an update failure")
halt
end
end
|