bosh-director 1.3008.0 → 1.3010.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6fa18d5307ac8eea26fb86273257a05d6e0edad
4
- data.tar.gz: 6e46d6b78536fecf443426d2c0eb1cb974d14140
3
+ metadata.gz: b7440bb5c715a87559c7e85a3589112ae363aab3
4
+ data.tar.gz: 80ff5c4ae767140b2e667976fd7f275c92514ac8
5
5
  SHA512:
6
- metadata.gz: a4a65aed66263dc6ce7c757a688a42ac24946d0f77813acf21a6aaa1a10368cb09a4962d3bce0cb3cb83575331d3862ac7f39ceafaad90f7cbcbaa5f62dd1354
7
- data.tar.gz: b5bb429aa4467bb3e79b0b2cb5ef03e5d110546c2ebb3cd40cc439f80acd018ec8dba1b6973bdee8319797f1b52001bf0118d032911deddd45ffdb67148b3dab
6
+ metadata.gz: 9d7f086a7fc1aeed44528a34dec18617bd6997276190db8b81d2940478db3a2934792954a675844d69daf48918f9e6b8ea0d78c91ec85fdf0e963179cbe9fd1f
7
+ data.tar.gz: 0455fd62dc5e4c7ca0762233a9ad5f5377b755af45d18264a685a31c8acc998175d0b196cadfc04fca9cf793398994add8c380b5972e92b6bfb20d3736db0ee1
@@ -67,7 +67,7 @@ module Bosh::Director
67
67
  }
68
68
 
69
69
  deployment = @deployment_manager.find_by_name(params[:deployment])
70
- manifest = request.content_length.nil? ? StringIO.new(deployment.manifest) : request.body
70
+ manifest = (request.content_length.nil? || request.content_length == 0) ? StringIO.new(deployment.manifest) : request.body
71
71
  latest_cloud_config = Bosh::Director::Api::CloudConfigManager.new.latest
72
72
  task = @deployment_manager.create_deployment(current_user, manifest, latest_cloud_config, options)
73
73
  redirect "/tasks/#{task.id}"
@@ -114,6 +114,7 @@ module Bosh::Director
114
114
  JobIncompatibleSpecs = err(80010)
115
115
  JobPackageCollision = err(80011)
116
116
  JobInvalidPackageSpec = err(80012)
117
+ JobInvalidLinkSpec = err(80013)
117
118
 
118
119
  ResourceError = err(100001)
119
120
  ResourceNotFound = err(100002, NOT_FOUND)
