bosh-director 1.3173.0 → 1.3177.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/db/migrations/director/20151229184742_add_vm_attributes_to_instance.rb +25 -0
- data/db/migrations/director/20160108191637_drop_vm_env_json_from_instance.rb +7 -0
- data/lib/bosh/director/api/controllers/base_controller.rb +1 -1
- data/lib/bosh/director/api/controllers/deployments_controller.rb +1 -1
- data/lib/bosh/director/api/deployment_manager.rb +10 -12
- data/lib/bosh/director/api/instance_manager.rb +5 -6
- data/lib/bosh/director/api/snapshot_manager.rb +1 -2
- data/lib/bosh/director/cloudcheck_helper.rb +30 -52
- data/lib/bosh/director/config.rb +2 -1
- data/lib/bosh/director/deployment_deleter.rb +0 -21
- data/lib/bosh/director/deployment_plan.rb +1 -1
- data/lib/bosh/director/deployment_plan/agent_state_migrator.rb +7 -19
- data/lib/bosh/director/deployment_plan/assembler.rb +6 -30
- data/lib/bosh/director/deployment_plan/compilation_instance_pool.rb +2 -4
- data/lib/bosh/director/deployment_plan/dynamic_network.rb +1 -1
- data/lib/bosh/director/deployment_plan/instance.rb +6 -46
- data/lib/bosh/director/deployment_plan/instance_network_reservations.rb +13 -13
- data/lib/bosh/director/deployment_plan/instance_plan.rb +3 -3
- data/lib/bosh/director/deployment_plan/instance_plan_factory.rb +12 -4
- data/lib/bosh/director/deployment_plan/instance_planner.rb +5 -4
- data/lib/bosh/director/deployment_plan/instance_repository.rb +7 -14
- data/lib/bosh/director/deployment_plan/instance_spec.rb +2 -2
- data/lib/bosh/director/deployment_plan/ip_provider/database_ip_repo.rb +7 -7
- data/lib/bosh/director/deployment_plan/ip_provider/in_memory_ip_repo.rb +6 -3
- data/lib/bosh/director/deployment_plan/ip_provider/ip_provider.rb +4 -4
- data/lib/bosh/director/deployment_plan/job.rb +0 -7
- data/lib/bosh/director/deployment_plan/job_migrator.rb +3 -2
- data/lib/bosh/director/deployment_plan/manual_network_subnet.rb +1 -1
- data/lib/bosh/director/deployment_plan/network_planner/planner.rb +2 -2
- data/lib/bosh/director/deployment_plan/network_reservation_repository.rb +20 -0
- data/lib/bosh/director/deployment_plan/placement_planner/static_ips_availability_zone_picker.rb +2 -1
- data/lib/bosh/director/deployment_plan/planner.rb +2 -17
- data/lib/bosh/director/deployment_plan/steps/package_compile_step.rb +1 -1
- data/lib/bosh/director/deployment_plan/steps/update_step.rb +1 -21
- data/lib/bosh/director/disk_manager.rb +8 -8
- data/lib/bosh/director/dns/dns_manager.rb +76 -20
- data/lib/bosh/director/errand/job_manager.rb +1 -1
- data/lib/bosh/director/instance_deleter.rb +1 -3
- data/lib/bosh/director/instance_updater.rb +4 -3
- data/lib/bosh/director/job_updater.rb +10 -2
- data/lib/bosh/director/jobs/base_job.rb +1 -1
- data/lib/bosh/director/jobs/cloud_check/scan_and_fix.rb +3 -3
- data/lib/bosh/director/jobs/create_snapshot.rb +1 -1
- data/lib/bosh/director/jobs/delete_deployment.rb +1 -1
- data/lib/bosh/director/jobs/delete_deployment_snapshots.rb +1 -1
- data/lib/bosh/director/jobs/snapshot_deployment.rb +2 -2
- data/lib/bosh/director/jobs/vm_state.rb +16 -17
- data/lib/bosh/director/models.rb +0 -1
- data/lib/bosh/director/models/deployment.rb +0 -3
- data/lib/bosh/director/models/instance.rb +17 -10
- data/lib/bosh/director/network_reservation.rb +15 -16
- data/lib/bosh/director/problem_handlers/inactive_disk.rb +4 -6
- data/lib/bosh/director/problem_handlers/missing_disk.rb +3 -5
- data/lib/bosh/director/problem_handlers/missing_vm.rb +8 -10
- data/lib/bosh/director/problem_handlers/mount_info_mismatch.rb +8 -3
- data/lib/bosh/director/problem_handlers/unresponsive_agent.rb +14 -29
- data/lib/bosh/director/problem_scanner/disk_scan_stage.rb +1 -4
- data/lib/bosh/director/problem_scanner/problem_register.rb +2 -4
- data/lib/bosh/director/problem_scanner/scanner.rb +1 -1
- data/lib/bosh/director/problem_scanner/vm_scan_stage.rb +17 -35
- data/lib/bosh/director/stopper.rb +2 -2
- data/lib/bosh/director/version.rb +1 -1
- data/lib/bosh/director/vm_creator.rb +15 -33
- data/lib/bosh/director/vm_deleter.rb +6 -8
- data/lib/bosh/director/vm_metadata_updater.rb +5 -7
- data/lib/bosh/director/vm_recreator.rb +3 -2
- metadata +19 -18
- data/lib/bosh/director/deployment_plan/vm.rb +0 -22
- data/lib/bosh/director/models/vm.rb +0 -38
@@ -36,10 +36,10 @@ module Bosh::Director
|
|
36
36
|
resolver = ProblemResolver.new(@deployment)
|
37
37
|
resolver.apply_resolutions(resolutions(jobs))
|
38
38
|
|
39
|
-
|
39
|
+
'scan and fix complete'
|
40
40
|
end
|
41
41
|
rescue Lock::TimeoutError
|
42
|
-
raise
|
42
|
+
raise 'Unable to get deployment lock, maybe a deployment is in progress. Try again later.'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -48,7 +48,7 @@ module Bosh::Director
|
|
48
48
|
jobs.each do |job, index|
|
49
49
|
instance = @instance_manager.find_by_name(@deployment.name, job, index)
|
50
50
|
next if instance.resurrection_paused
|
51
|
-
problems = Models::DeploymentProblem.filter(deployment: @deployment, resource_id: instance.
|
51
|
+
problems = Models::DeploymentProblem.filter(deployment: @deployment, resource_id: instance.id, state: 'open')
|
52
52
|
problems.each do |problem|
|
53
53
|
if problem.type == 'unresponsive_agent' || problem.type == 'missing_vm'
|
54
54
|
all_resolutions[problem.id.to_s] = :recreate_vm
|
@@ -14,7 +14,7 @@ module Bosh::Director
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def perform
|
17
|
-
logger.info("taking snapshot of: #{@instance.job}/#{@instance.index} (#{@instance.
|
17
|
+
logger.info("taking snapshot of: #{@instance.job}/#{@instance.index} (#{@instance.vm_cid})")
|
18
18
|
snapshot_cids = Bosh::Director::Api::SnapshotManager.take_snapshot(@instance, @options)
|
19
19
|
"snapshot(s) #{snapshot_cids.join(', ')} created"
|
20
20
|
end
|
@@ -25,7 +25,7 @@ module Bosh::Director
|
|
25
25
|
|
26
26
|
ip_provider = DeploymentPlan::IpProviderFactory.new(true, logger)
|
27
27
|
|
28
|
-
dns_manager =
|
28
|
+
dns_manager = DnsManagerProvider.create
|
29
29
|
disk_manager = DiskManager.new(@cloud, logger)
|
30
30
|
instance_deleter = InstanceDeleter.new(ip_provider, dns_manager, disk_manager, force: @force)
|
31
31
|
deployment_deleter = DeploymentDeleter.new(event_log, logger, dns_manager, Config.max_threads)
|
@@ -22,7 +22,7 @@ module Bosh::Director
|
|
22
22
|
deployment.job_instances.each do |instance|
|
23
23
|
snapshots = instance.persistent_disks.map { |disk| disk.snapshots }.flatten
|
24
24
|
if snapshots.any?
|
25
|
-
logger.info("deleting snapshots of: #{instance.job}/#{instance.index} (#{instance.
|
25
|
+
logger.info("deleting snapshots of: #{instance.job}/#{instance.index} (#{instance.vm_cid})")
|
26
26
|
Bosh::Director::Api::SnapshotManager.delete_snapshots(snapshots)
|
27
27
|
end
|
28
28
|
end
|
@@ -31,11 +31,11 @@ module Bosh::Director
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def snapshot(instance)
|
34
|
-
logger.info("taking snapshot of: #{instance.job}/#{instance.index} (#{instance.
|
34
|
+
logger.info("taking snapshot of: #{instance.job}/#{instance.index} (#{instance.vm_cid})")
|
35
35
|
Bosh::Director::Api::SnapshotManager.take_snapshot(instance, @options)
|
36
36
|
rescue Bosh::Clouds::CloudError => e
|
37
37
|
@errors += 1
|
38
|
-
logger.error("failed to take snapshot of: #{instance.job}/#{instance.index} (#{instance.
|
38
|
+
logger.error("failed to take snapshot of: #{instance.job}/#{instance.index} (#{instance.vm_cid}) - #{e.inspect}")
|
39
39
|
send_alert(instance, e.inspect)
|
40
40
|
end
|
41
41
|
|
@@ -15,11 +15,11 @@ module Bosh::Director
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def perform
|
18
|
-
|
18
|
+
instances = Models::Instance.filter(:deployment_id => @deployment_id).exclude(vm_cid: nil)
|
19
19
|
ThreadPool.new(:max_threads => Config.max_threads).wrap do |pool|
|
20
|
-
|
20
|
+
instances.each do |instance|
|
21
21
|
pool.process do
|
22
|
-
vm_state =
|
22
|
+
vm_state = process_instance(instance)
|
23
23
|
result_file.write(vm_state.to_json + "\n")
|
24
24
|
end
|
25
25
|
end
|
@@ -29,7 +29,7 @@ module Bosh::Director
|
|
29
29
|
nil
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def process_instance(instance)
|
33
33
|
ips = []
|
34
34
|
dns_records = []
|
35
35
|
job_state = nil
|
@@ -37,7 +37,7 @@ module Bosh::Director
|
|
37
37
|
processes = []
|
38
38
|
|
39
39
|
begin
|
40
|
-
agent = AgentClient.with_vm_credentials_and_agent_id(
|
40
|
+
agent = AgentClient.with_vm_credentials_and_agent_id(instance.credentials, instance.agent_id, :timeout => TIMEOUT)
|
41
41
|
agent_state = agent.get_state(@format)
|
42
42
|
agent_state['networks'].each_value do |network|
|
43
43
|
ips << network['ip']
|
@@ -53,30 +53,29 @@ module Bosh::Director
|
|
53
53
|
end
|
54
54
|
|
55
55
|
if dns_manager.dns_enabled?
|
56
|
-
dns_records = dns_manager.find_dns_record_names_by_instance(
|
56
|
+
dns_records = dns_manager.find_dns_record_names_by_instance(instance)
|
57
57
|
dns_records.sort_by! { |name| -(name.split('.').first.length) }
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
vm_type_name = vm_apply_spec && vm_apply_spec['vm_type'] ? vm_apply_spec['vm_type']['name'] : nil
|
60
|
+
vm_type_name = instance.spec && instance.spec['vm_type'] ? instance.spec['vm_type']['name'] : nil
|
62
61
|
|
63
62
|
{
|
64
|
-
:vm_cid =>
|
65
|
-
:disk_cid =>
|
63
|
+
:vm_cid => instance.vm_cid,
|
64
|
+
:disk_cid => instance.persistent_disk_cid,
|
66
65
|
:ips => ips,
|
67
66
|
:dns => dns_records,
|
68
|
-
:agent_id =>
|
69
|
-
:job_name =>
|
70
|
-
:index =>
|
67
|
+
:agent_id => instance.agent_id,
|
68
|
+
:job_name => instance.job,
|
69
|
+
:index => instance.index,
|
71
70
|
:job_state => job_state,
|
72
71
|
:resource_pool => vm_type_name,
|
73
72
|
:vm_type => vm_type_name,
|
74
73
|
:vitals => job_vitals,
|
75
74
|
:processes => processes,
|
76
|
-
:resurrection_paused =>
|
77
|
-
:az =>
|
78
|
-
:id =>
|
79
|
-
:bootstrap =>
|
75
|
+
:resurrection_paused => instance.resurrection_paused,
|
76
|
+
:az => instance.availability_zone,
|
77
|
+
:id => instance.uuid,
|
78
|
+
:bootstrap => instance.bootstrap
|
80
79
|
}
|
81
80
|
end
|
82
81
|
|
data/lib/bosh/director/models.rb
CHANGED
@@ -20,7 +20,6 @@ require 'bosh/director/models/snapshot'
|
|
20
20
|
require 'bosh/director/models/task'
|
21
21
|
require 'bosh/director/models/template'
|
22
22
|
require 'bosh/director/models/user'
|
23
|
-
require 'bosh/director/models/vm'
|
24
23
|
require 'bosh/director/models/persistent_disk'
|
25
24
|
require 'bosh/director/models/rendered_templates_archive'
|
26
25
|
|
@@ -1,11 +1,8 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
module Bosh::Director::Models
|
4
2
|
class Deployment < Sequel::Model(Bosh::Director::Config.db)
|
5
3
|
many_to_many :stemcells
|
6
4
|
many_to_many :release_versions
|
7
5
|
one_to_many :job_instances, :class => "Bosh::Director::Models::Instance"
|
8
|
-
one_to_many :vms
|
9
6
|
one_to_many :instances
|
10
7
|
one_to_many :properties, :class => "Bosh::Director::Models::DeploymentProperty"
|
11
8
|
one_to_many :problems, :class => "Bosh::Director::Models::DeploymentProblem"
|
@@ -3,7 +3,6 @@ require 'securerandom'
|
|
3
3
|
module Bosh::Director::Models
|
4
4
|
class Instance < Sequel::Model(Bosh::Director::Config.db)
|
5
5
|
many_to_one :deployment
|
6
|
-
many_to_one :vm
|
7
6
|
one_to_many :persistent_disks
|
8
7
|
one_to_many :rendered_templates_archives
|
9
8
|
one_to_many :ip_addresses
|
@@ -12,7 +11,6 @@ module Bosh::Director::Models
|
|
12
11
|
def validate
|
13
12
|
validates_presence [:deployment_id, :job, :index, :state]
|
14
13
|
validates_unique [:deployment_id, :job, :index]
|
15
|
-
validates_unique [:vm_id] if vm_id
|
16
14
|
validates_integer :index
|
17
15
|
validates_includes %w(started stopped detached), :state
|
18
16
|
end
|
@@ -64,7 +62,7 @@ module Bosh::Director::Models
|
|
64
62
|
end
|
65
63
|
|
66
64
|
def to_s
|
67
|
-
"#{self.job}/#{self.
|
65
|
+
"#{self.job}/#{self.index} (#{self.uuid})"
|
68
66
|
end
|
69
67
|
|
70
68
|
def spec
|
@@ -96,13 +94,22 @@ module Bosh::Director::Models
|
|
96
94
|
self.spec_json = Yajl::Encoder.encode(spec)
|
97
95
|
end
|
98
96
|
|
99
|
-
def
|
100
|
-
if
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
97
|
+
def vm_env
|
98
|
+
return {} if spec.nil?
|
99
|
+
spec['env'] || {}
|
100
|
+
end
|
101
|
+
|
102
|
+
def vm_env=(vm_env_hash)
|
103
|
+
self.spec = (spec || {}).merge(env: vm_env_hash)
|
104
|
+
end
|
105
|
+
|
106
|
+
def credentials
|
107
|
+
return nil if credentials_json.nil?
|
108
|
+
Yajl::Parser.parse(credentials_json)
|
109
|
+
end
|
110
|
+
|
111
|
+
def credentials=(spec)
|
112
|
+
self.credentials_json = Yajl::Encoder.encode(spec)
|
106
113
|
end
|
107
114
|
end
|
108
115
|
|
@@ -2,10 +2,10 @@ module Bosh::Director
|
|
2
2
|
class NetworkReservation
|
3
3
|
include IpUtil
|
4
4
|
|
5
|
-
attr_reader :ip, :
|
5
|
+
attr_reader :ip, :instance_model, :network, :type
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(instance_model, network)
|
8
|
+
@instance_model = instance_model
|
9
9
|
@network = network
|
10
10
|
@ip = nil
|
11
11
|
@reserved = false
|
@@ -41,8 +41,8 @@ module Bosh::Director
|
|
41
41
|
class ExistingNetworkReservation < NetworkReservation
|
42
42
|
attr_reader :network_type
|
43
43
|
|
44
|
-
def initialize(
|
45
|
-
super(
|
44
|
+
def initialize(instance_model, network, ip, network_type)
|
45
|
+
super(instance_model, network)
|
46
46
|
@ip = ip_to_i(ip) if ip
|
47
47
|
@network_type = network_type
|
48
48
|
end
|
@@ -52,26 +52,25 @@ module Bosh::Director
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def desc
|
55
|
-
"existing reservation#{@ip.nil? ? '' : " with IP '#{formatted_ip}' for instance #{@
|
55
|
+
"existing reservation#{@ip.nil? ? '' : " with IP '#{formatted_ip}' for instance #{@instance_model}"}"
|
56
56
|
end
|
57
57
|
|
58
58
|
def to_s
|
59
|
-
"{ip=#{formatted_ip}, network=#{@network.name}, instance=#{@
|
59
|
+
"{ip=#{formatted_ip}, network=#{@network.name}, instance=#{@instance_model}, reserved=#{reserved?}, type=#{type}}"
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
class DesiredNetworkReservation < NetworkReservation
|
64
|
-
def self.new_dynamic(
|
65
|
-
new(
|
64
|
+
def self.new_dynamic(instance_model, network)
|
65
|
+
new(instance_model, network, nil, :dynamic)
|
66
66
|
end
|
67
67
|
|
68
|
-
def self.new_static(
|
69
|
-
new(
|
68
|
+
def self.new_static(instance_model, network, ip)
|
69
|
+
new(instance_model, network, ip, :static)
|
70
70
|
end
|
71
71
|
|
72
|
-
def initialize(
|
73
|
-
|
74
|
-
@network = network
|
72
|
+
def initialize(instance_model, network, ip, type)
|
73
|
+
super(instance_model, network)
|
75
74
|
@ip = ip_to_i(ip) if ip
|
76
75
|
@type = type
|
77
76
|
end
|
@@ -90,11 +89,11 @@ module Bosh::Director
|
|
90
89
|
end
|
91
90
|
|
92
91
|
def desc
|
93
|
-
"#{type} reservation with IP '#{formatted_ip}' for instance #{@
|
92
|
+
"#{type} reservation with IP '#{formatted_ip}' for instance #{@instance_model}"
|
94
93
|
end
|
95
94
|
|
96
95
|
def to_s
|
97
|
-
"{type=#{type}, ip=#{formatted_ip}, network=#{@network.name}, instance=#{@
|
96
|
+
"{type=#{type}, ip=#{formatted_ip}, network=#{@network.name}, instance=#{@instance_model}}"
|
98
97
|
end
|
99
98
|
end
|
100
99
|
end
|
@@ -25,8 +25,6 @@ module Bosh::Director
|
|
25
25
|
if @instance.nil?
|
26
26
|
handler_error("Cannot find instance for disk `#{@disk.disk_cid}'")
|
27
27
|
end
|
28
|
-
|
29
|
-
@vm = @instance.vm
|
30
28
|
end
|
31
29
|
|
32
30
|
def description
|
@@ -72,9 +70,9 @@ module Bosh::Director
|
|
72
70
|
handler_error("Disk is currently in use")
|
73
71
|
end
|
74
72
|
|
75
|
-
if @
|
73
|
+
if @instance.vm_cid
|
76
74
|
begin
|
77
|
-
cloud.detach_disk(@
|
75
|
+
cloud.detach_disk(@instance.vm_cid, @disk.disk_cid)
|
78
76
|
rescue => e
|
79
77
|
# We are going to delete this disk anyway
|
80
78
|
# and we know it's not in use, so we can ignore
|
@@ -87,8 +85,8 @@ module Bosh::Director
|
|
87
85
|
end
|
88
86
|
|
89
87
|
def disk_mounted?
|
90
|
-
return false
|
91
|
-
agent_timeout_guard(@
|
88
|
+
return false unless @instance.vm_cid
|
89
|
+
agent_timeout_guard(@instance.vm_cid, @instance.credentials, @instance.agent_id) do |agent|
|
92
90
|
agent.list_disk.include?(@disk.disk_cid)
|
93
91
|
end
|
94
92
|
end
|
@@ -19,8 +19,6 @@ module Bosh::Director
|
|
19
19
|
if @instance.nil?
|
20
20
|
handler_error("Cannot find instance for disk `#{@disk.disk_cid}'")
|
21
21
|
end
|
22
|
-
|
23
|
-
@vm = @instance.vm
|
24
22
|
end
|
25
23
|
|
26
24
|
def description
|
@@ -44,8 +42,8 @@ module Bosh::Director
|
|
44
42
|
@disk.update(active: false)
|
45
43
|
|
46
44
|
# If VM is present we try to unmount and detach disk from VM
|
47
|
-
if @
|
48
|
-
agent_client = agent_client(@
|
45
|
+
if @instance.vm_cid && cloud.has_vm?(@instance.vm_cid)
|
46
|
+
agent_client = agent_client(@instance.credentials, @instance.agent_id)
|
49
47
|
disk_list = []
|
50
48
|
|
51
49
|
begin
|
@@ -67,7 +65,7 @@ module Bosh::Director
|
|
67
65
|
|
68
66
|
begin
|
69
67
|
@logger.debug('Sending cpi request: detach_disk')
|
70
|
-
cloud.detach_disk(@
|
68
|
+
cloud.detach_disk(@instance.vm_cid, @disk.disk_cid) if @instance.vm_cid
|
71
69
|
rescue Bosh::Clouds::DiskNotAttached, Bosh::Clouds::DiskNotFound
|
72
70
|
end
|
73
71
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
module Bosh::Director
|
4
2
|
module ProblemHandlers
|
5
3
|
class MissingVM < Base
|
@@ -7,28 +5,28 @@ module Bosh::Director
|
|
7
5
|
register_as :missing_vm
|
8
6
|
auto_resolution :recreate_vm
|
9
7
|
|
10
|
-
def initialize(
|
8
|
+
def initialize(instance_id, data)
|
11
9
|
super
|
12
|
-
@
|
10
|
+
@instance = Models::Instance.find(id: instance_id)
|
13
11
|
end
|
14
12
|
|
15
13
|
resolution :ignore do
|
16
|
-
plan {
|
14
|
+
plan { 'Skip for now' }
|
17
15
|
action { }
|
18
16
|
end
|
19
17
|
|
20
18
|
resolution :recreate_vm do
|
21
|
-
plan { "Recreate VM for '#{@
|
22
|
-
action { recreate_vm(@
|
19
|
+
plan { "Recreate VM for '#{@instance}'" }
|
20
|
+
action { recreate_vm(@instance) }
|
23
21
|
end
|
24
22
|
|
25
23
|
resolution :delete_vm_reference do
|
26
|
-
plan {
|
27
|
-
action { delete_vm_reference(@
|
24
|
+
plan { 'Delete VM reference' }
|
25
|
+
action { delete_vm_reference(@instance) }
|
28
26
|
end
|
29
27
|
|
30
28
|
def description
|
31
|
-
"VM with cloud ID `#{@
|
29
|
+
"VM with cloud ID `#{@instance.vm_cid}' missing."
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -16,11 +16,10 @@ module Bosh::Director
|
|
16
16
|
end
|
17
17
|
|
18
18
|
@disk_cid = @disk.disk_cid
|
19
|
-
@vm_cid = @disk.instance.
|
19
|
+
@vm_cid = @disk.instance.vm_cid if @disk.instance
|
20
20
|
handler_error("Can't find corresponding vm-cid for disk `#{@disk_cid}'") if @vm_cid.nil?
|
21
21
|
|
22
22
|
@instance = @disk.instance
|
23
|
-
@vm = @instance.vm
|
24
23
|
|
25
24
|
@disk_owners = @data['owner_vms']
|
26
25
|
end
|
@@ -55,7 +54,13 @@ module Bosh::Director
|
|
55
54
|
|
56
55
|
def reattach_disk(reboot = false)
|
57
56
|
cloud.attach_disk(@vm_cid, @disk_cid)
|
58
|
-
reboot
|
57
|
+
if reboot
|
58
|
+
reboot_vm(@instance)
|
59
|
+
else
|
60
|
+
agent_timeout_guard(@instance.vm_cid, @instance.credentials, @instance.agent_id) do |agent|
|
61
|
+
agent.mount_disk(@disk_cid)
|
62
|
+
end
|
63
|
+
end
|
59
64
|
end
|
60
65
|
end
|
61
66
|
end
|
@@ -5,21 +5,21 @@ module Bosh::Director
|
|
5
5
|
register_as :unresponsive_agent
|
6
6
|
auto_resolution :ignore
|
7
7
|
|
8
|
-
def initialize(
|
8
|
+
def initialize(instance_id, data)
|
9
9
|
super
|
10
|
-
@
|
10
|
+
@instance = Models::Instance.find(id: instance_id)
|
11
11
|
|
12
|
-
|
13
|
-
handler_error("VM `#{
|
12
|
+
unless @instance.vm_cid
|
13
|
+
handler_error("VM `#{@instance.vm_cid}' is no longer in the database")
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
handler_error("VM `#{
|
16
|
+
unless @instance.agent_id
|
17
|
+
handler_error("VM `#{@instance.agent_id}' doesn't have an agent id")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def description
|
22
|
-
"#{
|
22
|
+
"#{@instance} (#{@instance.vm_cid}) is not responding"
|
23
23
|
end
|
24
24
|
|
25
25
|
resolution :ignore do
|
@@ -29,48 +29,33 @@ module Bosh::Director
|
|
29
29
|
|
30
30
|
resolution :reboot_vm do
|
31
31
|
plan { 'Reboot VM' }
|
32
|
-
action { validate;
|
32
|
+
action { validate; reboot_vm(@instance) }
|
33
33
|
end
|
34
34
|
|
35
35
|
resolution :recreate_vm do
|
36
|
-
plan { "Recreate VM for '#{@
|
37
|
-
action { validate;
|
36
|
+
plan { "Recreate VM for '#{@instance}'" }
|
37
|
+
action { validate; recreate_vm(@instance) }
|
38
38
|
end
|
39
39
|
|
40
40
|
resolution :delete_vm_reference do
|
41
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(@
|
42
|
+
action { validate; delete_vm_reference(@instance) }
|
43
43
|
end
|
44
44
|
|
45
|
+
private
|
46
|
+
|
45
47
|
def agent_alive?
|
46
|
-
agent_client(@
|
48
|
+
agent_client(@instance.credentials, @instance.agent_id).ping
|
47
49
|
true
|
48
50
|
rescue Bosh::Director::RpcTimeout
|
49
51
|
false
|
50
52
|
end
|
51
53
|
|
52
|
-
def ensure_cid
|
53
|
-
if @vm.cid.nil?
|
54
|
-
handler_error("VM `#{@vm.id}' doesn't have a cloud id, " +
|
55
|
-
'only resolution is to delete the VM reference.')
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def ensure_no_cid
|
60
|
-
if @vm.cid
|
61
|
-
handler_error("VM `#{@vm.id}' has a cloud id, " +
|
62
|
-
'please use a different resolution.')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
54
|
def validate
|
67
55
|
if agent_alive?
|
68
56
|
handler_error('Agent is responding now, skipping resolution')
|
69
57
|
end
|
70
58
|
end
|
71
|
-
|
72
|
-
def delete_vm
|
73
|
-
end
|
74
59
|
end
|
75
60
|
end
|
76
61
|
end
|