bosh-director 1.1798.0 → 1.1836.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ require 'bosh/director'
2
+
3
+ module Bosh::Director
4
+ class CompileTaskGenerator
5
+ def initialize(logger, event_log)
6
+ @logger = logger
7
+ @event_log = event_log
8
+ end
9
+
10
+ # The compile_tasks hash passed in by the caller will be populated with CompileTasks objects
11
+ def generate!(compile_tasks, job, template, package, stemcell)
12
+ # Our assumption here is that package dependency graph
13
+ # has no cycles: this is being enforced on release upload.
14
+ # Other than that it's a vanilla DFS.
15
+
16
+ @logger.info("Checking whether package `#{package.desc}' needs to be compiled for stemcell `#{stemcell.desc}'")
17
+ task_key = [package.id, stemcell.id]
18
+ task = compile_tasks[task_key]
19
+
20
+ if task # We already visited this task and its dependencies
21
+ task.add_job(job) # But we still need to register this job with task
22
+ return task
23
+ end
24
+
25
+ release_version = template.release.model
26
+
27
+ task = CompileTask.new(package,
28
+ stemcell,
29
+ job,
30
+ release_version.package_dependency_key(package.name),
31
+ release_version.package_cache_key(package.name, stemcell))
32
+
33
+ compiled_package = task.find_compiled_package(@logger, @event_log)
34
+ if compiled_package
35
+ task.use_compiled_package(compiled_package)
36
+ end
37
+
38
+ @logger.info("Processing package `#{package.desc}' dependencies")
39
+ dependencies = release_version.dependencies(package.name)
40
+ dependencies.each do |dependency|
41
+ @logger.info("Package `#{package.desc}' depends on package `#{dependency.desc}'")
42
+ dependency_task = generate!(compile_tasks, job, template, dependency, stemcell)
43
+ task.add_dependency(dependency_task)
44
+ end
45
+
46
+ compile_tasks[task_key] = task
47
+ task
48
+ end
49
+
50
+ end
51
+ end
@@ -1,5 +1,7 @@
1
1
  require 'tmpdir'
2
2
  require 'digest/sha1'
3
+ require 'bosh/director/tar_gzipper'
4
+ require 'bosh/director/rendered_templates_writer'
3
5
 
4
6
  module Bosh::Director
5
7
  class CompressedRenderedJobTemplates
@@ -53,7 +53,11 @@ module Bosh::Director
53
53
  end
54
54
 
55
55
  @blobstore = nil
56
+
56
57
  @compiled_package_cache = nil
58
+ @compiled_package_blobstore = nil
59
+ @compiled_package_cache_options = nil
60
+
57
61
  @nats = nil
58
62
  @nats_rpc = nil
59
63
  @cloud = nil
@@ -62,7 +66,7 @@ module Bosh::Director
62
66
  def configure(config)
63
67
  @max_vm_create_tries = Integer(config.fetch('max_vm_create_tries', 5))
64
68
 
65
- @base_dir = config["dir"]
69
+ @base_dir = config['dir']
66
70
  FileUtils.mkdir_p(@base_dir)
67
71
 
68
72
  # checkpoint task progress every 30 secs
@@ -85,14 +89,14 @@ module Bosh::Director
85
89
  @event_log = EventLog::Log.new
86
90
 
87
91
  # by default keep only last 500 tasks in disk
88
- @max_tasks = config.fetch("max_tasks", 500).to_i
92
+ @max_tasks = config.fetch('max_tasks', 500).to_i
89
93
 
90
- @max_threads = config.fetch("max_threads", 32).to_i
94
+ @max_threads = config.fetch('max_threads', 32).to_i
91
95
 
92
96
  self.redis_options= {
93
- :host => config["redis"]["host"],
94
- :port => config["redis"]["port"],
95
- :password => config["redis"]["password"],
97
+ :host => config['redis']['host'],
98
+ :port => config['redis']['port'],
99
+ :password => config['redis']['password'],
96
100
  :logger => redis_logger
97
101
  }
98
102
 