@@ -0,0 +1,159 @@
1
+ module Bosh::Director
2
+ class ReleaseJob
3
+ def initialize(job_meta, release_model, release_dir, packages, logger)
4
+ @name = job_meta['name']
5
+ @version = job_meta['version']
6
+ @sha1 = job_meta['sha1']
7
+ @fingerprint = job_meta['fingerprint']
8
+
9
+ @packages = packages
10
+ @release_model = release_model
11
+ @release_dir = release_dir
12
+ @logger = logger
13
+ end
14
+
15
+ def create
16
+ template = create_template
17
+ unpack
18
+
19
+ job_manifest = load_manifest
20
+ validate_templates(job_manifest)
21
+ validate_monit
22
+
23
+ template.blobstore_id = BlobUtil.create_blob(job_tgz)
24
+ template.package_names = parse_package_names(job_manifest)
25
+
26
+ validate_logs(job_manifest)
27
+ template.logs = job_manifest['logs'] if job_manifest['logs']
28
+
29
+ validate_properties(job_manifest)
30
+ template.properties = job_manifest['properties'] if job_manifest['properties']
31
+
32
+ validate_links(job_manifest)
33
+
34
+ template.save
35
+ end
36
+
37
+ private
38
+
39
+ def unpack
40
+ FileUtils.mkdir_p(job_dir)
41
+
42
+ desc = "job `#{@name}/#{@version}'"
43
+ result = Bosh::Exec.sh("tar -C #{job_dir} -xzf #{job_tgz} 2>&1", :on_error => :return)
44
+ if result.failed?
45
+ @logger.error("Extracting #{desc} archive failed in dir #{job_dir}, " +
46
+ "tar returned #{result.exit_status}, " +
47
+ "output: #{result.output}")
48
+ raise JobInvalidArchive, "Extracting #{desc} archive failed. Check task debug log for details."
49
+ end
50
+ end
51
+
52
+ def job_tgz
53
+ @job_tgz ||= File.join(@release_dir, 'jobs', "#{@name}.tgz")
54
+ end
55
+
56
+ def job_dir
57
+ @job_dir ||= File.join(@release_dir, 'jobs', @name)
58
+ end
59
+
60
+ def create_template
61
+ template_attrs = {
62
+ :release => @release_model,
63
+ :name => @name,
64
+ :sha1 => @sha1,
65
+ :fingerprint => @fingerprint,
66
+ :version => @version
67
+ }
68
+
69
+ @logger.info("Creating job template `#{@name}/#{@version}' " +
70
+ 'from provided bits')
71
+ Models::Template.new(template_attrs)
72
+ end
73
+
74
+
75
+ def load_manifest
76
+ manifest_file = File.join(job_dir, 'job.MF')
77
+ unless File.file?(manifest_file)
78
+ raise JobMissingManifest,
79
+ "Missing job manifest for `#{@name}'"
80
+ end
81
+
82
+ Psych.load_file(manifest_file)
83
+ end
84
+
85
+ def validate_templates(job_manifest)
86
+ if job_manifest['templates']
87
+ job_manifest['templates'].each_key do |relative_path|
88
+ path = File.join(job_dir, 'templates', relative_path)
89
+ unless File.file?(path)
90
+ raise JobMissingTemplateFile,
91
+ "Missing template file `#{relative_path}' for job `#{@name}'"
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ def validate_monit
98
+ main_monit_file = File.join(job_dir, 'monit')
99
+ aux_monit_files = Dir.glob(File.join(job_dir, '*.monit'))
100
+
101
+ unless File.exists?(main_monit_file) || aux_monit_files.size > 0
102
+ raise JobMissingMonit, "Job `#{@name}' is missing monit file"
103
+ end
104
+ end
105
+
106
+ def parse_package_names(job_manifest)
107
+ package_names = []
108
+ if job_manifest['packages']
109
+ unless job_manifest['packages'].is_a?(Array)
110
+ raise JobInvalidPackageSpec,
111
+ "Job `#{@name}' has invalid package spec format"
112
+ end
113
+
114
+ job_manifest['packages'].each do |package_name|
115
+ package = @packages[package_name]
116
+ if package.nil?
117
+ raise JobMissingPackage,
118
+ "Job `#{@name}' is referencing " +
119
+ "a missing package `#{package_name}'"
120
+ end
121
+ package_names << package.name
122
+ end
123
+ end
124
+ package_names
125
+ end
126
+
127
+ def validate_logs(job_manifest)
128
+ if job_manifest['logs']
129
+ unless job_manifest['logs'].is_a?(Hash)
130
+ raise JobInvalidLogSpec,
131
+ "Job `#{@name}' has invalid logs spec format"
132
+ end
133
+ end
134
+ end
135
+
136
+ def validate_properties(job_manifest)
137
+ if job_manifest['properties']
138
+ unless job_manifest['properties'].is_a?(Hash)
139
+ raise JobInvalidPropertySpec,
140
+ "Job `#{@name}' has invalid properties spec format"
141
+ end
142
+ end
143
+ end
144
+
145
+ def validate_links(job_manifest)
146
+ if job_manifest['provides']
147
+ if !job_manifest['provides'].is_a?(Array) || job_manifest['provides'].find { |p| !p.is_a?(String) }
148
+ raise JobInvalidLinkSpec, "Job `#{@name}' has invalid spec format: 'provides' needs to be an array of strings"
149
+ end
150
+ end
151
+
152
+ if job_manifest['requires']
153
+ if !job_manifest['requires'].is_a?(Array) || job_manifest['requires'].find { |p| !p.is_a?(String) }
154
+ raise JobInvalidLinkSpec, "Job `#{@name}' has invalid spec format: 'requires' needs to be an array of strings"
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
@@ -382,99 +382,8 @@ module Bosh::Director
382
382
  end
383
383
 
384
384
  def create_job(job_meta, release_dir)
