bosh-director 1.3122.0 → 1.3123.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: 7ec6dc203b602d57e98a511fff53b46b3400b02c
4
- data.tar.gz: e182a9575ff473028360ba30622614a0a85bdcbf
3
+ metadata.gz: 2a7c3216d881eaf691df4e7719c312a0b05e33bb
4
+ data.tar.gz: 2833073f1a613e9aa25ba4d87e41da1444393c31
5
5
  SHA512:
6
- metadata.gz: 5f20efc6d54acc5f57519c5106b00f6f5de0ecdf096a1b23104d644452f002b6b5be0ea80b6947bf8e6df505f75b312acfa0ffa067cecd665f9c5a7678359070
7
- data.tar.gz: 87b3ad7cc3812d3d8336c6e7c470513cc137af3131fd9e15bc509cb93ec93678b2e57b7024dfd15fc6b7caf10ece93362b6be754fb5c0c89dc69ec3d1f59a01b
6
+ metadata.gz: 23ff0c0f04f350def0e713a689a3e6d0662b4f9ab742ad8e031c8b8ce2417c4baa48d2eb0dfc485d4f613f65b47917e723410f39b894b6d20b335acec7784792
7
+ data.tar.gz: 1b0a899924443fac2c3584d401c1d0d9c67cf60f5219ed5e6a974c211cc206d631fed2a5d8eb52377a844da9512aa3ec86e767be38e4b269c1195fe4fce1748f
@@ -168,7 +168,11 @@ module Bosh::Director
168
168
  @deadline = Time.now.to_i + deadline
169
169
 
170
170
  begin
171
+ Config.job_cancelled?
171
172
  ping
173
+ rescue TaskCancelled => e
174
+ @logger.debug("Task was cancelled. Stop waiting response from vm")
175
+ raise e
172
176
  rescue RpcTimeout
173
177
  retry if @deadline - Time.now.to_i > 0
174
178
  raise RpcTimeout, "Timed out pinging to #{@client_id} after #{deadline} seconds"
@@ -7,7 +7,8 @@ module Bosh::Director
7
7
  payload = json_decode(request.body)
8
8
  options = {
9
9
  rebase: params['rebase'] == 'true',
10
- sha1: params['sha1']
10
+ fix: params['fix'] == 'true',
11
+ sha1: params['sha1']
11
12
  }
12
13
  task = @release_manager.create_release_from_url(current_user, payload['location'], options)
13
14
  redirect "/tasks/#{task.id}"
@@ -15,7 +16,8 @@ module Bosh::Director
15
16
 
16
17
  post '/', :consumes => :multipart do
17
18
  options = {
18
- rebase: params['rebase'] == 'true',
19
+ rebase: params['rebase'] == 'true',
20
+ fix: params['fix'] == 'true',
19
21
  }
20
22
 
21
23
  task = @release_manager.create_release_from_file_path(current_user, params[:nginx_upload_path], options)
@@ -22,6 +22,11 @@ module Bosh::Director
22
22
  blobstore_id
23
23
  end
24
24
 
25
+ def self.replace_blob(old_blobstore_id, path)
26
+ blobstore.delete(old_blobstore_id) if blobstore.exists?(old_blobstore_id)
27
+ return create_blob path
28
+ end
29
+
25
30
  def self.save_to_global_cache(compiled_package, cache_key)
26
31
  global_cache_filename = [compiled_package.package.name, cache_key].join('-')
27
32
  Dir.mktmpdir do |path|
@@ -51,6 +51,8 @@ module Bosh::Director
51
51
  agent_client(vm).wait_until_ready
52
52
  rescue Bosh::Director::RpcTimeout
53
53
  handler_error("Agent still unresponsive after reboot")
54
+ rescue Bosh::Director::TaskCancelled
55
+ handler_error("Task was cancelled")
54
56
  end
55
57
  end
56
58
 
@@ -166,8 +166,8 @@ module Bosh::Director
166
166
  configure_vm(vm, agent, network_settings)
167
167
  vm_data.agent = agent
168
168
  yield vm_data
169
- rescue RpcTimeout => e
170
- # if we time out waiting for the agent, we should clean up the the VM
169
+ rescue RpcTimeout, TaskCancelled => e
170
+ # if we time out waiting for the agent or task was cancelled, we should clean up the the VM
171
171
  # as it will leave us in an unrecoverable state otherwise
172
172
  @vm_reuser.remove_vm(vm_data)
173
173
  tear_down_vm(vm_data)
