bosh-director 1.3048.0 → 1.3050.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: 99e55b602be5167be9b84464a78041c5062b3a6b
4
- data.tar.gz: 50a15495b6c79bba2264981fa4fe07158d6456ed
3
+ metadata.gz: 21b3597db4028e01b8fe540f0a551c60f2b0e06f
4
+ data.tar.gz: 5069ad495cd05d71565b6b31cf6a9f68219a8e6e
5
5
  SHA512:
6
- metadata.gz: 16088e13da325245d18e3f0c45983f1fd288459acb7411475c15a4a7a141b6ae53a62a774ee4b93ccd768e6a987f544e8d16f0956e79884762e484777b53a6a7
7
- data.tar.gz: 2ec85bdee426f93026360a03aac14b8b86dca556ce2f60ce6e55f29d3861ab5dbb500c401a4c4e42c193edd366597b9ff2a0f999bbff86efe272d2ccbe1ca0ce
6
+ metadata.gz: 560901cbd41cc4b0b9a56322797301f7a6e5b1c892a78e763c60fd2df739be8984a076eaf677daeaaaf6f7a27bc4c1100af98e84cd09bc1ea2363f7c28d99218
7
+ data.tar.gz: 2e1da9546ec0ad35a8d7e33c60638498e882959d8d9626861adbd290b9402a8f820ec379e772f5c1e89eb9a7a797f8fd663a97903a666947e1cc5f10c70ec2e8
@@ -16,7 +16,25 @@ module Bosh::Director
16
16
  fingerprint_list << package['fingerprint'] if package['fingerprint']
17
17
  end
18
18
 
19
- matching_packages = Models::Package.where(fingerprint: fingerprint_list).all
19
+ matching_packages = Models::Package.where(fingerprint: fingerprint_list, ~:sha1 => nil, ~:blobstore_id => nil).all
20
+
21
+ json_encode(matching_packages.map(&:fingerprint).compact.uniq)
22
+ end
23
+
24
+ post '/matches_compiled', :consumes => :yaml do
25
+ manifest = Psych.load(request.body)
26
+
27
+ unless manifest.is_a?(Hash) && manifest['compiled_packages'].is_a?(Array)
28
+ raise BadManifest, "Manifest doesn't have a usable packages section"
29
+ end
30
+
31
+ fingerprint_list = []
32
+
33
+ manifest['compiled_packages'].each do |package|
34
+ fingerprint_list << package['fingerprint'] if package['fingerprint']
35
+ end
36
+
37
+ matching_packages = Models::Package.join(Models::CompiledPackage, :package_id=>:id).where(fingerprint: fingerprint_list).all
20
38
 
21
39
  json_encode(matching_packages.map(&:fingerprint).compact.uniq)
22
40
  end
@@ -7,7 +7,6 @@ module Bosh::Director
7
7
  payload = json_decode(request.body)
8
8
  options = {
9
9
  rebase: params['rebase'] == 'true',
10
- skip_if_exists: params['skip_if_exists'] == 'true',
11
10
  }
12
11
  task = @release_manager.create_release_from_url(current_user, payload['location'], options)
13
12
  redirect "/tasks/#{task.id}"
@@ -129,7 +128,7 @@ module Bosh::Director
129
128
  'blobstore_id' => package.blobstore_id,
130
129
  'sha1' => package.sha1,
131
130
  'fingerprint' => package.fingerprint.to_s,
