Class: Bosh::Director::Jobs::DeleteRelease

Inherits:
BaseJob show all
Includes:
LockHelper
Defined in:
lib/bosh/director/jobs/delete_release.rb

Instance Attribute Summary

Attributes inherited from BaseJob

#task_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LockHelper

#with_compile_lock, #with_deployment_lock, #with_release_lock, #with_release_locks, #with_stemcell_lock

Methods inherited from BaseJob

#begin_stage, #dns_manager, #event_manager, #logger, perform, #result_file, schedule_message, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log, #username

Constructor Details

#initialize(name, options = {}) ⇒ DeleteRelease

Returns a new instance of DeleteRelease.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bosh/director/jobs/delete_release.rb', line 12

def initialize(name, options = {})
  @name = name
  @force = !!options['force']
  @version = options['version']

  blobstore = options.fetch(:blobstore) { App.instance.blobstores.blobstore }
  blob_deleter = Helpers::BlobDeleter.new(blobstore, logger)
  compiled_package_deleter = Helpers::CompiledPackageDeleter.new(blob_deleter, logger)
  package_deleter = Helpers::PackageDeleter.new(compiled_package_deleter, blob_deleter, logger)
  template_deleter = Helpers::TemplateDeleter.new(blob_deleter, logger)
  release_deleter = Helpers::ReleaseDeleter.new(package_deleter, template_deleter, Config.event_log, logger)
  release_version_deleter =
    Helpers::ReleaseVersionDeleter.new(release_deleter, package_deleter, template_deleter, logger, Config.event_log)
  release_manager = Api::ReleaseManager.new
  @name_version_release_deleter = Helpers::NameVersionReleaseDeleter.new(release_deleter, release_manager, release_version_deleter, logger)
end

Class Method Details

.job_typeObject



8
9
10
# File 'lib/bosh/director/jobs/delete_release.rb', line 8

def self.job_type
  :delete_release
end

Instance Method Details

#performObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bosh/director/jobs/delete_release.rb', line 29

def perform
  logger.info('Processing delete release')

  errors = nil

  with_release_lock(@name, :timeout => 10) do
    errors = @name_version_release_deleter.find_and_delete_release(@name, @version, @force)
  end

  unless errors.empty?
    error_strings = errors.map { |e| e.to_s }.join(', ')
    raise ReleaseDeleteFailed, "Can't delete release: #{error_strings}"
  end

  "/release/#{@name}"
end