385
- name, version = job_meta["name"], job_meta["version"]
386
-
387
- template_attrs = {
388
- :release => @release_model,
389
- :name => name,
390
- :sha1 => job_meta["sha1"],
391
- :fingerprint => job_meta["fingerprint"],
392
- :version => version
393
- }
394
-
395
- logger.info("Creating job template `#{name}/#{version}' " +
396
- "from provided bits")
397
- template = Models::Template.new(template_attrs)
398
-
399
- job_tgz = File.join(release_dir, "jobs", "#{name}.tgz")
400
- job_dir = File.join(release_dir, "jobs", "#{name}")
401
-
402
- FileUtils.mkdir_p(job_dir)
403
-
404
- desc = "job `#{name}/#{version}'"
405
- result = Bosh::Exec.sh("tar -C #{job_dir} -xzf #{job_tgz} 2>&1", :on_error => :return)
406
- if result.failed?
407
- logger.error("Extracting #{desc} archive failed in dir #{job_dir}, " +
408
- "tar returned #{result.exit_status}, " +
409
- "output: #{result.output}")
410
- raise JobInvalidArchive, "Extracting #{desc} archive failed. Check task debug log for details."
411
- end
412
-
413
- manifest_file = File.join(job_dir, "job.MF")
414
- unless File.file?(manifest_file)
415
- raise JobMissingManifest,
416
- "Missing job manifest for `#{template.name}'"
417
- end
418
-
419
- job_manifest = Psych.load_file(manifest_file)
420
-
421
- if job_manifest["templates"]
422
- job_manifest["templates"].each_key do |relative_path|
423
- path = File.join(job_dir, "templates", relative_path)
424
- unless File.file?(path)
425
- raise JobMissingTemplateFile,
426
- "Missing template file `#{relative_path}' for job `#{template.name}'"
427
- end
428
- end
429
- end
430
-
431
- main_monit_file = File.join(job_dir, "monit")
432
- aux_monit_files = Dir.glob(File.join(job_dir, "*.monit"))
433
-
434
- unless File.exists?(main_monit_file) || aux_monit_files.size > 0
435
- raise JobMissingMonit, "Job `#{template.name}' is missing monit file"
436
- end
437
-
438
- template.blobstore_id = BlobUtil.create_blob(job_tgz)
439
-
440
- package_names = []
441
- if job_manifest["packages"]
442
- unless job_manifest["packages"].is_a?(Array)
443
- raise JobInvalidPackageSpec,
444
- "Job `#{template.name}' has invalid package spec format"
445
- end
446
-
447
- job_manifest["packages"].each do |package_name|
448
- package = @packages[package_name]
449
- if package.nil?
450
- raise JobMissingPackage,
451
- "Job `#{template.name}' is referencing " +
452
- "a missing package `#{package_name}'"
453
- end
454
- package_names << package.name
455
- end
456
- end
457
- template.package_names = package_names
458
-
459
- if job_manifest["logs"]
460
- unless job_manifest["logs"].is_a?(Hash)
461
- raise JobInvalidLogSpec,
462
- "Job `#{template.name}' has invalid logs spec format"
463
- end
464
-
465
- template.logs = job_manifest["logs"]
466
- end
467
-
468
- if job_manifest["properties"]
469
- unless job_manifest["properties"].is_a?(Hash)
470
- raise JobInvalidPropertySpec,
471
- "Job `#{template.name}' has invalid properties spec format"
472
- end
473
-
474
- template.properties = job_manifest["properties"]
475
- end
476
-
477
- template.save
385
+ release_job = ReleaseJob.new(job_meta, @release_model, release_dir, @packages, logger)
386
+ release_job.create
478
387
  end
479
388
 
480
389
  # @param [Array<Array>] jobs Existing jobs metadata
@@ -37,7 +37,7 @@ module Bosh::Director
37
37
  end
38
38
 
39
39
  resolution :ignore do
40
- plan { "Ignore problem" }
40
+ plan { "Skip for now" }
41
41
  action { }
42
42
  end
43
43
 
@@ -31,7 +31,7 @@ module Bosh::Director
31
31
  end
32
32
 
33
33
  resolution :ignore do
34
- plan { 'Ignore problem' }
34
+ plan { 'Skip for now' }
35
35
  action { }
36
36
  end
37
37
 
@@ -13,17 +13,17 @@ module Bosh::Director
13
13
  end
14
14
 
15
15
  resolution :ignore do
16
- plan { "Ignore problem" }
16
+ plan { "Skip for now" }
17
17
  action { }
18
18
  end
19
19
 
20
20
  resolution :recreate_vm do
21
- plan { "Recreate VM using last known apply spec" }
21
+ plan { "Recreate VM" }
22
22
  action { recreate_vm(@vm) }
23
23
  end
24
24
 
25
25
  resolution :delete_vm_reference do
26
- plan { "Delete VM reference (DANGEROUS!)" }
26
+ plan { "Delete VM reference" }
27
27
  action { delete_vm_reference(@vm, skip_cid_check: true) }
28
28
  end
29
29
 
@@ -32,4 +32,4 @@ module Bosh::Director
32
32
  end
33
33
  end
34
34
  end
35
- end
35
+ end
@@ -37,7 +37,7 @@ module Bosh::Director
37
37
  end
38
38
 
39
39
  resolution :ignore do
40
- plan { "Ignore problem" }
40
+ plan { "Skip for now" }
41
41
  action { }
42
42
  end
43
43
 
@@ -34,7 +34,7 @@ module Bosh::Director
34
34
  end
35
35
 
36
36
  resolution :ignore do
37
- plan { "Ignore problem" }
37
+ plan { "Skip for now" }
38
38
  action { }
39
39
  end