132
- 'compiled_packages' => package.compiled_packages.sort_by { |cp| cp.stemcell }.map do |compiled|
131
+ 'compiled_packages' => package.compiled_packages.sort_by { |cp| [cp.stemcell.name, cp.stemcell.version] }.map do |compiled|
133
132
  {
134
133
  'stemcell' => "#{compiled.stemcell.name}/#{compiled.stemcell.version}",
135
134
  'sha1' => compiled.sha1,
@@ -12,10 +12,6 @@ module Bosh
12
12
  controllers = {}
13
13
  controllers['/backups'] = Bosh::Director::Api::Controllers::BackupsController.new(@config)
14
14
  controllers['/cloud_configs'] = Bosh::Director::Api::Controllers::CloudConfigsController.new(@config)
15
- controllers['/compiled_package_groups'] = Bosh::Director::Api::Controllers::CompiledPackagesController.new(
16
- @config,
17
- Bosh::Director::Api::CompiledPackageGroupManager.new
18
- )
19
15
  controllers['/deployments'] = Bosh::Director::Api::Controllers::DeploymentsController.new(@config)
20
16
  controllers['/info'] = Bosh::Director::Api::Controllers::InfoController.new(@config)
21
17
  controllers['/locks'] = Bosh::Director::Api::Controllers::LocksController.new(@config)
@@ -19,7 +19,6 @@ require 'bosh/director/api/release_manager'
19
19
  require 'bosh/director/api/resource_manager'
20
20
  require 'bosh/director/api/snapshot_manager'
21
21
  require 'bosh/director/api/stemcell_manager'
22
- require 'bosh/director/api/compiled_package_group_manager'
23
22
  require 'bosh/director/api/task_manager'
24
23
  require 'bosh/director/api/user/config_user_manager'
25
24
  require 'bosh/director/api/user/database_user_manager'
@@ -56,32 +56,6 @@ module Bosh
56
56
  assemble_without_vm_binding(attrs, deployment_manifest, cloud_manifest, deployment_model, cloud_config, options)
57
57
  end
58
58
 
59
- def self.validate_packages(planner, options)
60
- release_manager = Bosh::Director::Api::ReleaseManager.new
61
- planner.jobs.each { |job|
62
- job.templates.each{ |template|
63
- release_model = release_manager.find_by_name(template.release.name)
64
- template.package_models.each{ |package|
65
-
66
- release_version_model = release_manager.find_version(release_model, template.release.version)
67
- packages_list = release_version_model.transitive_dependencies(package)
68
- packages_list << package
69
-
70
- packages_list.each { |needed_package|
71
- if needed_package.sha1.nil? || needed_package.blobstore_id.nil?
72
- compiled_packages_list = Bosh::Director::Models::CompiledPackage[:package_id => needed_package.id, :stemcell_id => job.resource_pool.stemcell.model.id]
73
- if compiled_packages_list.nil?
74
- msg = "Can't #{options[:context]} `#{release_version_model.release.name}/#{release_version_model.version}': it is not " +
75
- "compiled for `#{job.resource_pool.stemcell.model.desc}' and no source package is available"
76
- raise PackageMissingSourceCode, msg
77
- end
78
- end
79
- }
80
- }
81
- }
82
- }
83
- end
84
-
85
59
  private
86
60
 
87
61
  def deployment_name(manifest_hash)
@@ -121,7 +95,7 @@ module Bosh
121
95
 
122
96
  run_prepare_step(assembler)
123
97
 
124
- self.class.validate_packages(planner, {:context => 'deploy'})
98
+ validate_packages(planner)
125
99
 
126
100
  DeploymentPlan::Steps::PackageCompileStep.new(
127
101
  planner,
@@ -138,6 +112,46 @@ module Bosh
138
112
  planner
139
113
  end
140
114
 
115
+ def validate_packages(planner)
116
+ faults = {}
117
+ release_manager = Bosh::Director::Api::ReleaseManager.new
118
+ planner.jobs.each { |job|
119
+ job.templates.each{ |template|
120
+ release_model = release_manager.find_by_name(template.release.name)
121
+ template.package_models.each{ |package|
122
+
123
+ release_version_model = release_manager.find_version(release_model, template.release.version)
124
+ packages_list = release_version_model.transitive_dependencies(package)
125
+ packages_list << package
126
+
127
+ release_desc = "#{release_version_model.release.name}/#{release_version_model.version}"
128
+
129
+ packages_list.each { |needed_package|
130
+ if needed_package.sha1.nil? || needed_package.blobstore_id.nil?
131
+ compiled_packages_list = Bosh::Director::Models::CompiledPackage[:package_id => needed_package.id, :stemcell_id => job.resource_pool.stemcell.model.id]
132
+ if compiled_packages_list.nil?
133
+ (faults[release_desc] ||= []) << {:package => needed_package, :stemcell => job.resource_pool.stemcell.model}
134
+ end
135
+ end
136
+ }
137
+ }
138
+ }
139
+ }
140
+ handle_faults(faults) unless faults.empty?
141
+ end
142
+
143
+ def handle_faults(faults)
144
+ msg = "\n"
145
+ faults.each { |release_desc, packages_and_stemcells_list|
146
+ msg += "\nCan't deploy release `#{release_desc}'. It references packages (see below) without source code and are not compiled against intended stemcells:\n"
147
+ sorted_packages_and_stemcells = packages_and_stemcells_list.sort_by { |p| p[:package].name }
148
+ sorted_packages_and_stemcells.each { |item|
149
+ msg += " - `#{item[:package].name}/#{item[:package].version}' against `#{item[:stemcell].desc}'\n"
150
+ }
151
+ }
152
+ raise PackageMissingSourceCode, msg
153
+ end
154
+
141
155
  def run_prepare_step(assembler)
142
156
  @event_log.begin_stage('Preparing deployment', 9)
143
157
  @logger.info('Preparing deployment')
@@ -74,6 +74,7 @@ module Bosh::Director
74
74
  ReleaseDeleteFailed = err(30009)
75
75
  ReleaseVersionInvalid = err(30010)
76
76
  ReleaseNotMatchingManifest = err(30011)
77
+ ReleaseInvalidPackage = err(30012)
77
78
 
78
79
  ValidationInvalidType = err(40000)
79
80
  ValidationMissingField = err(40001)
@@ -63,7 +63,7 @@ module Bosh::Director
63
63
  package.remove_release_version(release_version)
64
64
  end
65
65
 
66
- event_log.begin_stage("Deleting templates", templates_to_delete.count)
66
+ event_log.begin_stage("Deleting jobs", templates_to_delete.count)
67
67
  templates_to_delete.each do |template|
68
68
  track_and_log("#{template.name}/#{template.version}") do
69
69
  logger.info("Template #{template.name}/#{template.version} " +
@@ -74,7 +74,7 @@ module Bosh::Director
74
74
  end
75
75
 
76
76
  templates_to_keep.each do |template|
77
- logger.info("Keeping template " +
77
+ logger.info("Keeping job " +
78
78
  "#{template.name}/#{template.version} as it is used " +
79
79
  "by other release versions")
80
80
  template.remove_release_version(release_version)
@@ -100,7 +100,7 @@ module Bosh::Director
100
100
  end
101
101
  end
102
102
 
103
- event_log.begin_stage("Deleting templates", release.templates.count)
103
+ event_log.begin_stage("Deleting jobs", release.templates.count)
104
104
  release.templates.each do |template|
105
105
  track_and_log("#{template.name}/#{template.version}") do
106
106
  delete_template(template)
@@ -145,7 +145,7 @@ module Bosh::Director
145
145
  end
146
146
 
147
147
  def delete_template(template)
148
- logger.info("Deleting template: #{template.name}/#{template.version}")
148
+ logger.info("Deleting job: #{template.name}/#{template.version}")
149
149
 
150
150
  if delete_blobstore_id(template.blobstore_id)
151
151
  template.remove_all_release_versions
@@ -2,6 +2,7 @@ require 'securerandom'
2
2
  require 'common/version/release_version'
3
3
  require 'bosh/director/compiled_release_downloader'
4
4
  require 'bosh/director/compiled_release_manifest'
5
+ require 'bosh/director/compiled_package_group'
5
6
 
6
7
  module Bosh::Director
7
8
  module Jobs
@@ -40,17 +41,18 @@ module Bosh::Director
40
41
  @release_version_model = release_manager.find_version(release, @release_version)
41
42
 
42
43
  unless deployment_manifest_has_release?
43
- raise ReleaseNotMatchingManifest, "Release #{@release_name}/#{@release_version} not found in deployment #{@deployment_name} manifest"
44
+ raise ReleaseNotMatchingManifest, "Release version `#{@release_name}/#{@release_version}' not found in deployment `#{@deployment_name}' manifest"
44
45
  end
45
46
 
47
+ validate_release_packages
48
+
46
49
  lock_timeout = 15 * 60 # 15 minutes
47
50
 
48
51
  with_deployment_lock(@deployment_name, :timeout => lock_timeout) do
49
52
  with_release_lock(@release_name, :timeout => lock_timeout) do
50
53
  with_stemcell_lock(@stemcell.name, @stemcell.version, :timeout => lock_timeout) do
51
54
 
52
- planner = create_planner
53
- DeploymentPlan::PlannerFactory.validate_packages(planner, {:context => 'export'})
55
+ planner = create_planner(stemcell_manager)
54
56
  package_compile_step = DeploymentPlan::Steps::PackageCompileStep.new(
55
57
  planner,
56
58
  Config.cloud, # CPI
@@ -69,6 +71,8 @@ module Bosh::Director
69
71
  "Exported release: #{@release_name}/#{@release_version} for #{@stemcell_os}/#{@stemcell_version}"
70
72
  end
71
73
 
74
+ private
75
+
72
76
  def deployment_manifest_has_release?
73
77
  @deployment_manifest["releases"].each do |release|
74
78
  if (release["name"] == @release_name) && (release["version"].to_s == @release_version.to_s)
@@ -78,7 +82,7 @@ module Bosh::Director
78
82
  false
79
83
  end
80
84
 
81
- def create_planner
85
+ def create_planner(stemcell_manager)
82
86
  cloud_config_model = @targeted_deployment.cloud_config
83
87
 
84
88
  planner_factory = DeploymentPlan::PlannerFactory.create(Config.event_log, Config.logger)
@@ -102,6 +106,24 @@ module Bosh::Director
102
106
  fake_job = create_fake_job(planner, fake_resource_pool_manifest, network_name)
103
107
  planner.add_job(fake_job)
104
108
 
109
+ assembler = DeploymentPlan::Assembler.new(
110
+ planner,
111
+ stemcell_manager,
112
+ Config.cloud,
113
+ nil, # blobstore not used for this assembler purposes
114
+ @logger,
115
+ @event_log
116
+ )
117
+ @logger.info('Created deployment plan')
118
+
119
+ track_and_log('Binding existing deployment') do
120
+ assembler.bind_existing_deployment
121
+ end
122
+
123
+ track_and_log('Binding resource pools') do
124
+ assembler.bind_resource_pools
125
+ end
126
+
105
127
  planner
106
128
  end
107
129
 
@@ -154,7 +176,33 @@ module Bosh::Director
154
176
  fake_job
155
177
  end
156
178
 
179
+ def validate_release_packages
180
+ faults = Set.new
181
+ @release_version_model.packages.each do |package|
182
+ packages_list = @release_version_model.transitive_dependencies(package)
183
+ packages_list << package
184
+
185
+ packages_list.each { |needed_package|
186
+ if needed_package.sha1.nil? || needed_package.blobstore_id.nil?
187
+ compiled_packages_list = Bosh::Director::Models::CompiledPackage[:package_id => needed_package.id, :stemcell_id => @stemcell.id]
188
+ if compiled_packages_list.nil?
189
+ faults << needed_package
190
+ end
191
+ end
192
+ }
193
+ end
194
+
195
+ unless faults.empty?
196
+ sorted_faults = faults.to_a.sort_by { |p| p.name }
197
+ msg = "Can't export release `#{@release_name}/#{@release_version}'. It references packages without" +
198
+ " source code that are not compiled against `#{@stemcell.desc}':\n"
199
+ sorted_faults.each do |non_compiled_package|
200
+ msg += " - #{non_compiled_package.name}/#{non_compiled_package.version}\n"
201
+ end
202
+ raise PackageMissingSourceCode, msg
203
+ end
204
+ end
205
+
157
206
  end
158
207
  end
159
208
  end
160
-