bosh_vsphere_cpi 1.2902.0 → 1.2905.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: 8476afad7bad1192d764778265348d8a31ec60d9
4
- data.tar.gz: ad2c4d1f695e444660d4e765db47a3c0f7f89b7c
3
+ metadata.gz: 60c75ba55eeb149c55f82d2e0761aa6c99b0f142
4
+ data.tar.gz: 9b5dff6edbb35ea496be586e0d2007b24a4b933f
5
5
  SHA512:
6
- metadata.gz: 3409e451fde5a32cdaa22e092abe8211046207ebc2f35bfdfae60b667a2999bc6aa1d8329dfb2a72595459796afcf1c8a10bfc7690d1b68da81a17538a31cdfd
7
- data.tar.gz: 79ff48d380c07d508b12ab1935a0f873d6eafa2f46eacd0a7592817efd9fb00351ebbf8642865a64dc43760d4dd3508e59760c17553161a51953c197b7805a7b
6
+ metadata.gz: a69456ce29e6c0a9080b1a3269bd15c3c7c015d0960bd93d2f2dd6965c998762420bbeed3d3d39875b937680deaf37d72a767b0545296f0706aa58cb4a6d78ba
7
+ data.tar.gz: a118414527e88a772f5b6697b15a40cde2f13c293cd316e47e8e61e59413ff80b82100de85f244a76e76db8cafcc11516d70fdff51bbd6b2c55d8d1882b0b0c4
@@ -25,10 +25,6 @@ module VSphereCloud
25
25
  return disk if accessible_datastores.include?(disk.datastore.name)
26
26
 
27
27
  destination_datastore = @resources.pick_persistent_datastore_in_cluster(cluster, disk.size_in_mb)
28
- if destination_datastore.nil?
29
- raise Bosh::Clouds::NoDiskSpace.new(true),
30
- "Not enough persistent space on cluster '#{cluster.name}', requested disk size: #{disk.size_in_mb}Mb"
31
- end
32
28
 
33
29
  unless accessible_datastores.include?(destination_datastore.name)
34
30
  raise "Datastore '#{destination_datastore.name}' is not accessible to cluster '#{cluster.name}'"
@@ -27,9 +27,13 @@ module VSphereCloud
27
27
  def pick_persistent_datastore_in_cluster(cluster_name, disk_size_in_mb)
28
28
  @lock.synchronize do
29
29
  cluster = @datacenter.clusters[cluster_name]
30
- return nil if cluster.nil?
30
+ if cluster.nil?
31
+ raise Bosh::Clouds::NoDiskSpace.new(true), "Couldn't find cluster '#{cluster_name}'. Found #{@datacenter.clusters.values.map(&:name).join(", ")}"
32
+ end
31
33
 
32
- pick_datastore(cluster, disk_size_in_mb)
34
+ datastore = cluster.pick_persistent(disk_size_in_mb)
35
+ datastore.allocate(disk_size_in_mb)
36
+ datastore
33
37
  end
34
38
  end
35
39
 
@@ -116,11 +120,6 @@ module VSphereCloud
116
120
  def pick_persistent_datastore(cluster, disk_size_in_mb)
117
121
  @lock.synchronize do
118
122
  datastore = cluster.pick_persistent(disk_size_in_mb)
119
- if datastore.nil?
120
- raise Bosh::Clouds::NoDiskSpace.new(
121
- "Not enough persistent disk space (#{disk_size_in_mb}MB) in cluster #{cluster.name}")
122
- end
123
-
124
123
  datastore.allocate(disk_size_in_mb)
125
124
  datastore
126
125
  end
@@ -130,12 +129,6 @@ module VSphereCloud
130
129
 
131
130
  attr_reader :config
132
131
 
133
- def pick_datastore(cluster, disk_space)
134
- datastore = cluster.pick_persistent(disk_space)
135
- return nil if datastore.nil?
136
- datastore.allocate(disk_space)
137
- datastore
138
- end
139
132
 
140
133
  class PersistentDiskIndex
141
134
  def initialize(clusters, existing_persistent_disks)
@@ -84,7 +84,7 @@ module VSphereCloud
84
84
  # @return [Datastore, nil] best datastore if available for the requested
85
85
  # size.
86
86
  def pick_persistent(size)
