bosh-director 1.2957.0 → 1.2962.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bosh/director.rb +0 -1
- data/lib/bosh/director/api/cloud_config_manager.rb +9 -0
- data/lib/bosh/director/api/controllers/deployments_controller.rb +12 -4
- data/lib/bosh/director/deployment_plan.rb +4 -2
- data/lib/bosh/director/deployment_plan/assembler.rb +6 -62
- data/lib/bosh/director/deployment_plan/cloud_manifest_parser.rb +77 -0
- data/lib/bosh/director/deployment_plan/compilation_config.rb +12 -12
- data/lib/bosh/director/deployment_plan/deployment_repo.rb +28 -0
- data/lib/bosh/director/deployment_plan/deployment_spec_parser.rb +5 -74
- data/lib/bosh/director/deployment_plan/dynamic_network.rb +2 -2
- data/lib/bosh/director/deployment_plan/manifest_migrator.rb +53 -0
- data/lib/bosh/director/deployment_plan/manual_network.rb +1 -1
- data/lib/bosh/director/deployment_plan/network_subnet.rb +3 -4
- data/lib/bosh/director/deployment_plan/notifier.rb +5 -5
- data/lib/bosh/director/deployment_plan/planner.rb +96 -122
- data/lib/bosh/director/deployment_plan/planner_factory.rb +148 -0
- data/lib/bosh/director/deployment_plan/release_version.rb +6 -7
- data/lib/bosh/director/deployment_plan/resource_pool.rb +6 -6
- data/lib/bosh/director/deployment_plan/steps/package_compile_step.rb +5 -5
- data/lib/bosh/director/deployment_plan/steps/update_step.rb +59 -11
- data/lib/bosh/director/deployment_plan/vip_network.rb +1 -1
- data/lib/bosh/director/errand.rb +0 -1
- data/lib/bosh/director/errand/job_manager.rb +5 -0
- data/lib/bosh/director/errors.rb +2 -0
- data/lib/bosh/director/jobs/fetch_logs.rb +1 -1
- data/lib/bosh/director/jobs/run_errand.rb +31 -30
- data/lib/bosh/director/jobs/update_deployment.rb +32 -50
- data/lib/bosh/director/models/deployment.rb +0 -1
- data/lib/bosh/director/version.rb +1 -1
- metadata +25 -23
- data/lib/bosh/director/deployment_plan/steps/prepare_step.rb +0 -56
- data/lib/bosh/director/errand/deployment_preparer.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d4f4eade478f6b9d65bf799b7e13648e301cfc3
|
4
|
+
data.tar.gz: fa9bae11220e770e7394620c62b3d947adb17040
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 371c318920e3d18d0f6692ee3c394846c76ad9eecf9c357968cd87fababb8d77ae8b1b61583505320fa7cac9f47a7392131cd715ef40e8cd0143d234a32e2b95
|
7
|
+
data.tar.gz: 7409d247a48a67c21fa360b5ed0139ead30f536b8bcfb25a7d133c51af1fc1fb93c1dd38736033ace5cbf97619263c80eb45c8b32a2baf850ea98c55fd636fe3
|
data/lib/bosh/director.rb
CHANGED
@@ -64,7 +64,6 @@ require 'bosh/director/vm_metadata_updater'
|
|
64
64
|
require 'bosh/director/vm_data'
|
65
65
|
require 'bosh/director/vm_reuser'
|
66
66
|
require 'bosh/director/deployment_plan'
|
67
|
-
require 'bosh/director/deployment_plan/assembler'
|
68
67
|
require 'bosh/director/errand'
|
69
68
|
require 'bosh/director/duration'
|
70
69
|
require 'bosh/director/hash_string_vals'
|
@@ -6,6 +6,7 @@ module Bosh
|
|
6
6
|
cloud_config = Bosh::Director::Models::CloudConfig.new(
|
7
7
|
properties: cloud_config_yaml
|
8
8
|
)
|
9
|
+
validate_manifest(cloud_config)
|
9
10
|
cloud_config.save
|
10
11
|
end
|
11
12
|
|
@@ -16,6 +17,14 @@ module Bosh
|
|
16
17
|
def latest
|
17
18
|
list(1).first
|
18
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def validate_manifest(cloud_config)
|
24
|
+
deployment = Bosh::Director::DeploymentPlan::CloudPlanner.new(cloud_config)
|
25
|
+
parser = Bosh::Director::DeploymentPlan::CloudManifestParser.new(deployment, Config.logger)
|
26
|
+
parser.parse(cloud_config.manifest)
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -291,10 +291,7 @@ module Bosh::Director
|
|
291
291
|
end
|
292
292
|
|
293
293
|
get '/:deployment_name/errands' do
|
294
|
-
|
295
|
-
|
296
|
-
manifest = Psych.load(deployment.manifest)
|
297
|
-
deployment_plan = DeploymentPlan::Planner.parse(manifest, deployment.cloud_config, {}, Config.event_log, Config.logger)
|
294
|
+
deployment_plan = load_deployment_plan_without_binding
|
298
295
|
|
299
296
|
errands = deployment_plan.jobs.select(&:can_run_as_errand?)
|
300
297
|
|
@@ -306,6 +303,17 @@ module Bosh::Director
|
|
306
303
|
end
|
307
304
|
|
308
305
|
private
|
306
|
+
|
307
|
+
def load_deployment_plan_without_binding
|
308
|
+
deployment_model = @deployment_manager.find_by_name(params[:deployment_name])
|
309
|
+
manifest_hash = Psych.load(deployment_model.manifest)
|
310
|
+
cloud_config_model = deployment_model.cloud_config
|
311
|
+
|
312
|
+
planner_factory = Bosh::Director::DeploymentPlan::PlannerFactory.create(Config.event_log, Config.logger)
|
313
|
+
planner_factory.planner_without_vm_binding(manifest_hash, cloud_config_model, {})
|
314
|
+
end
|
315
|
+
|
316
|
+
|
309
317
|
def convert_job_instance_hash(hash)
|
310
318
|
hash.reduce([]) do |jobs, kv|
|
311
319
|
job, indicies = kv
|
@@ -24,7 +24,9 @@ require 'bosh/director/deployment_plan/vip_network'
|
|
24
24
|
require 'bosh/director/deployment_plan/planner'
|
25
25
|
require 'bosh/director/deployment_plan/dns_binder'
|
26
26
|
require 'bosh/director/deployment_plan/notifier'
|
27
|
-
require 'bosh/director/deployment_plan/steps/prepare_step'
|
28
27
|
require 'bosh/director/deployment_plan/steps/update_step'
|
29
28
|
require 'bosh/director/deployment_plan/steps/package_compile_step'
|
30
|
-
|
29
|
+
require 'bosh/director/deployment_plan/assembler'
|
30
|
+
require 'bosh/director/deployment_plan/planner_factory'
|
31
|
+
require 'bosh/director/deployment_plan/manifest_migrator'
|
32
|
+
require 'bosh/director/deployment_plan/deployment_repo'
|
@@ -5,19 +5,13 @@ module Bosh::Director
|
|
5
5
|
include LockHelper
|
6
6
|
include IpUtil
|
7
7
|
|
8
|
-
def initialize(deployment_plan)
|
8
|
+
def initialize(deployment_plan, stemcell_manager, cloud, blobstore, logger, event_log)
|
9
9
|
@deployment_plan = deployment_plan
|
10
|
-
@cloud =
|
11
|
-
@logger =
|
12
|
-
@event_log =
|
13
|
-
@stemcell_manager =
|
14
|
-
@blobstore =
|
15
|
-
end
|
16
|
-
|
17
|
-
# Binds deployment DB record to a plan
|
18
|
-
# @return [void]
|
19
|
-
def bind_deployment
|
20
|
-
@deployment_plan.bind_model
|
10
|
+
@cloud = cloud
|
11
|
+
@logger = logger
|
12
|
+
@event_log = event_log
|
13
|
+
@stemcell_manager = stemcell_manager
|
14
|
+
@blobstore = blobstore
|
21
15
|
end
|
22
16
|
|
23
17
|
# Binds release DB record(s) to a plan
|
@@ -318,59 +312,9 @@ module Bosh::Director
|
|
318
312
|
end
|
319
313
|
end
|
320
314
|
|
321
|
-
# Calculates configuration checksums for all jobs in this deployment plan
|
322
|
-
# @return [void]
|
323
|
-
def bind_configuration
|
324
|
-
@deployment_plan.jobs_starting_on_deploy.each do |job|
|
325
|
-
JobRenderer.new(job, @blobstore).render_job_instances
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
315
|
def bind_dns
|
330
316
|
binder = DeploymentPlan::DnsBinder.new(@deployment_plan)
|
331
317
|
binder.bind_deployment
|
332
318
|
end
|
333
|
-
|
334
|
-
def bind_instance_vms
|
335
|
-
jobs = @deployment_plan.jobs_starting_on_deploy
|
336
|
-
instances = jobs.map(&:instances).flatten
|
337
|
-
|
338
|
-
binder = DeploymentPlan::InstanceVmBinder.new(@event_log)
|
339
|
-
binder.bind_instance_vms(instances)
|
340
|
-
end
|
341
|
-
|
342
|
-
def delete_unneeded_vms
|
343
|
-
unneeded_vms = @deployment_plan.unneeded_vms
|
344
|
-
if unneeded_vms.empty?
|
345
|
-
@logger.info('No unneeded vms to delete')
|
346
|
-
return
|
347
|
-
end
|
348
|
-
|
349
|
-
@event_log.begin_stage('Deleting unneeded VMs', unneeded_vms.size)
|
350
|
-
ThreadPool.new(max_threads: Config.max_threads, logger: @logger).wrap do |pool|
|
351
|
-
unneeded_vms.each do |vm_model|
|
352
|
-
pool.process do
|
353
|
-
@event_log.track(vm_model.cid) do
|
354
|
-
@logger.info("Delete unneeded VM #{vm_model.cid}")
|
355
|
-
@cloud.delete_vm(vm_model.cid)
|
356
|
-
vm_model.destroy
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
def delete_unneeded_instances
|
364
|
-
unneeded_instances = @deployment_plan.unneeded_instances
|
365
|
-
if unneeded_instances.empty?
|
366
|
-
@logger.info('No unneeded instances to delete')
|
367
|
-
return
|
368
|
-
end
|
369
|
-
|
370
|
-
event_log_stage = @event_log.begin_stage('Deleting unneeded instances', unneeded_instances.size)
|
371
|
-
instance_deleter = InstanceDeleter.new(@deployment_plan)
|
372
|
-
instance_deleter.delete_instances(unneeded_instances, event_log_stage)
|
373
|
-
@logger.info('Deleted no longer needed instances')
|
374
|
-
end
|
375
319
|
end
|
376
320
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'common/deep_copy'
|
2
|
+
|
3
|
+
module Bosh::Director
|
4
|
+
module DeploymentPlan
|
5
|
+
class CloudManifestParser
|
6
|
+
include ValidationHelper
|
7
|
+
|
8
|
+
def initialize(deployment, logger)
|
9
|
+
@deployment = deployment
|
10
|
+
@logger = logger
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse(cloud_manifest)
|
14
|
+
@cloud_manifest = cloud_manifest
|
15
|
+
|
16
|
+
parse_networks
|
17
|
+
parse_compilation
|
18
|
+
parse_resource_pools
|
19
|
+
parse_disk_pools
|
20
|
+
|
21
|
+
@deployment
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def parse_networks
|
27
|
+
networks = safe_property(@cloud_manifest, 'networks', :class => Array)
|
28
|
+
networks.each do |network_spec|
|
29
|
+
type = safe_property(network_spec, 'type', :class => String,
|
30
|
+
:default => 'manual')
|
31
|
+
|
32
|
+
case type
|
33
|
+
when 'manual'
|
34
|
+
network = ManualNetwork.new(@deployment, network_spec)
|
35
|
+
when 'dynamic'
|
36
|
+
network = DynamicNetwork.new(@deployment, network_spec)
|
37
|
+
when 'vip'
|
38
|
+
network = VipNetwork.new(@deployment, network_spec)
|
39
|
+
else
|
40
|
+
raise DeploymentInvalidNetworkType,
|
41
|
+
"Invalid network type `#{type}'"
|
42
|
+
end
|
43
|
+
|
44
|
+
@deployment.add_network(network)
|
45
|
+
end
|
46
|
+
|
47
|
+
if @deployment.networks.empty?
|
48
|
+
raise DeploymentNoNetworks, 'No networks specified'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_compilation
|
53
|
+
compilation_spec = safe_property(@cloud_manifest, 'compilation', :class => Hash)
|
54
|
+
@deployment.compilation = CompilationConfig.new(@deployment, compilation_spec)
|
55
|
+
end
|
56
|
+
|
57
|
+
def parse_resource_pools
|
58
|
+
resource_pools = safe_property(@cloud_manifest, 'resource_pools', :class => Array)
|
59
|
+
resource_pools.each do |rp_spec|
|
60
|
+
@deployment.add_resource_pool(ResourcePool.new(@deployment, rp_spec, @logger))
|
61
|
+
end
|
62
|
+
|
63
|
+
if @deployment.resource_pools.empty?
|
64
|
+
raise DeploymentNoResourcePools, 'No resource_pools specified'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def parse_disk_pools
|
69
|
+
disk_pools = safe_property(@cloud_manifest, 'disk_pools', :class => Array, :optional => true)
|
70
|
+
return if disk_pools.nil?
|
71
|
+
disk_pools.each do |dp_spec|
|
72
|
+
@deployment.add_disk_pool(DiskPool.parse(dp_spec))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -30,24 +30,24 @@ module Bosh::Director
|
|
30
30
|
# @param [Hash] compilation_config parsed compilation config YAML section
|
31
31
|
def initialize(deployment, compilation_config)
|
32
32
|
@deployment = deployment
|
33
|
-
@workers = safe_property(compilation_config, "workers",
|
34
|
-
|
35
|
-
network_name = safe_property(compilation_config, "network",
|
36
|
-
|
33
|
+
@workers = safe_property(compilation_config, "workers", class: Integer, min: 1)
|
34
|
+
|
35
|
+
network_name = safe_property(compilation_config, "network", class: String)
|
36
|
+
|
37
37
|
@reuse_compilation_vms = safe_property(compilation_config,
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
"reuse_compilation_vms",
|
39
|
+
class: :boolean,
|
40
|
+
optional: true)
|
41
|
+
|
41
42
|
@network = deployment.network(network_name)
|
42
43
|
if @network.nil?
|
43
44
|
raise CompilationConfigUnknownNetwork,
|
44
|
-
|
45
|
-
|
45
|
+
"Compilation config references an unknown " +
|
46
|
+
"network `#{network_name}'"
|
46
47
|
end
|
47
48
|
@cloud_properties = safe_property(
|
48
|
-
|
49
|
-
@env = safe_property(compilation_config, "env", :
|
50
|
-
:optional => true, :default => {})
|
49
|
+
compilation_config, "cloud_properties", class: Hash, default: {})
|
50
|
+
@env = safe_property(compilation_config, "env", class: Hash, optional: true, default: {})
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Bosh
|
2
|
+
module Director
|
3
|
+
module DeploymentPlan
|
4
|
+
class DeploymentRepo
|
5
|
+
|
6
|
+
def initialize(canonicalizer)
|
7
|
+
@canonicalizer = canonicalizer
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_or_create_by_name(name)
|
11
|
+
deployment = Models::Deployment.find(name: name)
|
12
|
+
return deployment if deployment
|
13
|
+
|
14
|
+
canonical_name = @canonicalizer.canonical(name)
|
15
|
+
Models::Deployment.db.transaction do
|
16
|
+
Models::Deployment.each do |other|
|
17
|
+
if @canonicalizer.canonical(other.name) == canonical_name
|
18
|
+
raise DeploymentCanonicalNameTaken,
|
19
|
+
"Invalid deployment name `#{name}', canonical name already taken (`#{canonical_name}')"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
Models::Deployment.create(name: name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -6,32 +6,21 @@ module Bosh::Director
|
|
6
6
|
include DnsHelper
|
7
7
|
include ValidationHelper
|
8
8
|
|
9
|
-
def initialize(event_log, logger)
|
9
|
+
def initialize(deployment, event_log, logger)
|
10
10
|
@event_log = event_log
|
11
11
|
@logger = logger
|
12
|
+
@deployment = deployment
|
12
13
|
end
|
13
14
|
|
14
15
|
# @param [Hash] manifest Raw deployment manifest
|
15
16
|
# @return [DeploymentPlan::Planner] Deployment as build from deployment_spec
|
16
|
-
def parse(
|
17
|
-
@deployment_manifest =
|
18
|
-
if cloud_config.nil?
|
19
|
-
@cloud_manifest = cloud_manifest_from_deployment_manifest @deployment_manifest
|
20
|
-
else
|
21
|
-
@cloud_manifest = cloud_config.manifest
|
22
|
-
end
|
23
|
-
|
17
|
+
def parse(deployment_manifest, options = {})
|
18
|
+
@deployment_manifest = deployment_manifest
|
24
19
|
@job_states = safe_property(options, 'job_states', :class => Hash, :default => {})
|
25
20
|
|
26
|
-
@deployment = Planner.new(parse_name, manifest, cloud_config, options)
|
27
|
-
|
28
21
|
parse_properties
|
29
22
|
parse_releases
|
30
|
-
parse_networks
|
31
|
-
parse_compilation
|
32
23
|
parse_update
|
33
|
-
parse_resource_pools
|
34
|
-
parse_disk_pools
|
35
24
|
parse_jobs
|
36
25
|
|
37
26
|
@deployment
|
@@ -39,15 +28,6 @@ module Bosh::Director
|
|
39
28
|
|
40
29
|
private
|
41
30
|
|
42
|
-
CLOUD_MANIFEST_KEYS = ['resource_pools','compilation','disk_pools','networks']
|
43
|
-
def cloud_manifest_from_deployment_manifest(deployment_manifest)
|
44
|
-
cloud_manifest = {}
|
45
|
-
CLOUD_MANIFEST_KEYS.each do |key|
|
46
|
-
cloud_manifest[key] = deployment_manifest[key] if deployment_manifest.has_key? key
|
47
|
-
end
|
48
|
-
cloud_manifest
|
49
|
-
end
|
50
|
-
|
51
31
|
def parse_name
|
52
32
|
safe_property(@deployment_manifest, 'name', :class => String)
|
53
33
|
end
|
@@ -74,64 +54,15 @@ module Bosh::Director
|
|
74
54
|
end
|
75
55
|
|
76
56
|
release_specs.each do |release_spec|
|
77
|
-
@deployment.add_release(ReleaseVersion.new(@deployment, release_spec))
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def parse_networks
|
82
|
-
networks = safe_property(@cloud_manifest, 'networks', :class => Array)
|
83
|
-
networks.each do |network_spec|
|
84
|
-
type = safe_property(network_spec, 'type', :class => String,
|
85
|
-
:default => 'manual')
|
86
|
-
|
87
|
-
case type
|
88
|
-
when 'manual'
|
89
|
-
network = ManualNetwork.new(@deployment, network_spec)
|
90
|
-
when 'dynamic'
|
91
|
-
network = DynamicNetwork.new(@deployment, network_spec)
|
92
|
-
when 'vip'
|
93
|
-
network = VipNetwork.new(@deployment, network_spec)
|
94
|
-
else
|
95
|
-
raise DeploymentInvalidNetworkType,
|
96
|
-
"Invalid network type `#{type}'"
|
97
|
-
end
|
98
|
-
|
99
|
-
@deployment.add_network(network)
|
100
|
-
end
|
101
|
-
|
102
|
-
if @deployment.networks.empty?
|
103
|
-
raise DeploymentNoNetworks, 'No networks specified'
|
57
|
+
@deployment.add_release(ReleaseVersion.new(@deployment.model, release_spec))
|
104
58
|
end
|
105
59
|
end
|
106
60
|
|
107
|
-
def parse_compilation
|
108
|
-
compilation_spec = safe_property(@cloud_manifest, 'compilation', :class => Hash)
|
109
|
-
@deployment.compilation = CompilationConfig.new(@deployment, compilation_spec)
|
110
|
-
end
|
111
|
-
|
112
61
|
def parse_update
|
113
62
|
update_spec = safe_property(@deployment_manifest, 'update', :class => Hash)
|
114
63
|
@deployment.update = UpdateConfig.new(update_spec)
|
115
64
|
end
|
116
65
|
|
117
|
-
def parse_resource_pools
|
118
|
-
resource_pools = safe_property(@cloud_manifest, 'resource_pools', :class => Array)
|
119
|
-
resource_pools.each do |rp_spec|
|
120
|
-
@deployment.add_resource_pool(ResourcePool.new(@deployment, rp_spec, @logger))
|
121
|
-
end
|
122
|
-
|
123
|
-
# Uncomment when integration test fixed
|
124
|
-
# raise "No resource pools specified." if @resource_pools.empty?
|
125
|
-
end
|
126
|
-
|
127
|
-
def parse_disk_pools
|
128
|
-
disk_pools = safe_property(@cloud_manifest, 'disk_pools', :class => Array, :optional => true)
|
129
|
-
return if disk_pools.nil?
|
130
|
-
disk_pools.each do |dp_spec|
|
131
|
-
@deployment.add_disk_pool(DiskPool.parse(dp_spec))
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
66
|
def parse_jobs
|
136
67
|
jobs = safe_property(@deployment_manifest, 'jobs', :class => Array, :default => [])
|
137
68
|
jobs.each do |job_spec|
|
@@ -23,7 +23,7 @@ module Bosh::Director
|
|
23
23
|
def initialize(deployment, network_spec)
|
24
24
|
super
|
25
25
|
@cloud_properties =
|
26
|
-
safe_property(network_spec, "cloud_properties", :
|
26
|
+
safe_property(network_spec, "cloud_properties", class: Hash, default: {})
|
27
27
|
|
28
28
|
@dns = dns_servers(network_spec["name"], network_spec)
|
29
29
|
end
|
@@ -88,4 +88,4 @@ module Bosh::Director
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
91
|
-
end
|
91
|
+
end
|