@@ -101,29 +105,29 @@ module Bosh::Director
101
105
  @logger.info("Starting BOSH Director: #{VERSION} (#{@revision})")
102
106
 
103
107
  @process_uuid = SecureRandom.uuid
104
- @nats_uri = config["mbus"]
108
+ @nats_uri = config['mbus']
105
109
 
106
- @cloud_options = config["cloud"]
107
- @compiled_package_cache_options = config["compiled_package_cache"]
108
- @name = config["name"] || ""
110
+ @cloud_options = config['cloud']
111
+ @compiled_package_cache_options = config['compiled_package_cache']
112
+ @name = config['name'] || ''
109
113
 
110
114
  @compiled_package_cache = nil
111
115
 
112
116
  @db_config = config['db']
113
- @db = configure_db(config["db"])
114
- @dns = config["dns"]
115
- @dns_domain_name = "bosh"
117
+ @db = configure_db(config['db'])
118
+ @dns = config['dns']
119
+ @dns_domain_name = 'bosh'
116
120
  if @dns
117
- @dns_db = configure_db(@dns["db"]) if @dns["db"]
118
- @dns_domain_name = canonical(@dns["domain_name"]) if @dns["domain_name"]
121
+ @dns_db = configure_db(@dns['db']) if @dns['db']
122
+ @dns_domain_name = canonical(@dns['domain_name']) if @dns['domain_name']
119
123
  end
120
124
 
121
125
  @uuid = override_uuid || Bosh::Director::Models::DirectorAttribute.find_or_create_uuid(@logger)
122
126
  @logger.info("Director UUID: #{@uuid}")
123
127
 
124
- @encryption = config["encryption"]
125
- @fix_stateful_nodes = config.fetch("scan_and_fix", {})
126
- .fetch("auto_fix_stateful_nodes", false)
128
+ @encryption = config['encryption']
129
+ @fix_stateful_nodes = config.fetch('scan_and_fix', {})
130
+ .fetch('auto_fix_stateful_nodes', false)
127
131
  @enable_snapshots = config.fetch('snapshots', {}).fetch('enabled', false)
128
132
 
129
133
  Bosh::Clouds::Config.configure(self)
@@ -140,15 +144,15 @@ module Bosh::Director
140
144
  end
141
145
 
142
146
  def get_revision
143
- Dir.chdir(File.expand_path("../../../../../..", __FILE__))
144
- revision_command = "(cat REVISION 2> /dev/null || " +
145
- "git show-ref --head --hash=8 2> /dev/null || " +
146
- "echo 00000000) | head -n1"
147
+ Dir.chdir(File.expand_path('../../../../../..', __FILE__))
148
+ revision_command = '(cat REVISION 2> /dev/null || ' +
149
+ 'git show-ref --head --hash=8 2> /dev/null || ' +
150
+ 'echo 00000000) | head -n1'
147
151
  `#{revision_command}`.strip
148
152
  end
149
153
 
150
154
  def configure_db(db_config)
151
- patch_sqlite if db_config["adapter"] == "sqlite"
155
+ patch_sqlite if db_config['adapter'] == 'sqlite'
152
156
 
153
157
  connection_options = db_config.delete('connection_options') {{}}
154
158
  db_config.delete_if { |_, v| v.to_s.empty? }
@@ -166,8 +170,8 @@ module Bosh::Director
166
170
  def compiled_package_cache_blobstore
167
171
  @lock.synchronize do
168
172
  if @compiled_package_cache_blobstore.nil? && use_compiled_package_cache?
169
- provider = @compiled_package_cache_options["provider"]
170
- options = @compiled_package_cache_options["options"]
173
+ provider = @compiled_package_cache_options['provider']
174
+ options = @compiled_package_cache_options['options']
171
175
  @compiled_package_cache_blobstore = Bosh::Blobstore::Client.safe_create(provider, options)
172
176
  end
173
177
  end
@@ -175,20 +179,20 @@ module Bosh::Director
175
179
  end
176
180
 
177
181
  def compiled_package_cache_provider
178
- use_compiled_package_cache? ? @compiled_package_cache_options["provider"] : nil
182
+ use_compiled_package_cache? ? @compiled_package_cache_options['provider'] : nil
179
183
  end