@@ -14,75 +14,24 @@ module Bosh::Director
14
14
  def initialize(dest, options={})
15
15
  @backup_file = dest
16
16
  @tar_gzipper = options.fetch(:tar_gzipper) { Core::TarGzipper.new }
17
- @blobstore_client = options.fetch(:blobstore) { App.instance.blobstores.blobstore }
18
17
  @db_adapter = options.fetch(:db_adapter) { Bosh::Director::DbBackup.create(Config.db_config) }
19
- @base_dir = options.fetch(:base_dir) { Config.base_dir }
20
- @log_dir = options.fetch(:log_dir) { Config.log_dir }
21
18
  end
22
19
 
23
20
  def perform
24
21
  Dir.mktmpdir do |tmp_output_dir|
25
22
  event_log.begin_stage('Backing up director', 4)
26
-
27
- files = []
28
-
29
- if @log_dir
30
- backup_logs("#{tmp_output_dir}/logs.tgz")
31
- files << 'logs.tgz'
32
- end
33
-
34
- backup_task_logs("#{tmp_output_dir}/task_logs.tgz")
35
- files << 'task_logs.tgz'
36
-
37
23
  backup_database("#{tmp_output_dir}/director_db.sql")
38
- files << 'director_db.sql'
39
-
40
- backup_blobstore("#{tmp_output_dir}/blobs.tgz")
41
- files << 'blobs.tgz'
42
-
43
- @tar_gzipper.compress(tmp_output_dir, files, @backup_file)
44
-
24
+ @tar_gzipper.compress(tmp_output_dir, 'director_db.sql', @backup_file)
45
25
  "Backup created at #{@backup_file}"
46
26
  end
47
27
  end
48
28
 
49
29
  private
50
- def backup_logs(output)
51
- track_and_log('Backing up logs') do
52
- @tar_gzipper.compress(File.dirname(@log_dir), [File.basename(@log_dir)], output, copy_first: true)
53
- end
54
- end
55
-
56
- def backup_task_logs(output)
57
- track_and_log('Backing up task logs') do
58
- @tar_gzipper.compress(@base_dir, %w(tasks), output, copy_first: true)
59
- end
60
- end
61
-
62
30
  def backup_database(output)
63
31
  track_and_log('Backing up database') do
64
32
  @db_adapter.export(output)
65
33
  end
66
34
  end
67
-
68
- def backup_blobstore(output)
69
- Dir.mktmpdir do |tmp_dir|
70
- Dir.mkdir(File.join(tmp_dir, 'blobs'))
71
-
72
- track_and_log('Backing up blobstore') do
73
- [Models::Package.all, Models::CompiledPackage.all, Models::Template.all].each do |packages|
74
- packages.each do |package|
75
- File.open(File.join(tmp_dir, 'blobs', package.blobstore_id), 'w') do |file|
76
- logger.debug("Writing file #{file.path}")
77
- @blobstore_client.get(package.blobstore_id, file)
78
- end
79
- end
80
- end
81
-
82
- @tar_gzipper.compress(tmp_dir, 'blobs', output)
83
- end
84
- end
85
- end
86
35
  end
87
36
  end
88
37
  end
@@ -28,7 +28,7 @@ module Bosh::Director
28
28
  def task_cancelled?
29
29
  return false if task_id.nil?
30
30
  task = task_manager.find_task(task_id)
31
- task && (task.state == 'cancelling' || task.state == 'timeout')
31
+ task && (task.state == 'cancelling' || task.state == 'timeout' || task.state == 'cancelled')
32
32
  end
33
33
 
34
34
  def task_checkpoint
@@ -33,6 +33,7 @@ module Bosh::Director
33
33
  @release_model, @release_version_model, @manifest, @name, @version = nil, nil, nil, nil, nil
34
34
 
35
35
  @rebase = !!options['rebase']
36
+ @fix = !!options['fix']
36
37
  end
37
38
 
38
39
  # Extracts release tarball, verifies release manifest and saves release in DB
@@ -328,7 +329,7 @@ module Bosh::Director
328
329
  end
329
330
  end
330
331
 
331
- if source_release && package.blobstore_id.nil?
332
+ if source_release && (package.blobstore_id.nil? || @fix)
332
333
  save_package_source_blob(package, package_meta, release_dir)
333
334
  package.save
334
335
  end
@@ -484,25 +485,42 @@ module Bosh::Director
484
485
 
485
486
  # @return [boolean] true if a new blob was created; false otherwise
486
487
  def save_package_source_blob(package, package_meta, release_dir)