40
40
 
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Director
4
2
  module ProblemHandlers
5
3
  class UnresponsiveAgent < Base
@@ -25,23 +23,23 @@ module Bosh::Director
25
23
  end
26
24
 
27
25
  resolution :ignore do
28
- plan { "Ignore problem" }
26
+ plan { 'Skip for now' }
29
27
  action { }
30
28
  end
31
29
 
32
30
  resolution :reboot_vm do
33
- plan { "Reboot VM" }
31
+ plan { 'Reboot VM' }
34
32
  action { validate; ensure_cid; reboot_vm(@vm) }
35
33
  end
36
34
 
37
35
  resolution :recreate_vm do
38
- plan { "Recreate VM using last known apply spec" }
36
+ plan { 'Recreate VM' }
39
37
  action { validate; ensure_cid; recreate_vm(@vm) }
40
38
  end
41
39
 
42
40
  resolution :delete_vm_reference do
43
- plan { "Delete VM reference (DANGEROUS!)" }
44
- action { validate; ensure_no_cid; delete_vm_reference(@vm) }
41
+ plan { 'Delete VM reference (forceful; may need to manually delete VM from the Cloud to avoid IP conflicts)' }
42
+ action { validate; delete_vm_reference(@vm, skip_cid_check: true) }
45
43
  end
46
44
 
47
45
  def agent_alive?
@@ -54,20 +52,20 @@ module Bosh::Director
54
52
  def ensure_cid
55
53
  if @vm.cid.nil?
56
54
  handler_error("VM `#{@vm.id}' doesn't have a cloud id, " +
57
- "only resolution is to delete the VM reference.")
55
+ 'only resolution is to delete the VM reference.')
58
56
  end
59
57
  end
60
58
 
61
59
  def ensure_no_cid
62
60
  if @vm.cid
63
61
  handler_error("VM `#{@vm.id}' has a cloud id, " +
64
- "please use a different resolution.")
62
+ 'please use a different resolution.')
65
63
  end
66
64
  end
67
65
 
68
66
  def validate
69
67
  if agent_alive?
70
- handler_error("Agent is responding now, skipping resolution")
68
+ handler_error('Agent is responding now, skipping resolution')
71
69
  end
72
70
  end
73
71
 
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.3008.0'
3
+ VERSION = '1.3010.0'
4
4
  end
5
5
  end
data/lib/bosh/director.rb CHANGED
@@ -122,6 +122,7 @@ require 'bosh/director/jobs/run_errand'
122
122
  require 'bosh/director/jobs/cloud_check/scan'
123
123
  require 'bosh/director/jobs/cloud_check/scan_and_fix'
124
124
  require 'bosh/director/jobs/cloud_check/apply_resolutions'
125
+ require 'bosh/director/jobs/release/release_job'
125
126
  require 'bosh/director/jobs/ssh'
126
127
 
127
128
  require 'bosh/director/models/helpers/model_helper'
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.3008.0
4
+ version: 1.3010.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-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-06 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.3008.0
33
+ version: 1.3010.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.3008.0
40
+ version: 1.3010.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.3008.0
47
+ version: 1.3010.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.3008.0
54
+ version: 1.3010.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.3008.0
61
+ version: 1.3010.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.3008.0
68
+ version: 1.3010.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.3008.0
75
+ version: 1.3010.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.3008.0
82
+ version: 1.3010.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.3008.0
89
+ version: 1.3010.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.3008.0
96
+ version: 1.3010.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.3008.0
103
+ version: 1.3010.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.3008.0
110
+ version: 1.3010.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.3008.0
117
+ version: 1.3010.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.3008.0
124
+ version: 1.3010.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.3008.0
131
+ version: 1.3010.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.3008.0
138
+ version: 1.3010.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.3008.0
145
+ version: 1.3010.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.3008.0
152
+ version: 1.3010.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: bosh_vcloud_cpi
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -572,7 +572,7 @@ dependencies:
572
572
  version: '0'
573
573
  description: |-
574
574
  BOSH Director
575
- cfb32d
575
+ 1dcc8d
576
576
  email: support@cloudfoundry.com
577
577
  executables:
578
578
  - bosh-director
@@ -770,6 +770,7 @@ files:
770
770
  - lib/bosh/director/jobs/export_release.rb
771
771
  - lib/bosh/director/jobs/fetch_logs.rb
772
772
  - lib/bosh/director/jobs/import_compiled_packages.rb
773
+ - lib/bosh/director/jobs/release/release_job.rb
773
774
  - lib/bosh/director/jobs/run_errand.rb
774
775
  - lib/bosh/director/jobs/scheduled_backup.rb
775
776
  - lib/bosh/director/jobs/snapshot_deployment.rb