180
184
 
181
185
  def cloud_type
182
186
  if @cloud_options
183
- @cloud_options["plugin"]
187
+ @cloud_options['plugin']
184
188
  end
185
189
  end
186
190
 
187
191
  def cloud
188
192
  @lock.synchronize do
189
193
  if @cloud.nil?
190
- plugin = @cloud_options["plugin"]
191
- properties = @cloud_options["properties"]
194
+ plugin = @cloud_options['plugin']
195
+ properties = @cloud_options['properties']
192
196
  @cloud = Bosh::Clouds::Provider.create(plugin, properties)
193
197
  end
194
198
  end
@@ -266,8 +270,8 @@ module Bosh::Director
266
270
  return if @patched_sqlite
267
271
  @patched_sqlite = true
268
272
 
269
- require "sequel"
270
- require "sequel/adapters/sqlite"
273
+ require 'sequel'
274
+ require 'sequel/adapters/sqlite'
271
275
 
272
276
  Sequel::SQLite::Database.class_eval do
273
277
  def connect(server)
@@ -389,7 +389,6 @@ module Bosh::Director
389
389
  state = idle_vm.current_state
390
390
  state['job'] = instance.job.spec
391
391
  state['index'] = instance.index
392
- state['release'] = instance.job.release.spec
393
392
  agent.apply(state)
394
393
 
395
394
  # Our assumption here is that director database access
@@ -20,11 +20,18 @@ module Bosh::Director
20
20
  attr_accessor :vm
21
21
 
22
22
  # @return [Hash] Current state as provided by the BOSH Agent
23
- attr_accessor :current_state
23
+ attr_writer :current_state
24
24
 
25
25
  # @return [DeploymentPlan::Instance, nil] Instance that reserved this VM
26
26
  attr_accessor :bound_instance
27
27
 
28
+ def current_state
29
+ if @current_state
30
+ @current_state.delete("release")
31
+ end
32
+ @current_state
33
+ end
34
+
28
35
  ##
29
36
  # Creates a new idle VM reference for the specific resource pool
30
37
  # @param [DeploymentPlan::ResourcePool] resource_pool Resource pool
@@ -106,4 +113,4 @@ module Bosh::Director
106
113
  end
107
114
  end
108
115
  end
109
- end
116
+ end
@@ -345,7 +345,6 @@ module Bosh::Director
345
345
  def spec
346
346
  spec = {
347
347
  'deployment' => @job.deployment.name,
348
- 'release' => job.release.spec,
349
348
  'job' => job.spec,
350
349
  'index' => index,
351
350
  'networks' => network_settings,
@@ -121,7 +121,6 @@ module Bosh::Director
121
121
  first_template = @templates[0]
122
122
  result = {
123
123
  "name" => @name,
124
- "release" => @release.name,
125
124
  "templates" => [],
126
125
  # --- Legacy ---
127
126
  "template" => first_template.name,
@@ -322,7 +322,6 @@ module Bosh::Director
322
322
  "resource_pool" => @job.resource_pool.spec,
323
323
  "job" => @job.spec,
324
324
  "index" => @instance.index,
325
- "release" => @job.release.spec
326
325
  }
327
326
 
328
327
  if @instance.disk_size > 0
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
1
+ require 'bosh/director/compile_task_generator'
2
2
 
3
3
  module Bosh::Director
4
4
  class PackageCompiler
@@ -27,6 +27,8 @@ module Bosh::Director
27
27
 
28
28
  @vm_reuser = VmReuser.new
29
29
 
30
+ @compile_task_generator = CompileTaskGenerator.new(@logger, @event_log)
31
+
30
32
  @compile_tasks = {}
31
33
  @ready_tasks = []
32
34
  @compilations_performed = 0
@@ -183,59 +185,27 @@ module Bosh::Director
183
185
 
184
186
  @event_log.track('Finding packages to compile') do
185
187
  @deployment_plan.jobs.each do |job|
186
- job_desc = "#{job.release.name}/#{job.name}"
187
188
  stemcell = job.resource_pool.stemcell
188
189
 
189
- @logger.info("Job `#{job_desc}' needs to run on stemcell `#{stemcell.model.desc}'")
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}'")
190
199
 
