bosh-director 1.2606.0 → 1.2611.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,6 @@ module Bosh::Director
5
5
  include LockHelper
6
6
  include IpUtil
7
7
 
8
- # @param [DeploymentPlan] deployment_plan Deployment plan
9
8
  def initialize(deployment_plan)
10
9
  @deployment_plan = deployment_plan
11
10
  @cloud = Config.cloud
@@ -115,23 +114,31 @@ module Bosh::Director
115
114
  end
116
115
  end
117
116
 
118
- # Does the job instance exist in the new deployment?
119
- if (job = @deployment_plan.job(instance_model.job)) &&
120
- (instance = job.instance(instance_model.index))
117
+ instance_name = "#{instance_model.job}/#{instance_model.index}"
121
118
 
122
- @logger.debug('Found job and instance spec')
123
- instance.use_model(instance_model)
124
- instance.current_state = state
125
-
126
- @logger.debug('Copying network reservations')
127
- instance.take_network_reservations(reservations)
119
+ job = @deployment_plan.job(instance_model.job)
120
+ unless job
121
+ @logger.debug("Job '#{instance_model.job}' not found, marking for deletion")
122
+ @deployment_plan.delete_instance(instance_model)
123
+ return
124
+ end
128
125
 
129
- @logger.debug('Copying resource pool reservation')
130
- job.resource_pool.mark_active_vm
131
- else
132
- @logger.debug('Job/instance not found, marking for deletion')
126
+ instance = job.instance(instance_model.index)
127
+ unless instance
128
+ @logger.debug("Job instance #{instance_name} not found, marking for deletion")
133
129
  @deployment_plan.delete_instance(instance_model)
130
+ return
134
131
  end
132
+
133
+ @logger.debug("Found job instance #{instance_name}")
134
+ instance.use_model(instance_model)
135
+ instance.current_state = state
136
+
137
+ @logger.debug("Copying job instance #{instance_name} network reservations")
138
+ instance.take_network_reservations(reservations)
139
+
140
+ @logger.debug("Copying job instance #{instance_name} resource pool reservation")
141
+ job.resource_pool.mark_active_vm
135
142
  end
136
143
 
137
144
  def get_network_reservations(state)
@@ -35,6 +35,9 @@ module Bosh::Director
35
35
  # @return [Integer] Number of active resource pool VMs
36
36
  attr_reader :active_vm_count
37
37
 
38
+ # @return [Integer] Number of VMs reserved
39
+ attr_reader :reserved_capacity
40
+
38
41
  # @param [DeploymentPlan] deployment_plan Deployment plan
39
42
  # @param [Hash] spec Raw resource pool spec from the deployment manifest
40
43
  def initialize(deployment_plan, spec)
@@ -63,8 +66,8 @@ module Bosh::Director
63
66
  @idle_vms = []
64
67
  @allocated_vms = []
65
68
  @active_vm_count = 0
66
- @required_capacity = 0
67
- @errand_capacity = 0
69
+ @reserved_capacity = 0
70
+ @reserved_errand_capacity = 0
68
71
  end
69
72
 
70
73
  # Returns resource pools spec as Hash (usually for agent to serialize)
@@ -101,13 +104,6 @@ module Bosh::Director
101
104
  reservation
102
105
  end
103
106
 
104
- # Returns a number of VMs that need to be created in order to bring
105
- # this resource pool to a desired size
106
- # @return [Integer]
107
- def missing_vm_count
108
- @size - @active_vm_count - @idle_vms.size
109
- end
110
-
111
107
  # Adds a new VM to a list of managed idle VMs
112
108
  def add_idle_vm
113
109
  idle_vm = IdleVm.new(self)
@@ -134,27 +130,43 @@ module Bosh::Director
134
130
  @active_vm_count += 1
135
131
  end
136
132
 
137
- # Checks if there is enough capacity to run extra N VMs,
133
+ # Checks if there is enough capacity to run _extra_ N VMs,
138
134
  # raise error if not enough capacity
139
135
  # @raise [ResourcePoolNotEnoughCapacity]
140
136
  # @return [void]
141
137
  def reserve_capacity(n)
