bosh-director 1.5.0.pre.1142 → 1.5.0.pre.1145

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,8 +61,15 @@ module Bosh::Director
61
61
  {"state" => "done", "value" => msg, "agent_task_id" => nil}
62
62
  end
63
63
 
64
- [:apply, :compile_package, :drain, :fetch_logs, :migrate_disk, :mount_disk,
65
- :stop, :unmount_disk].each do |method|
64
+ [ :apply,
65
+ :compile_package,
66
+ :drain,
67
+ :fetch_logs,
68
+ :migrate_disk,
69
+ :mount_disk,
70
+ :stop,
71
+ :unmount_disk,
72
+ ].each do |method|
66
73
  define_method (method) do |*args|
67
74
  task = AgentClient.convert_old_message_to_new(super(*args))
68
75
  while task["state"] == "running"
@@ -73,6 +80,5 @@ module Bosh::Director
73
80
  task["value"]
74
81
  end
75
82
  end
76
-
77
83
  end
78
84
  end
@@ -585,12 +585,7 @@ module Bosh::Director
585
585
  end
586
586
  end
587
587
 
588
- # JMS and MB: We don't know why this code exists. According to JP it shouldn't. We want to remove it.
589
- # To get comforable with that idea, we log something we can look for in production.
590
- #
591
- # GET /resources/deadbeef
592
588
  get '/resources/:id' do
593
- @logger.warn('Something is proxying a blob through the director. Find out why before we remove this method. ZAUGYZ')
594
589
  tmp_file = @resource_manager.get_resource_path(params[:id])
595
590
  send_disposable_file(tmp_file, :type => 'application/x-gzip')
596
591
  end
@@ -46,113 +46,24 @@ module Bosh::Director
46
46
  # in the current deployment and kicks off compilation.
47
47
  # @return [void]
48
48
  def compile
49
- @logger.info("Generating a list of compile tasks")
49
+ @logger.info('Generating a list of compile tasks')
50
50
  prepare_tasks
51
51
 
52
52
  @compile_tasks.each_value do |task|
53
53
  if task.ready_to_compile?
54
- @logger.info("Package `#{task.package.desc}' is ready to be " +
55
- "compiled for stemcell `#{task.stemcell.desc}'")
54
+ @logger.info("Package `#{task.package.desc}' is ready to be compiled for stemcell `#{task.stemcell.desc}'")
56
55
  @ready_tasks << task
57
56
  end
58
57
  end
59
58
 
60
59
  if @ready_tasks.empty?
61
- @logger.info("All packages are already compiled")
60
+ @logger.info('All packages are already compiled')
62
61
  else
63
62
  compile_packages
64
63
  director_job_checkpoint
65
64
  end
66
65
  end
67
66
 
68
- # Generates all compilation tasks required to compile all packages
69
- # in the jobs defined by deployment plan
70
- # @return [void]
71
- def prepare_tasks
72
- @event_log.begin_stage("Preparing package compilation")
73
-
74
- @event_log.track("Finding packages to compile") do
75
- @deployment_plan.jobs.each do |job|
76
- job_desc = "#{job.release.name}/#{job.name}"
77
- stemcell = job.resource_pool.stemcell
78
-
79
- @logger.info("Job `#{job_desc}' needs to run " +
80
- "on stemcell `#{stemcell.model.desc}'")
81
-
82
- job.templates.each do |template|
83
- template.package_models.each do |package|
84
- generate_compile_task(job, package, stemcell.model)
85
- end
86
- end
87
- end
88
- end
89
- end
90
-
91
- # Generates compilation task for a given (package, stemcell) tuple
92
- # @param [DeploymentPlan::Job] job Job spec
93
- # @param [Models::Package] package Package model
94
- # @param [Models::Stemcell] stemcell Stemcell model
95
- # @return [CompileTask] Compilation task for this package/stemcell tuple
96
- def generate_compile_task(job, package, stemcell)
97
- # Our assumption here is that package dependency graph
98
- # has no cycles: this is being enforced on release upload.
99
- # Other than that it's a vanilla DFS.
100
-
101
- @logger.info("Checking whether package `#{package.desc}' needs " +
102
- "to be compiled for stemcell `#{stemcell.desc}'")
103
- task_key = [package.id, stemcell.id]
104
- task = @compile_tasks[task_key]
105
-
106
- if task # We already visited this task and its dependencies
107
- task.add_job(job) # But we still need to register this job with task
108
- return task
109
- end
110
-
111
- dependencies = package.dependency_set.map do |name|
112
- job.release.get_package_model_by_name(name)
113
- end
114
-
115
- task = CompileTask.new(package, stemcell, dependencies, job)
116
-
117
- compiled_package = task.find_compiled_package(@logger, @event_log)
118
- if compiled_package
119
- task.use_compiled_package(compiled_package)
120
- end
121
-
122
- @logger.info("Processing package `#{package.desc}' dependencies")
123
- dependencies.each do |dependency|
124
- @logger.info("Package `#{package.desc}' depends on " +
125
- "package `#{dependency.desc}'")
126
- dependency_task = generate_compile_task(job, dependency, stemcell)
127
- task.add_dependency(dependency_task)
128
- end
129
-
130
- @compile_tasks[task_key] = task
131
- task
132
- end
133
-
134
- def reserve_network
135
- reservation = NetworkReservation.new_dynamic
136
-
137
- @network_mutex.synchronize do
138
- @network.reserve(reservation)
139
- end
140
-
141
- if !reservation.reserved?
142
- raise PackageCompilationNetworkNotReserved,
143
- "Could not reserve network for package compilation: " +
144
- reservation.error.to_s
145
- end
146
-
147
- reservation
148
- end
149
-
150
- def release_network(reservation)
151
- @network_mutex.synchronize do
152
- @network.release(reservation)
153
- end
154
- end
155
-
156
67
  def compile_package(task)