87
- pick_store(size, :persistent)
87
+ pick_store(:persistent, size)
88
88
  end
89
89
 
90
90
  # Picks the best datastore for the specified ephemeral disk.
@@ -93,7 +93,7 @@ module VSphereCloud
93
93
  # @return [Datastore, nil] best datastore if available for the requested
94
94
  # size.
95
95
  def pick_ephemeral(size)
96
- pick_store(size, :ephemeral)
96
+ pick_store(:ephemeral, size)
97
97
  end
98
98
 
99
99
  # @return [String] cluster name.
@@ -133,17 +133,49 @@ module VSphereCloud
133
133
  # @param [Symbol] type disk type.
134
134
  # @return [Datastore, nil] best datastore if available for the requested
135
135
  # size.
136
- def pick_store(size, type)
137
- weighted_datastores = []
138
- datastores =
139
- type == :persistent ? persistent_datastores : ephemeral_datastores
140
- datastores.each_value do |datastore|
141
- if datastore.free_space - size >= DISK_HEADROOM
142
- weighted_datastores << [datastore, datastore.free_space]
143
- end
136
+
137
+ def pick_store(type, size)
138
+ datastores = type == :ephemeral ? ephemeral_datastores : persistent_datastores
139
+ datastores_and_free_space = datastores.each_value.map do |datastore|
140
+ [datastore, datastore.free_space]
141
+ end
142
+
143
+ datastores_and_free_space_with_enough_space = datastores_and_free_space.reject do |datastore, free_space|
144
+ free_space - size < DISK_HEADROOM
145
+ end
146
+
147
+ log_datastore_selection(type, datastores_and_free_space, datastores_and_free_space_with_enough_space, size)
148
+
149
+ if datastores_and_free_space_with_enough_space.empty?
150
+ raise_no_disk_space_found(type, datastores_and_free_space, size)
151
+ end
152
+
153
+ Util.weighted_random(datastores_and_free_space_with_enough_space)
154
+ end
155
+
156
+ def raise_no_disk_space_found(type, datastores_and_free_space, size)
157
+ datastore_debug_info = datastores_and_free_space.map do |datastore, free_space|
158
+ "#{datastore.name} (#{free_space}MB free of #{datastore.total_space}MB capacity)"
144
159
  end
160
+ raise Bosh::Clouds::NoDiskSpace.new(true), <<-MESSAGE
161
+ Couldn't find a #{type} datastore with #{size}MB of free space in #{name}. Found:
162
+ #{datastore_debug_info.join("\n ")}
163
+ MESSAGE
164
+ end
165
+
166
+ def log_datastore_selection(type, datastores_and_free_space, datastores_and_free_space_with_enough_space, size)
167
+ @logger.debug("Looking for a #{type} datastore in #{name} with #{size}MB free space in:")
168
+ datastores_and_free_space.each do |datastore, _|
169
+ @logger.debug(" #{debug_info_for_datastore(datastore)}")
170
+ end
171
+ acceptable_datastores_message = datastores_and_free_space_with_enough_space.map do |datastore, _|
172
+ datastore.name
173
+ end.join(", ")
174
+ @logger.debug("Picking a random datastore (weighted by free space) from: #{acceptable_datastores_message}")
175
+ end
145
176
 
146
- Util.weighted_random(weighted_datastores)
177
+ def debug_info_for_datastore(datastore)
178
+ "#{datastore.name} (#{datastore.free_space}MB free of #{datastore.total_space}MB capacity)"
147
179
  end
148
180
 
149
181
  def synced_free_memory
@@ -1,7 +1,7 @@
1
1
  module Bosh
2
2
  module Clouds
3
3
  class VSphere
4
- VERSION = '1.2902.0'
4
+ VERSION = '1.2905.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_vsphere_cpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2902.0
4
+ version: 1.2905.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-03-26 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2902.0
19
+ version: 1.2905.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.2902.0
26
+ version: 1.2905.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.2902.0
33
+ version: 1.2905.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.2902.0
40
+ version: 1.2905.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: membrane
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ dependencies:
208
208
  version: '0'
209
209
  description: |-
210
210
  BOSH VSphere CPI
211
- ac0a41
211
+ 327a58
212
212
  email: support@cloudfoundry.com
213
213
  executables:
214
214
  - vsphere_cpi