bosh-director 1.2941.0 → 1.2949.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2941.0
4
+ version: 1.2949.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-21 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt-ruby
@@ -30,126 +30,126 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2941.0
33
+ version: 1.2949.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2941.0
40
+ version: 1.2949.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bosh-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2941.0
47
+ version: 1.2949.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2941.0
54
+ version: 1.2949.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bosh-director-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2941.0
61
+ version: 1.2949.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2941.0
68
+ version: 1.2949.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bosh_common
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.2941.0
75
+ version: 1.2949.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.2941.0
82
+ version: 1.2949.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bosh-template
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.2941.0
89
+ version: 1.2949.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.2941.0
96
+ version: 1.2949.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bosh_cpi
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.2941.0
103
+ version: 1.2949.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.2941.0
110
+ version: 1.2949.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bosh_openstack_cpi
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2941.0
117
+ version: 1.2949.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.2941.0
124
+ version: 1.2949.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bosh_aws_cpi
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.2941.0
131
+ version: 1.2949.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.2941.0
138
+ version: 1.2949.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: bosh_vsphere_cpi
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.2941.0
145
+ version: 1.2949.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.2941.0
152
+ version: 1.2949.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: bosh_vcloud_cpi
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -558,7 +558,7 @@ dependencies:
558
558
  version: '0'
559
559
  description: |-
560
560
  BOSH Director
561
- 8ac133
561
+ 46bdbc
562
562
  email: support@cloudfoundry.com
563
563
  executables:
564
564
  - bosh-director
@@ -698,14 +698,15 @@ files:
698
698
  - lib/bosh/director/deployment_plan/network_subnet.rb
699
699
  - lib/bosh/director/deployment_plan/notifier.rb
700
700
  - lib/bosh/director/deployment_plan/planner.rb
701
- - lib/bosh/director/deployment_plan/preparer.rb
702
701
  - lib/bosh/director/deployment_plan/release_version.rb
703
702
  - lib/bosh/director/deployment_plan/resource_pool.rb
704
703
  - lib/bosh/director/deployment_plan/resource_pools.rb
705
704
  - lib/bosh/director/deployment_plan/stemcell.rb
705
+ - lib/bosh/director/deployment_plan/steps/package_compile_step.rb
706
+ - lib/bosh/director/deployment_plan/steps/prepare_step.rb
707
+ - lib/bosh/director/deployment_plan/steps/update_step.rb
706
708
  - lib/bosh/director/deployment_plan/template.rb
707
709
  - lib/bosh/director/deployment_plan/update_config.rb
708
- - lib/bosh/director/deployment_plan/updater.rb
709
710
  - lib/bosh/director/deployment_plan/vip_network.rb
710
711
  - lib/bosh/director/deployment_plan/vm.rb
711
712
  - lib/bosh/director/dns_helper.rb
@@ -786,7 +787,6 @@ files:
786
787
  - lib/bosh/director/models/vm.rb
787
788
  - lib/bosh/director/nats_rpc.rb
788
789
  - lib/bosh/director/network_reservation.rb
789
- - lib/bosh/director/package_compiler.rb
790
790
  - lib/bosh/director/problem_handlers/base.rb
791
791
  - lib/bosh/director/problem_handlers/inactive_disk.rb
792
792
  - lib/bosh/director/problem_handlers/invalid_problem.rb