157
68
  package = task.package
158
69
  stemcell = task.stemcell
@@ -171,27 +82,27 @@ module Bosh::Director
171
82
  package.sha1, package.name,
172
83
  "#{package.version}.#{build}",
173
84
  task.dependency_spec)
174
- task_result = agent_task["result"]
85
+ task_result = agent_task['result']
175
86
  end
176
87
 
177
88
  compiled_package = Models::CompiledPackage.create do |p|
178
89
  p.package = package
179
90
  p.stemcell = stemcell
180
- p.sha1 = task_result["sha1"]
91
+ p.sha1 = task_result['sha1']
181
92
  p.build = build
182
- p.blobstore_id = task_result["blobstore_id"]
93
+ p.blobstore_id = task_result['blobstore_id']
183
94
  p.dependency_key = task.dependency_key
184
95
  end
185
96
 
186
97
  if Config.use_compiled_package_cache?
187
98
  if BlobUtil.exists_in_global_cache?(package, task.cache_key)
188
- @logger.info("Already exists in global package cache, skipping upload")
99
+ @logger.info('Already exists in global package cache, skipping upload')
189
100
  else
190
- @logger.info("Uploading to global package cache")
101
+ @logger.info('Uploading to global package cache')
191
102
  BlobUtil.save_to_global_cache(compiled_package, task.cache_key)
192
103
  end
193
104
  else
194
- @logger.info("Global blobstore not configured, skipping upload")
105
+ @logger.info('Global blobstore not configured, skipping upload')
195
106
  end
196
107
 
197
108
  @counter_mutex.synchronize { @compilations_performed += 1 }
@@ -213,8 +124,7 @@ module Bosh::Director
213
124
  if @deployment_plan.compilation.reuse_compilation_vms
214
125
  vm_data = @vm_reuser.get_vm(stemcell)
215
126
  if vm_data
216
- @logger.info("Reusing compilation VM `#{vm_data.vm.cid}' for " +
217
- "stemcell `#{stemcell.desc}'")
127
+ @logger.info("Reusing compilation VM `#{vm_data.vm.cid}' for stemcell `#{stemcell.desc}'")
218
128
  begin
219
129
  yield vm_data
220
130
  ensure
@@ -226,8 +136,7 @@ module Bosh::Director
226
136
  if @vm_reuser.get_num_vms(stemcell) >=
227
137
  @deployment_plan.compilation.workers
228
138
  raise PackageCompilationNotEnoughWorkersForReuse,
229
- "There should never be more VMs for a stemcell than the " +
230
- "number of workers in reuse_compilation_vms mode"
139
+ 'There should never be more VMs for a stemcell than the number of workers in reuse_compilation_vms mode'
231
140
  end
232
141
  end
233
142
 
@@ -267,8 +176,63 @@ module Bosh::Director
267
176
  end
268
177
  end
269
178
 