487
- return false unless package.blobstore_id.nil?
488
-
489
- name, version, existing_blob = package_meta['name'], package_meta['version'], package_meta['blobstore_id']
488
+ name, version, existing_blob, sha1 = package_meta['name'], package_meta['version'], package_meta['blobstore_id'], package_meta['sha1']
490
489
  desc = "package '#{name}/#{version}'"
490
+ package_tgz = File.join(release_dir, 'packages', "#{name}.tgz")
491
+
492
+ if @fix
493
+ if package.blobstore_id != nil
494
+ logger.info("Verifying package #{desc} with blobstore_id: #{package.blobstore_id}")
495
+ validate_tgz(package_tgz, desc)
496
+ fix_package(package, package_tgz)
497
+ return true
498
+ end
499
+ package.sha1 = package_meta['sha1']
500
+
501
+ if existing_blob
502
+ pkg = Models::Package.where(blobstore_id: existing_blob).first
503
+ logger.info("Verifying package #{desc} with blobstore_id: #{existing_blob}")
504
+ fix_package(pkg, package_tgz)
505
+ package.blobstore_id = BlobUtil.copy_blob(pkg.blobstore_id)
506
+ return true
507
+ end
491
508
 
492
- package.sha1 = package_meta['sha1']
493
-
494
- if existing_blob
495
- logger.info("Creating #{desc} from existing blob #{existing_blob}")
496
- package.blobstore_id = BlobUtil.copy_blob(existing_blob)
497
-
498
- elsif package
499
- logger.info("Creating #{desc} from provided bits")
509
+ else
510
+ return false unless package.blobstore_id.nil?
511
+ package.sha1 = package_meta['sha1']
500
512
 
501
- package_tgz = File.join(release_dir, 'packages', "#{name}.tgz")
502
- validate_tgz(package_tgz, desc)
503
- package.blobstore_id = BlobUtil.create_blob(package_tgz)
513
+ if existing_blob
514
+ logger.info("Creating #{desc} from existing blob #{existing_blob}")
515
+ package.blobstore_id = BlobUtil.copy_blob(existing_blob)
516
+ return true
517
+ end
504
518
  end
505
519
 
520
+ logger.info("Creating #{desc} from provided bits")
521
+ validate_tgz(package_tgz, desc)
522
+ package.blobstore_id = BlobUtil.create_blob(package_tgz)
523
+
506
524
  true
507
525
  end
508
526
 
@@ -618,6 +636,13 @@ module Bosh::Director
618
636
  list = Bosh::Common::Version::ReleaseVersionList.parse(strings)
619
637
  list.rebase(@version)
620
638
  end
639
+
640
+ def fix_package(package, package_tgz)
641
+ single_step_stage("Fixing package '#{package.name}/#{package.version}'") do
642
+ logger.info("Fixing package '#{package.name}/#{package.version}'")
643
+ package.blobstore_id = BlobUtil.replace_blob(package.blobstore_id, package_tgz)
644
+ end
645
+ end
621
646
  end
622
647
  end
623
648
  end
@@ -50,7 +50,6 @@ module Bosh::Director
50
50
 
51
51
  vm_model = VmCreator.new.create(deployment, stemcell, @resource_pool.cloud_properties,
52
52
  vm.network_settings, nil, @resource_pool.env)
53
-
54
53
  agent = AgentClient.with_defaults(vm_model.agent_id)
55
54
  agent.wait_until_ready
56
55
  agent.update_settings(Config.trusted_certs)
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.3122.0'
3
+ VERSION = '1.3123.0'
4
4
  end
5
5
  end
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.3122.0
4
+ version: 1.3123.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-10-29 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,98 +16,98 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3122.0
19
+ version: 1.3123.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3122.0
26
+ version: 1.3123.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bosh_cpi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3122.0
33
+ version: 1.3123.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.3122.0
40
+ version: 1.3123.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bosh-registry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3122.0
47
+ version: 1.3123.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.3122.0
54
+ version: 1.3123.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: blobstore_client
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.3122.0
61
+ version: 1.3123.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.3122.0
68
+ version: 1.3123.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bosh-core
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.3122.0
75
+ version: 1.3123.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.3122.0
82
+ version: 1.3123.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bosh-director-core
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.3122.0
89
+ version: 1.3123.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.3122.0
96
+ version: 1.3123.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bosh-template
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.3122.0
103
+ version: 1.3123.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.3122.0
110
+ version: 1.3123.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bosh_openstack_cpi
113
113
  requirement: !ruby/object:Gem::Requirement