@@ -1,54 +0,0 @@
1
- module Bosh::Director
2
- module DeploymentPlan
3
- class Preparer
4
- def initialize(job, assembler)
5
- @job = job
6
- @assembler = assembler
7
- end
8
-
9
- def prepare
10
- job.begin_stage('Preparing deployment', 9)
11
-
12
- job.track_and_log('Binding deployment') do
13
- @assembler.bind_deployment
14
- end
15
-
16
- job.track_and_log('Binding releases') do
17
- @assembler.bind_releases
18
- end
19
-
20
- job.track_and_log('Binding existing deployment') do
21
- @assembler.bind_existing_deployment
22
- end
23
-
24
- job.track_and_log('Binding resource pools') do
25
- @assembler.bind_resource_pools
26
- end
27
-
28
- job.track_and_log('Binding stemcells') do
29
- @assembler.bind_stemcells
30
- end
31
-
32
- job.track_and_log('Binding templates') do
33
- @assembler.bind_templates
34
- end
35
-
36
- job.track_and_log('Binding properties') do
37
- @assembler.bind_properties
38
- end
39
-
40
- job.track_and_log('Binding unallocated VMs') do
41
- @assembler.bind_unallocated_vms
42
- end
43
-
44
- job.track_and_log('Binding instance networks') do
45
- @assembler.bind_instance_networks
46
- end
47
- end
48
-
49
- private
50
-
51
- attr_reader :job
52
- end
53
- end
54
- end
@@ -1,50 +0,0 @@
1
- module Bosh::Director
2
- module DeploymentPlan
3
- class Updater
4
- def initialize(base_job, event_log, resource_pools, assembler, deployment_plan, multi_job_updater)
5
- @base_job = base_job
6
- @logger = base_job.logger
7
- @event_log = event_log
8
- @resource_pools = resource_pools
9
- @assembler = assembler
10
- @deployment_plan = deployment_plan
11
- @multi_job_updater = multi_job_updater
12
- end
13
-
14
- def update
15
- @event_log.begin_stage('Preparing DNS', 1)
16
- @base_job.track_and_log('Binding DNS') do
17
- @assembler.bind_dns
18
- end
19
-
20
- @logger.info('Deleting no longer needed VMs')
21
- @assembler.delete_unneeded_vms
22
-
23
- @logger.info('Deleting no longer needed instances')
24
- @assembler.delete_unneeded_instances
25
-
26
- @logger.info('Updating resource pools')
27
- @resource_pools.update
28
- @base_job.task_checkpoint
29
-
30
- @logger.info('Binding instance VMs')
31
- @assembler.bind_instance_vms
32
-
33
- @event_log.begin_stage('Preparing configuration', 1)
34
- @base_job.track_and_log('Binding configuration') do
35
- @assembler.bind_configuration
36
- end
37
-
38
- @logger.info('Updating jobs')
39
- @multi_job_updater.run(
40
- @base_job,
41
- @deployment_plan,
42
- @deployment_plan.jobs_starting_on_deploy,
43
- )
44
-
45
- @logger.info('Refilling resource pools')
46
- @resource_pools.refill
47
- end
48
- end
49
- end
50
- end
@@ -1,339 +0,0 @@
1
- require 'bosh/director/compile_task_generator'
2
-
3
- module Bosh::Director
4
- class PackageCompiler
5
- include LockHelper
6
-
7
- attr_reader :compilations_performed
8
-
9
- # @param [DeploymentPlan] deployment_plan Deployment plan
10
- def initialize(deployment_plan)
11
- @deployment_plan = deployment_plan
12
-
13
- @cloud = Config.cloud
14
- @event_log = Config.event_log
15
- @logger = Config.logger
16
- @director_job = Config.current_job
17
-
18
- @tasks_mutex = Mutex.new
19
- @network_mutex = Mutex.new
20
- @counter_mutex = Mutex.new
21
-
22
- compilation_config = @deployment_plan.compilation
23
-
24
- @network = compilation_config.network
25
- @compilation_resources = compilation_config.cloud_properties
26
- @compilation_env = compilation_config.env
27
-
28
- @vm_reuser = VmReuser.new
29
-
30
- @compile_task_generator = CompileTaskGenerator.new(@logger, @event_log)
31
-
32
- @compile_tasks = {}
33
- @ready_tasks = []
34
- @compilations_performed = 0
35
- end
36
-
37
- # @return [Integer] How many compile tasks are present
38
- def compile_tasks_count
39
- @compile_tasks.size
40
- end
41
-
42
- # @return [Integer] How many compile tasks are ready
43
- def ready_tasks_count
44
- @tasks_mutex.synchronize { @ready_tasks.size }
45
- end
46
-
47
- # Generates compilation tasks for all packages in all job templates included
48
- # in the current deployment and kicks off compilation.
49
- # @return [void]
50
- def compile
51
- @logger.info('Generating a list of compile tasks')
52
- prepare_tasks
53
-
54
- @compile_tasks.each_value do |task|
55
- if task.ready_to_compile?
56
- @logger.info("Package `#{task.package.desc}' is ready to be compiled for stemcell `#{task.stemcell.desc}'")
57
- @ready_tasks << task
58
- end
59
- end
60
-
61
- if @ready_tasks.empty?
62
- @logger.info('All packages are already compiled')
63
- else
64
- compile_packages
65
- director_job_checkpoint
66
- end
67
- end
68
-
69
- def compile_package(task)
70
- package = task.package
71
- stemcell = task.stemcell
72
-
73
- with_compile_lock(package.id, stemcell.id) do
74
- # Check if the package was compiled in a parallel deployment
75
- compiled_package = task.find_compiled_package(@logger, @event_log)
76
- if compiled_package.nil?
77
- build = Models::CompiledPackage.generate_build_number(package, stemcell)
78
- task_result = nil
79
-
80
- prepare_vm(stemcell) do |vm_data|
81
- vm_metadata_updater.update(vm_data.vm, :compiling => package.name)
82
- agent_task =
83
- vm_data.agent.compile_package(package.blobstore_id,
84
- package.sha1, package.name,
85
- "#{package.version}.#{build}",
86
- task.dependency_spec)
87
- task_result = agent_task['result']
88
- end
89
-
90
- compiled_package = Models::CompiledPackage.create do |p|
91
- p.package = package
92
- p.stemcell = stemcell
93
- p.sha1 = task_result['sha1']
94
- p.build = build
95
- p.blobstore_id = task_result['blobstore_id']
96
- p.dependency_key = task.dependency_key
97
- end
98
-
99
- if Config.use_compiled_package_cache?
100
- if BlobUtil.exists_in_global_cache?(package, task.cache_key)
101
- @logger.info('Already exists in global package cache, skipping upload')
102
- else
103
- @logger.info('Uploading to global package cache')
104
- BlobUtil.save_to_global_cache(compiled_package, task.cache_key)
105
- end
106
- else
107
- @logger.info('Global blobstore not configured, skipping upload')
108
- end
109
-
110
- @counter_mutex.synchronize { @compilations_performed += 1 }
111
- end
112
-
113
- task.use_compiled_package(compiled_package)
114
- end
115
- end
116
-
117
- # This method will create a VM for each stemcell in the stemcells array
118
- # passed in. The VMs are yielded and their destruction is ensured.
119
- # @param [Models::Stemcell] stemcell The stemcells that need to have
120
- # compilation VMs created.
121
- # @yield [VmData] Yields a VmData object that contains all the data for the
122
- # VM that should be used for compilation. This may be a reused VM or a
123
- # freshly created VM.
124
- def prepare_vm(stemcell)
125
- # If we're reusing VMs, try to just return an already-created VM.
126
- if @deployment_plan.compilation.reuse_compilation_vms
127
- vm_data = @vm_reuser.get_vm(stemcell)
128
- if vm_data
129
- @logger.info("Reusing compilation VM `#{vm_data.vm.cid}' for stemcell `#{stemcell.desc}'")
130
- begin
131
- yield vm_data
132
- ensure
133
- vm_data.release
134
- end
135
- return
136
- end
137
- # This shouldn't happen. If it does there's a bug.
138
- if @vm_reuser.get_num_vms(stemcell) >=
139
- @deployment_plan.compilation.workers
140
- raise PackageCompilationNotEnoughWorkersForReuse,
141
- 'There should never be more VMs for a stemcell than the number of workers in reuse_compilation_vms mode'
142
- end
143
- end
144
-
145
- @logger.info("Creating compilation VM for stemcell `#{stemcell.desc}'")
146
-
147
- reservation = reserve_network
148
-
149
- network_settings = {
150
- @network.name => @network.network_settings(reservation)
151
- }
152
-
153
- vm = VmCreator.create(@deployment_plan.model, stemcell,
154
- @compilation_resources, network_settings,
155
- nil, @compilation_env)
156
- vm_data = @vm_reuser.add_vm(reservation, vm, stemcell, network_settings)
157
-
158
- @logger.info("Configuring compilation VM: #{vm.cid}")
159
-
160
- begin
161
- agent = AgentClient.with_defaults(vm.agent_id)
162
- agent.wait_until_ready
163
-
164
- configure_vm(vm, agent, network_settings)
165
- vm_data.agent = agent
166
- yield vm_data
167
- rescue RpcTimeout => e
168
- # if we time out waiting for the agent, we should clean up the the VM
169
- # as it will leave us in an unrecoverable state otherwise
170
- @vm_reuser.remove_vm(vm_data)
171
- tear_down_vm(vm_data)
172
- raise e
173
- ensure
174
- vm_data.release
175
- unless @deployment_plan.compilation.reuse_compilation_vms
176
- tear_down_vm(vm_data)
177
- end
178
- end
179
- end
180
-
181
- private
182
-
183
- def prepare_tasks
184
- @event_log.begin_stage('Preparing package compilation', 1)
185
-
186
- @event_log.track('Finding packages to compile') do
187
- @deployment_plan.jobs.each do |job|
188
- stemcell = job.resource_pool.stemcell
189
-
190
- template_descs = job.templates.map do |t|
191
- # we purposefully did NOT inline those because
192
- # when instance_double blows up,
193
- # it's obscure which double is at fault
194
- release_name = t.release.name
195
- template_name = t.name
196
- "`#{release_name}/#{template_name}'"
197
- end
198
- @logger.info("Job templates #{template_descs.join(', ')} need to run on stemcell `#{stemcell.model.desc}'")
199
-
200
- job.templates.each do |template|
201
- template.package_models.each do |package|
202
- @compile_task_generator.generate!(@compile_tasks, job, template, package, stemcell.model)
203
- end
204
- end
205
- end
206
- end
207
- end
208
-
209
- def tear_down_vm(vm_data)
210
- vm = vm_data.vm
211
- if vm.exists?
212
- reservation = vm_data.reservation
213
- @logger.info("Deleting compilation VM: #{vm.cid}")
214
- @cloud.delete_vm(vm.cid)
215
- vm.destroy
216
- release_network(reservation)
217
- end
218
- end
219
-
220
- def reserve_network
221
- reservation = NetworkReservation.new_dynamic
222
-
223
- @network_mutex.synchronize do
224
- @network.reserve(reservation)
225
- end
226
-
227
- unless reservation.reserved?
228
- raise PackageCompilationNetworkNotReserved,
229
- "Could not reserve network for package compilation: #{reservation.error}"
230
- end
231
-
232
- reservation
233
- end
234
-
235
- def release_network(reservation)
236
- @network_mutex.synchronize do
237
- @network.release(reservation)
238
- end
239
- end
240
-
241
- def compile_packages
242
- @event_log.begin_stage('Compiling packages', compilation_count)
243
- number_of_workers = @deployment_plan.compilation.workers
244
-
245
- begin
246
- ThreadPool.new(:max_threads => number_of_workers).wrap do |pool|
247
- loop do
248
- # process as many tasks without waiting
249
- loop do
250
- break if director_job_cancelled?
251
- task = @tasks_mutex.synchronize { @ready_tasks.pop }
252
- break if task.nil?
253
-
254
- pool.process { process_task(task) }
255
- end
256
-
257
- break if !pool.working? && (director_job_cancelled? || @ready_tasks.empty?)
258
- sleep(0.1)
259
- end
260
- end
261
- ensure
262
- # Delete all of the VMs if we were reusing compilation VMs. This can't
263
- # happen until everything was done compiling.
264
- if @deployment_plan.compilation.reuse_compilation_vms
265
- # Using a new ThreadPool instead of reusing the previous one,
266
- # as if there's a failed compilation, the thread pool will stop
267
- # processing any new thread.
268
- ThreadPool.new(:max_threads => number_of_workers).wrap do |pool|
269
- @vm_reuser.each do |vm_data|
270
- pool.process { tear_down_vm(vm_data) }
271
- end
272
- end
273
- end
274
- end
275
- end
276
-
277
- def enqueue_unblocked_tasks(task)
278
- @tasks_mutex.synchronize do
279
- @logger.info("Unblocking dependents of `#{task.package.desc}` for `#{task.stemcell.desc}`")
280
- task.dependent_tasks.each do |dep_task|
281
- if dep_task.ready_to_compile?
282
- @logger.info("Package `#{dep_task.package.desc}' now ready to be compiled for `#{dep_task.stemcell.desc}'")
283
- @ready_tasks << dep_task
284
- end
285
- end
286
- end
287
- end
288
-
289
- def process_task(task)
290
- package_desc = task.package.desc
291
- stemcell_desc = task.stemcell.desc
292
- task_desc = "package `#{package_desc}' for stemcell `#{stemcell_desc}'"
293
-
294
- with_thread_name("compile_package(#{package_desc}, #{stemcell_desc})") do
295
- if director_job_cancelled?
296
- @logger.info("Cancelled compiling #{task_desc}")
297
- else
298
- @event_log.track(package_desc) do
299
- @logger.info("Compiling #{task_desc}")
300
- compile_package(task)
301
- @logger.info("Finished compiling #{task_desc}")
302
- enqueue_unblocked_tasks(task)
303
- end
304
- end
305
- end
306
- end
307
-
308
- def director_job_cancelled?
309
- @director_job && @director_job.task_cancelled?
310
- end
311
-
312
- def director_job_checkpoint
313
- @director_job.task_checkpoint if @director_job
314
- end
315
-
316
- def configure_vm(vm, agent, network_settings)
317
- state = {
318
- 'deployment' => @deployment_plan.name,
319
- 'resource_pool' => 'package_compiler',
320
- 'networks' => network_settings
321
- }
322
-
323
- vm.update(:apply_spec => state)
324
- agent.apply(state)
325
- end
326
-
327
- def compilation_count
328
- counter = 0
329
- @compile_tasks.each_value do |task|
330
- counter += 1 unless task.compiled?
331
- end
332
- counter
333
- end
334
-
335
- def vm_metadata_updater
336
- @vm_metadata_updater ||= VmMetadataUpdater.build
337
- end
338
- end
339
- end