270
- # Tears down a VM and releases the network reservations.
271
- # @param [VmData] vm_data The VmData object for the VM to tear down.
179
+ private
180
+
181
+ def prepare_tasks
182
+ @event_log.begin_stage('Preparing package compilation')
183
+
184
+ @event_log.track('Finding packages to compile') do
185
+ @deployment_plan.jobs.each do |job|
186
+ job_desc = "#{job.release.name}/#{job.name}"
187
+ stemcell = job.resource_pool.stemcell
188
+
189
+ @logger.info("Job `#{job_desc}' needs to run on stemcell `#{stemcell.model.desc}'")
190
+
191
+ job.templates.each do |template|
192
+ template.package_models.each do |package|
193
+ generate_compile_task(job, package, stemcell.model)
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
199
+
200
+ def generate_compile_task(job, package, stemcell)
201
+ # Our assumption here is that package dependency graph
202
+ # has no cycles: this is being enforced on release upload.
203
+ # Other than that it's a vanilla DFS.
204
+
205
+ @logger.info("Checking whether package `#{package.desc}' needs to be compiled for stemcell `#{stemcell.desc}'")
206
+ task_key = [package.id, stemcell.id]
207
+ task = @compile_tasks[task_key]
208
+
209
+ if task # We already visited this task and its dependencies
210
+ task.add_job(job) # But we still need to register this job with task
211
+ return task
212
+ end
213
+
214
+ dependencies = package.dependency_set.map do |name|
215
+ job.release.get_package_model_by_name(name)
216
+ end
217
+
218
+ task = CompileTask.new(package, stemcell, dependencies, job)
219
+
220
+ compiled_package = task.find_compiled_package(@logger, @event_log)
221
+ if compiled_package
222
+ task.use_compiled_package(compiled_package)
223
+ end
224
+
225
+ @logger.info("Processing package `#{package.desc}' dependencies")
226
+ dependencies.each do |dependency|
227
+ @logger.info("Package `#{package.desc}' depends on package `#{dependency.desc}'")
228
+ dependency_task = generate_compile_task(job, dependency, stemcell)
229
+ task.add_dependency(dependency_task)
230
+ end
231
+
232
+ @compile_tasks[task_key] = task
233
+ task
234
+ end
235
+
272
236
  def tear_down_vm(vm_data)
273
237
  vm = vm_data.vm
274
238
  if vm.exists?
@@ -280,10 +244,29 @@ module Bosh::Director
280
244
  end
281
245
  end
282
246
 
283
- private
247
+ def reserve_network
248
+ reservation = NetworkReservation.new_dynamic
249
+
250
+ @network_mutex.synchronize do
251
+ @network.reserve(reservation)
252
+ end
253
+
254
+ unless reservation.reserved?
255
+ raise PackageCompilationNetworkNotReserved,
256
+ "Could not reserve network for package compilation: #{reservation.error}"
257
+ end
258
+
259
+ reservation
260
+ end
261
+
262
+ def release_network(reservation)
263
+ @network_mutex.synchronize do
264
+ @network.release(reservation)
265
+ end
266
+ end
284
267
 
285
268
  def compile_packages
286
- @event_log.begin_stage("Compiling packages", compilation_count)
269
+ @event_log.begin_stage('Compiling packages', compilation_count)
287
270
  number_of_workers = @deployment_plan.compilation.workers
288
271
 
289
272
  begin
@@ -320,12 +303,10 @@ module Bosh::Director
320
303
 
321
304
  def enqueue_unblocked_tasks(task)
322
305
  @tasks_mutex.synchronize do
323
- @logger.info("Unblocking dependents of " +
324
- "`#{task.package.desc}` for `#{task.stemcell.desc}`")
306
+ @logger.info("Unblocking dependents of `#{task.package.desc}` for `#{task.stemcell.desc}`")
325
307
  task.dependent_tasks.each do |dep_task|
326
308
  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}'")
309
+ @logger.info("Package `#{dep_task.package.desc}' now ready to be compiled for `#{dep_task.stemcell.desc}'")
329
310
  @ready_tasks << dep_task
330
311
  end
331
312
  end
@@ -361,9 +342,9 @@ module Bosh::Director
361
342
 
362
343
  def configure_vm(vm, agent, network_settings)
363
344
  state = {
364
- "deployment" => @deployment_plan.name,
365
- "resource_pool" => "package_compiler",
366
- "networks" => network_settings
345
+ 'deployment' => @deployment_plan.name,
346
+ 'resource_pool' => 'package_compiler',
347
+ 'networks' => network_settings
367
348
  }
368
349
 
369
350
  vm.update(:apply_spec => state)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Director
5
- VERSION = '1.5.0.pre.1142'
5
+ VERSION = '1.5.0.pre.1145'
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.1142
4
+ version: 1.5.0.pre.1145
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-22 00:00:00.000000000 Z
12
+ date: 2013-10-23 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.1142
37
+ version: 1.5.0.pre.1145
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.1142
45
+ version: 1.5.0.pre.1145
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.1142
53
+ version: 1.5.0.pre.1145
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.1142
61
+ version: 1.5.0.pre.1145
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.1142
69
+ version: 1.5.0.pre.1145
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.1142
77
+ version: 1.5.0.pre.1145
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.1142
85
+ version: 1.5.0.pre.1145
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.1142
93
+ version: 1.5.0.pre.1145
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.1142
101
+ version: 1.5.0.pre.1145
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.1142
109
+ version: 1.5.0.pre.1145
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.1142
117
+ version: 1.5.0.pre.1145
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.1142
125
+ version: 1.5.0.pre.1145
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.1142
133
+ version: 1.5.0.pre.1145
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.1142
141
+ version: 1.5.0.pre.1145
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
- 31eb14'
448
+ 715d8f'
449
449
  email: support@cloudfoundry.com
450
450
  executables:
451
451
  - bosh-director