191
200
  job.templates.each do |template|
192
201
  template.package_models.each do |package|
193
- generate_compile_task(job, package, stemcell.model)
202
+ @compile_task_generator.generate!(@compile_tasks, job, template, package, stemcell.model)
194
203
  end
195
204
  end
196
205
  end
197
206
  end
198
207
  end
199
208
 
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
- release_version = job.release.model
215
-
216
- task = CompileTask.new(package,
217
- stemcell,
218
- job,
219
- release_version.package_dependency_key(package.name),
220
- release_version.package_cache_key(package.name, stemcell))
221
-
222
- compiled_package = task.find_compiled_package(@logger, @event_log)
223
- if compiled_package
224
- task.use_compiled_package(compiled_package)
225
- end
226
-
227
- @logger.info("Processing package `#{package.desc}' dependencies")
228
- dependencies = release_version.dependencies(package.name)
229
- dependencies.each do |dependency|
230
- @logger.info("Package `#{package.desc}' depends on package `#{dependency.desc}'")
231
- dependency_task = generate_compile_task(job, dependency, stemcell)
232
- task.add_dependency(dependency_task)
233
- end
234
-
235
- @compile_tasks[task_key] = task
236
- task
237
- end
238
-
239
209
  def tear_down_vm(vm_data)
240
210
  vm = vm_data.vm
241
211
  if vm.exists?
@@ -1,6 +1,6 @@
1
1
  require 'tempfile'
2
- require 'bosh/director/rendered_templates_writer'
3
2
  require 'bosh/director/compressed_rendered_job_templates'
3
+ require 'bosh/director/deployment_plan/rendered_templates_archive'
4
4
 
5
5
  module Bosh::Director
6
6
  class RenderedJobTemplatesPersister
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.1798.0'
3
+ VERSION = '1.1836.0'
4
4
  end
5
5
  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.1798.0
4
+ version: 1.1836.0
5
5
  prerelease:
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: 2014-01-18 00:00:00.000000000 Z
12
+ date: 2014-01-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.1798.0
37
+ version: 1.1836.0
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.1798.0
45
+ version: 1.1836.0
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.1798.0
53
+ version: 1.1836.0
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.1798.0
61
+ version: 1.1836.0
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.1798.0
69
+ version: 1.1836.0
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.1798.0
77
+ version: 1.1836.0
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.1798.0
85
+ version: 1.1836.0
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.1798.0
93
+ version: 1.1836.0
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.1798.0
101
+ version: 1.1836.0
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.1798.0
109
+ version: 1.1836.0
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.1798.0
117
+ version: 1.1836.0
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.1798.0
125
+ version: 1.1836.0
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.1798.0
133
+ version: 1.1836.0
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.1798.0
141
+ version: 1.1836.0
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: eventmachine
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -461,7 +461,7 @@ dependencies:
461
461
  version: '1.0'
462
462
  description: ! 'BOSH Director
463
463
 
464
- 4c516b'
464
+ f49b5d'
465
465
  email: support@cloudfoundry.com
466
466
  executables:
467
467
  - bosh-director
@@ -545,6 +545,7 @@ files:
545
545
  - lib/bosh/director/blobstores.rb
546
546
  - lib/bosh/director/cloudcheck_helper.rb
547
547
  - lib/bosh/director/compile_task.rb
548
+ - lib/bosh/director/compile_task_generator.rb
548
549
  - lib/bosh/director/compiled_package.rb
549
550
  - lib/bosh/director/compiled_package/blob_sha_mismatch_error.rb
550
551
  - lib/bosh/director/compiled_package/compiled_package.rb
@@ -714,7 +715,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
714
715
  version: '0'
715
716
  segments:
716
717
  - 0
717
- hash: -1547539602198935562
718
+ hash: 3345351914595372714
718
719
  requirements: []
719
720
  rubyforge_project:
720
721
  rubygems_version: 1.8.23