bosh-director 1.5.0.pre.1134 → 1.5.0.pre.1138

Sign up to get free protection for your applications and to get access to all the features.
@@ -139,6 +139,40 @@ module Bosh::Director
139
139
  spec
140
140
  end
141
141
 
142
+ # @param [CompileTask] task
143
+ # @return [Models::CompiledPackage]
144
+ def find_compiled_package(logger, event_log)
145
+ # Check if this package is already compiled
146
+ compiled_package = Models::CompiledPackage[
147
+ :package_id => package.id,
148
+ :stemcell_id => stemcell.id,
149
+ :dependency_key => dependency_key
150
+ ]
151
+ if compiled_package
152
+ logger.info("Found compiled version of package `#{package.desc}' " +
153
+ "for stemcell `#{stemcell.desc}'")
154
+ else
155
+ if Config.use_compiled_package_cache?
156
+ if BlobUtil.exists_in_global_cache?(package, cache_key)
157
+ event_log.track("Downloading '#{package.desc}' from global cache") do
158
+ # has side effect of putting CompiledPackage model in db
159
+ compiled_package = BlobUtil.fetch_from_global_cache(package, stemcell, cache_key, dependency_key)
160
+ end
161
+ end
162
+ end
163
+
164
+ if compiled_package
165
+ logger.info("Package `Found compiled version of package `#{package.desc}'" +
166
+ "for stemcell `#{stemcell.desc}' in global cache")
167
+ else
168
+ logger.info("Package `#{package.desc}' " +
169
+ "needs to be compiled on `#{stemcell.desc}'")
170
+ end
171
+ end
172
+
173
+ compiled_package
174
+ end
175
+
142
176
  private
143
177
  def generate_dependency_key(packages)