142
- @required_capacity += n
143
- if @required_capacity > @size
138
+ needed = @reserved_capacity + n
139
+ if needed > @size
144
140
  raise ResourcePoolNotEnoughCapacity,
145
141
  "Resource pool `#{@name}' is not big enough: " +
146
- "#{@required_capacity} VMs needed, capacity is #{@size}"
142
+ "#{needed} VMs needed, capacity is #{@size}"
147
143
  end
144
+ @reserved_capacity = needed
148
145
  end
149
146
 
147
+ # Checks if there is enough capacity to run _up to_ N VMs,
148
+ # raise error if not enough capacity.
149
+ # Only enough capacity to run the largest errand is required,
150
+ # because errands can only run one at a time.
151
+ # @raise [ResourcePoolNotEnoughCapacity]
152
+ # @return [void]
150
153
  def reserve_errand_capacity(n)
151
- needed = n - @errand_capacity
154
+ needed = n - @reserved_errand_capacity
152
155
 
153
156
  if needed > 0
154
157
  reserve_capacity(needed)
155
- @errand_capacity = n
158
+ @reserved_errand_capacity = n
156
159
  end
157
160
  end
161
+
162
+ private
163
+
164
+ # Returns a number of VMs that need to be created in order to bring
165
+ # this resource pool to a desired size
166
+ # @return [Integer]
167
+ def missing_vm_count
168
+ @size - @active_vm_count - @idle_vms.size
169
+ end
158
170
  end
159
171
  end
160
172
  end
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.2606.0'
3
+ VERSION = '1.2611.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2606.0
4
+ version: 1.2611.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-13 00:00:00.000000000 Z
12
+ date: 2014-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bcrypt-ruby
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.2606.0
37
+ version: 1.2611.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.2606.0
45
+ version: 1.2611.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bosh-core
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 1.2606.0
53
+ version: 1.2611.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2606.0
61
+ version: 1.2611.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh-director-core
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 1.2606.0
69
+ version: 1.2611.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 1.2606.0
77
+ version: 1.2611.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bosh_common
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.2606.0
85
+ version: 1.2611.0
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.2606.0
93
+ version: 1.2611.0
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: bosh_cpi
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 1.2606.0
101
+ version: 1.2611.0
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.2606.0
109
+ version: 1.2611.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: bosh_openstack_cpi
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2606.0
117
+ version: 1.2611.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.2606.0
125
+ version: 1.2611.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: bosh_aws_cpi
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 1.2606.0
133
+ version: 1.2611.0
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 1.2606.0
141
+ version: 1.2611.0
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: bosh_vsphere_cpi
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +146,7 @@ dependencies:
146
146
  requirements:
147
147
  - - ~>
148
148
  - !ruby/object:Gem::Version
149
- version: 1.2606.0
149
+ version: 1.2611.0
150
150
  type: :runtime
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
@@ -154,7 +154,7 @@ dependencies:
154
154
  requirements:
155
155
  - - ~>
156
156
  - !ruby/object:Gem::Version
157
- version: 1.2606.0
157
+ version: 1.2611.0
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: bosh_warden_cpi
160
160
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +162,7 @@ dependencies:
162
162
  requirements:
163
163
  - - ~>
164
164
  - !ruby/object:Gem::Version
165
- version: 1.2606.0
165
+ version: 1.2611.0
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,7 +170,7 @@ dependencies:
170
170
  requirements:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
- version: 1.2606.0
173
+ version: 1.2611.0
174
174
  - !ruby/object:Gem::Dependency
175
175
  name: bosh_vcloud_cpi
176
176
  requirement: !ruby/object:Gem::Requirement
@@ -493,7 +493,7 @@ dependencies:
493
493
  version: '0'
494
494
  description: ! 'BOSH Director
495
495
 
496
- a72f3d'
496
+ 6129ec'
497
497
  email: support@cloudfoundry.com
498
498
  executables:
499
499
  - bosh-director
@@ -754,7 +754,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
754
754
  version: '0'
755
755
  segments:
756
756
  - 0
757
- hash: 2199722690621667440
757
+ hash: -4501133307616993299
758
758
  requirements: []
759
759
  rubyforge_project:
760
760
  rubygems_version: 1.8.23.2