144
178
  key = packages.sort { |a, b|
@@ -114,7 +114,7 @@ module Bosh::Director
114
114
 
115
115
  task = CompileTask.new(package, stemcell, dependencies, job)
116
116
 
117
- compiled_package = find_compiled_package(task)
117
+ compiled_package = task.find_compiled_package(@logger, @event_log)
118
118
  if compiled_package
119
119
  task.use_compiled_package(compiled_package)
120
120
  end
@@ -153,69 +153,13 @@ module Bosh::Director
153
153
  end
154
154
  end
155
155
 
156
- def compile_packages
157
- @event_log.begin_stage("Compiling packages", compilation_count)
158
- number_of_workers = @deployment_plan.compilation.workers
159
-
160
- begin
161
- ThreadPool.new(:max_threads => number_of_workers).wrap do |pool|
162
- loop do
163
- # process as many tasks without waiting
164
- loop do
165
- break if director_job_cancelled?
166
- task = @tasks_mutex.synchronize { @ready_tasks.pop }
167
- break if task.nil?
168
-
169
- pool.process { process_task(task) }
170
- end
171
-
172
- break if !pool.working? && (director_job_cancelled? || @ready_tasks.empty?)
173
- sleep(0.1)
174
- end
175
- end
176
- ensure
177
- # Delete all of the VMs if we were reusing compilation VMs. This can't
178
- # happen until everything was done compiling.
179
- if @deployment_plan.compilation.reuse_compilation_vms
180
- # Using a new ThreadPool instead of reusing the previous one,
181
- # as if there's a failed compilation, the thread pool will stop
182
- # processing any new thread.
183
- ThreadPool.new(:max_threads => number_of_workers).wrap do |pool|
184
- @vm_reuser.each do |vm_data|
185
- pool.process { tear_down_vm(vm_data) }
186
- end
187
- end
188
- end
189
- end
190
- end
191
-
192
- def process_task(task)
193
- package_desc = task.package.desc
194
- stemcell_desc = task.stemcell.desc
195
- task_desc = "package `#{package_desc}' for stemcell `#{stemcell_desc}'"
196
-
197
- with_thread_name("compile_package(#{package_desc}, #{stemcell_desc})") do
198
- if director_job_cancelled?
199
- @logger.info("Cancelled compiling #{task_desc}")
200
- else
201
- @event_log.track(package_desc) do
202
- @logger.info("Compiling #{task_desc}")
203
- compile_package(task)
204
- @logger.info("Finished compiling #{task_desc}")
205
- enqueue_unblocked_tasks(task)
206
- end
207
- end
208
- end
209
- end
210
- private :compile_packages, :process_task
211
-
212
156
  def compile_package(task)
213
157
  package = task.package
214
158
  stemcell = task.stemcell
215
159
 
216
160
  with_compile_lock(package.id, stemcell.id) do
217
161
  # Check if the package was compiled in a parallel deployment
218
- compiled_package = find_compiled_package(task)
162
+ compiled_package = task.find_compiled_package(@logger, @event_log)
219
163
  if compiled_package.nil?
220
164
  build = Models::CompiledPackage.generate_build_number(package, stemcell)
221
165
  task_result = nil
@@ -257,20 +201,6 @@ module Bosh::Director
257
201
  end
258
202
  end
259
203
 
260
- def enqueue_unblocked_tasks(task)
261
- @tasks_mutex.synchronize do
262
- @logger.info("Unblocking dependents of " +
263
- "`#{task.package.desc}` for `#{task.stemcell.desc}`")
264
- task.dependent_tasks.each do |dep_task|
265
- if dep_task.ready_to_compile?
266
- @logger.info("Package `#{dep_task.package.desc}' now ready to be " +
267
- "compiled for `#{dep_task.stemcell.desc}'")
268
- @ready_tasks << dep_task
269
- end
270
- end
271
- end
272
- end
273
-
274
204
  # This method will create a VM for each stemcell in the stemcells array
275
205
  # passed in. The VMs are yielded and their destruction is ensured.
276
206
  # @param [Models::Stemcell] stemcell The stemcells that need to have
@@ -350,45 +280,76 @@ module Bosh::Director
350
280
  end
351
281
  end
352
282
 
353
- # @param [CompileTask] task
354
- # @return [Models::CompiledPackage]
355
- def find_compiled_package(task)
356
- package = task.package
357
- stemcell = task.stemcell
358
- dependency_key = task.dependency_key
359
-
360
- # Check if this package is already compiled
361
- compiled_package = Models::CompiledPackage[
362
- :package_id => package.id,
363
- :stemcell_id => stemcell.id,
364
- :dependency_key => dependency_key
365
- ]
366
- if compiled_package
367
- @logger.info("Found compiled version of package `#{package.desc}' " +
368
- "for stemcell `#{stemcell.desc}'")
369
- else
370
- if Config.use_compiled_package_cache?
371
- if BlobUtil.exists_in_global_cache?(package, task.cache_key)
372
- @event_log.track("Downloading '#{package.desc}' from global cache") do
373
- # has side effect of putting CompiledPackage model in db
374
- compiled_package = BlobUtil.fetch_from_global_cache(package, stemcell, task.cache_key, dependency_key)
283
+ private
284
+
285
+ def compile_packages
286
+ @event_log.begin_stage("Compiling packages", compilation_count)
287
+ number_of_workers = @deployment_plan.compilation.workers
288
+
289
+ begin
290
+ ThreadPool.new(:max_threads => number_of_workers).wrap do |pool|
291
+ loop do
292
+ # process as many tasks without waiting
293
+ loop do
294
+ break if director_job_cancelled?
295
+ task = @tasks_mutex.synchronize { @ready_tasks.pop }
296
+ break if task.nil?
297
+
298
+ pool.process { process_task(task) }
375
299
  end
300
+
301
+ break if !pool.working? && (director_job_cancelled? || @ready_tasks.empty?)
302
+ sleep(0.1)
376
303
  end
377
304
  end
378
-
379
- if compiled_package
380
- @logger.info("Package `Found compiled version of package `#{package.desc}'" +
381
- "for stemcell `#{stemcell.desc}' in global cache")
382
- else
383
- @logger.info("Package `#{package.desc}' " +
384
- "needs to be compiled on `#{stemcell.desc}'")
305
+ ensure
306
+ # Delete all of the VMs if we were reusing compilation VMs. This can't
307
+ # happen until everything was done compiling.
308
+ if @deployment_plan.compilation.reuse_compilation_vms
309
+ # Using a new ThreadPool instead of reusing the previous one,
310
+ # as if there's a failed compilation, the thread pool will stop
311
+ # processing any new thread.
312
+ ThreadPool.new(:max_threads => number_of_workers).wrap do |pool|
313
+ @vm_reuser.each do |vm_data|
314
+ pool.process { tear_down_vm(vm_data) }
315
+ end
316
+ end
385
317
  end
386
318
  end
319
+ end
387
320
 
388
- compiled_package
321
+ def enqueue_unblocked_tasks(task)
322
+ @tasks_mutex.synchronize do
323
+ @logger.info("Unblocking dependents of " +
324
+ "`#{task.package.desc}` for `#{task.stemcell.desc}`")
325
+ task.dependent_tasks.each do |dep_task|
326
+ if dep_task.ready_to_compile?
327
+ @logger.info("Package `#{dep_task.package.desc}' now ready to be " +
328
+ "compiled for `#{dep_task.stemcell.desc}'")
329
+ @ready_tasks << dep_task
330
+ end
331
+ end
332
+ end
389
333
  end
390
334
 
391
- private
335
+ def process_task(task)
336
+ package_desc = task.package.desc
337
+ stemcell_desc = task.stemcell.desc
338
+ task_desc = "package `#{package_desc}' for stemcell `#{stemcell_desc}'"
339
+
340
+ with_thread_name("compile_package(#{package_desc}, #{stemcell_desc})") do
341
+ if director_job_cancelled?
342
+ @logger.info("Cancelled compiling #{task_desc}")
343
+ else
344
+ @event_log.track(package_desc) do
345
+ @logger.info("Compiling #{task_desc}")
346
+ compile_package(task)
347
+ @logger.info("Finished compiling #{task_desc}")
348
+ enqueue_unblocked_tasks(task)
349
+ end
350
+ end
351
+ end
352
+ end
392
353
 
393
354
  def director_job_cancelled?
394
355
  @director_job && @director_job.task_cancelled?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Director
5
- VERSION = '1.5.0.pre.1134'
5
+ VERSION = '1.5.0.pre.1138'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.pre.1134
4
+ version: 1.5.0.pre.1138
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-21 00:00:00.000000000 Z
12
+ date: 2013-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bcrypt-ruby
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.5.0.pre.1134
37
+ version: 1.5.0.pre.1138
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.5.0.pre.1134
45
+ version: 1.5.0.pre.1138
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bosh-core
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 1.5.0.pre.1134
53
+ version: 1.5.0.pre.1138
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.5.0.pre.1134
61
+ version: 1.5.0.pre.1138
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh_common
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 1.5.0.pre.1134
69
+ version: 1.5.0.pre.1138
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 1.5.0.pre.1134
77
+ version: 1.5.0.pre.1138
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bosh_cpi
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.5.0.pre.1134
85
+ version: 1.5.0.pre.1138
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.5.0.pre.1134
93
+ version: 1.5.0.pre.1138
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: bosh_openstack_cpi
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 1.5.0.pre.1134
101
+ version: 1.5.0.pre.1138
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.5.0.pre.1134
109
+ version: 1.5.0.pre.1138
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: bosh_aws_cpi
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.5.0.pre.1134
117
+ version: 1.5.0.pre.1138
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.5.0.pre.1134
125
+ version: 1.5.0.pre.1138
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: bosh_vsphere_cpi
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 1.5.0.pre.1134
133
+ version: 1.5.0.pre.1138
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 1.5.0.pre.1134
141
+ version: 1.5.0.pre.1138
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: eventmachine
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -445,7 +445,7 @@ dependencies:
445
445
  version: '1.0'
446
446
  description: ! 'BOSH Director
447
447
 
448
- bdd163'
448
+ 903d52'
449
449
  email: support@cloudfoundry.com
450
450
  executables:
451
451
  - bosh-director