Skip to content

Commit 3fc6d72

Browse files
ragaskarjpalermo
authored andcommitted
Revert "Only place disks on cluster-accessible datastores"
- These changes were originally made because it was believed that in deployments where "vertical" storage was used (that is, storage accessible only to a specific cluster, not all clusters), the disk could sometimes be incorrectly placed, resulting in a CPI/deployment failure. - Symptoms of this failure were errors like "Unable to access the virtual machine configuration", and "Invalid configuration for device '0'." - There were also reports of "No valid hosts could be found due to Das state" with this topology. - These prior changes ran some additional accessibility checks that verified that all datastores connected to a cluster were ALSO explicitly mounted by each ESXi host in that cluster. This behavior was identified as causing large performance degradations to deployments with many hosts and/or datastores. - Originally it was thought the errors seen above could occur _with any_ vertical storage configuration, further investigation has demonstrated that this only occurs if: * a deployment uses vertical storage. * datastores specified by the deployment are _connected_ but not used by cluster hosts (e.g., a datastores has been detached and unmounted from a host BUT the host has not rescanned disks.) In this circumstance, the API reports this disconnected datastore as being a part of the cluster, but these hosts will not be able to access it. - While this prior change is _technically correct_ as it guards against a possible but likely unintentional configuration, given the associated performance cost (borne by all users, including those with "correct" vertical storage configurations and those not using vertical storage at all) it makes sense to remove this extra check. - n.b. the behavior after revert still checks: 1) that the datastore is "connected" to hosts on the cluster and 2) the datastore is "accessible" (turned on). This reverts commits 3d50f05 and 3ff70d1 Signed-off-by: Brian Cunnie <bcunnie@vmware.com>
1 parent f04fe59 commit 3fc6d72

7 files changed

Lines changed: 22 additions & 101 deletions

File tree

src/vsphere_cpi/lib/cloud/vsphere/resources/cluster.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def accessible_datastores
153153
@accessible_datastores ||= Datastore.build_from_client(
154154
@client,
155155
properties['datastore']
156-
).select { |datastore| datastore.accessible_from?(@mob) }
156+
).select { |datastore| datastore.accessible }
157157
.inject({}) do |acc, datastore|
158158
acc[datastore.name] = datastore
159159
acc

src/vsphere_cpi/lib/cloud/vsphere/resources/datastore.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ def accessible?
8989
# maintenance mode and is part of the very same cluster that datastore
9090
# can access
9191
#
92-
def accessible_from?(cluster_mob)
92+
def accessible_from?(cluster)
9393
@mob.host.any? do |host_mount|
9494
next if host_mount.key.runtime.in_maintenance_mode
95-
next unless host_mount.mount_info.accessible
96-
cluster_mob.host.include?(host_mount.key)
95+
cluster.host.include?(host_mount.key)
9796
end
9897
end
9998

src/vsphere_cpi/lib/cloud/vsphere/resources/vm.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ def cluster
3030
cluster['name']
3131
end
3232

33-
def cluster_mob
34-
cluster = cloud_searcher.get_properties(host_properties['parent'], Vim::ClusterComputeResource, 'name', ensure_all: true)
35-
cluster[:obj]
36-
end
37-
3833
def resource_pool
3934
properties['resourcePool'].name
4035
end
@@ -46,7 +41,7 @@ def accessible_datastores
4641
ensure_all: true
4742
).select(&:accessible)
4843
.inject({}) do |acc, datastore|
49-
acc[datastore.name] = datastore if datastore.accessible_from?(cluster_mob)
44+
acc[datastore.name] = datastore
5045
acc
5146
end
5247
end

src/vsphere_cpi/spec/unit/cloud/vsphere/resources/cluster_spec.rb

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ module VSphereCloud::Resources
3535
'resourcePool' => fake_resource_pool_mob,
3636
}
3737
end
38-
let(:fake_cluster_mob_host) { double('VimSdk::Vim::HostSystem') }
39-
let(:cluster_mob) { instance_double('VimSdk::Vim::ClusterComputeResource', name: 'cluster1', host: fake_cluster_mob_host) }
38+
let(:cluster_mob) { instance_double('VimSdk::Vim::ClusterComputeResource', name: 'cluster1') }
4039
let(:cluster_hosts) { [instance_double('VimSdk::Vim::HostSystem')] }
4140
let(:fake_resource_pool_mob) { instance_double('VimSdk::Vim::ResourcePool') }
4241

@@ -47,29 +46,22 @@ module VSphereCloud::Resources
4746
end
4847
let(:fake_resource_pool_mob) { instance_double('VimSdk::Vim::ResourcePool') }
4948

50-
let(:fake_available_host_mount_mob) { instance_double('VimSdk::Vim::Datastore::HostMount', key: 'an-INCLUDED-key') }
51-
let(:fake_unavailable_host_mount_mob) { instance_double('VimSdk::Vim::Datastore::HostMount', key: 'an-EXCLUDED-key') }
52-
53-
let(:ephemeral_store_datastore_mob) { instance_double('VimSdk::Vim::Datastore', host: [fake_available_host_mount_mob]) }
54-
let(:ephemeral_store_properties) { {obj: ephemeral_store_datastore_mob,'name' => 'ephemeral_1', 'summary.freeSpace' => 15000 * BYTES_IN_MB} }
55-
let(:ephemeral_store_2_datastore_mob) { instance_double('VimSdk::Vim::Datastore', host: [fake_available_host_mount_mob]) }
56-
let(:ephemeral_store_2_properties) { {obj: ephemeral_store_2_datastore_mob,'name' => 'ephemeral_2', 'summary.freeSpace' => 25000 * BYTES_IN_MB} }
57-
let(:persistent_store_datastore_mob) { instance_double('VimSdk::Vim::Datastore', host: [fake_available_host_mount_mob]) }
58-
let(:persistent_store_properties) { {obj: persistent_store_datastore_mob,'name' => 'persistent_1', 'summary.freeSpace' => 10000 * BYTES_IN_MB, 'summary.capacity' => 20000 * BYTES_IN_MB} }
59-
let(:persistent_store_2_datastore_mob) { instance_double('VimSdk::Vim::Datastore', host: [fake_available_host_mount_mob]) }
60-
let(:persistent_store_2_properties) { {obj: persistent_store_2_datastore_mob,'name' => 'persistent_2', 'summary.freeSpace' => 20000 * BYTES_IN_MB, 'summary.capacity' => 40000 * BYTES_IN_MB} }
61-
let(:inaccessible_persistent_store_datastore_mob) { instance_double('VimSdk::Vim::Datastore', host: [fake_unavailable_host_mount_mob]) }
62-
let(:inaccessible_persistent_store_properties) { {obj: inaccessible_persistent_store_datastore_mob,'name' => 'persistent_inaccess'} }
63-
let(:other_store_properties) { {obj: inaccessible_persistent_store_datastore_mob, 'name' => 'other' } }
49+
let(:ephemeral_store_properties) { {'name' => 'ephemeral_1', 'summary.accessible' => true, 'summary.freeSpace' => 15000 * BYTES_IN_MB} }
50+
let(:ephemeral_store_2_properties) { {'name' => 'ephemeral_2', 'summary.accessible' => true, 'summary.freeSpace' => 25000 * BYTES_IN_MB} }
51+
let(:persistent_store_properties) { {'name' => 'persistent_1', 'summary.accessible' => true, 'summary.freeSpace' => 10000 * BYTES_IN_MB, 'summary.capacity' => 20000 * BYTES_IN_MB} }
52+
let(:persistent_store_2_properties) { {'name' => 'persistent_2', 'summary.accessible' => true, 'summary.freeSpace' => 20000 * BYTES_IN_MB, 'summary.capacity' => 40000 * BYTES_IN_MB} }
53+
let(:inaccessible_persistent_store_properties) { {'name' => 'persistent_inaccess', 'summary.accessible' => false} }
54+
55+
let(:other_store_properties) { { 'name' => 'other' } }
6456

6557
let(:fake_datastore_properties) do
6658
{
67-
keys: ephemeral_store_properties,
68-
are: ephemeral_store_2_properties,
69-
ignored: persistent_store_properties,
70-
in: persistent_store_2_properties,
71-
this: inaccessible_persistent_store_properties,
72-
hash: other_store_properties,
59+
instance_double('VimSdk::Vim::Datastore') => ephemeral_store_properties,
60+
instance_double('VimSdk::Vim::Datastore') => ephemeral_store_2_properties,
61+
instance_double('VimSdk::Vim::Datastore') => persistent_store_properties,
62+
instance_double('VimSdk::Vim::Datastore') => persistent_store_2_properties,
63+
instance_double('VimSdk::Vim::Datastore') => inaccessible_persistent_store_properties,
64+
instance_double('VimSdk::Vim::Datastore') => other_store_properties,
7365
}
7466
end
7567

@@ -103,17 +95,6 @@ module VSphereCloud::Resources
10395
end
10496

10597
describe '#accessible_datastores' do
106-
before do
107-
allow(fake_available_host_mount_mob).to receive_message_chain(:key, :runtime, :in_maintenance_mode).and_return(false)
108-
allow(fake_available_host_mount_mob).to receive_message_chain(:mount_info,:accessible).and_return(true)
109-
110-
allow(fake_unavailable_host_mount_mob).to receive_message_chain(:key, :runtime, :in_maintenance_mode).and_return(false)
111-
allow(fake_unavailable_host_mount_mob).to receive_message_chain(:mount_info,:accessible).and_return(true)
112-
113-
allow(fake_cluster_mob_host).to receive(:include?).with(fake_available_host_mount_mob.key).and_return(true)
114-
allow(fake_cluster_mob_host).to receive(:include?).with(fake_unavailable_host_mount_mob.key).and_return(false)
115-
end
116-
11798
it 'returns the full list of datastores without inaccessible stores' do
11899
accessible_datastores = cluster.accessible_datastores
119100
expect(accessible_datastores.keys).to match_array(%w(persistent_1 persistent_2 ephemeral_1 ephemeral_2))

src/vsphere_cpi/spec/unit/cloud/vsphere/resources/datastore_spec.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,13 @@
8585
context 'when all hosts are in maintenance mode' do
8686
let(:maintenance_mode) { true }
8787
let(:is_included) { true }
88-
before do
89-
allow(host_mount).to receive_message_chain(:mount_info, :accessible).and_return(true)
90-
end
9188
it 'is false' do
9289
expect(subject).to_not be_accessible_from(cluster)
9390
end
9491
end
9592

9693
context 'when at least one of the hosts is not in maintenance mode' do
9794
before do
98-
allow(host_mount).to receive_message_chain(:mount_info, :accessible).and_return(true)
9995
expect(cluster).to receive_message_chain(:host, :include?).with(host_mob).and_return(is_included)
10096
end
10197
let(:maintenance_mode) { false }
@@ -113,25 +109,6 @@
113109
end
114110
end
115111
end
116-
117-
context 'datastore-host accessibility' do
118-
let(:maintenance_mode) { false }
119-
before do
120-
expect(host_mount).to receive_message_chain(:mount_info, :accessible).and_return(is_accessible)
121-
end
122-
context "when the host can access the datastore" do
123-
let(:is_accessible) { true }
124-
it 'is true' do
125-
expect(subject).to be_accessible_from(cluster)
126-
end
127-
end
128-
context "when the host can't access the datastore" do
129-
let(:is_accessible) { false }
130-
it 'is false' do
131-
expect(subject).to_not be_accessible_from(cluster)
132-
end
133-
end
134-
end
135112
end
136113
end
137114

src/vsphere_cpi/spec/unit/cloud/vsphere/resources/vm_spec.rb

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,50 +34,20 @@
3434

3535
context 'accessible datastores' do
3636
let(:bytes_in_mb) {1024 * 1024}
37-
let(:cluster_mob) { instance_double('VimSdk::Vim::ClusterComputeResource') }
3837
let(:accessible_datastore_properties) { {'name' => 'datastore-name', 'summary.accessible' => true, 'summary.freeSpace' => 20000 * bytes_in_mb, 'summary.capacity' => 40000 * bytes_in_mb} }
3938
let(:inaccessible_datastore_properties) { {'name' => 'inaccessible-datastore-name', 'summary.accessible' => false} }
40-
let(:vertically_inaccessible_datastore_properties) { {'name' => 'vertically-inaccessible-datastore-name', 'summary.accessible' => true} }
4139
let(:datastore_mob) { instance_double('VimSdk::Vim::Datastore') }
4240
let(:inaccessible_datastore_mob) { instance_double('VimSdk::Vim::Datastore') }
43-
let(:vertically_inaccessible_datastore_mob) { instance_double('VimSdk::Vim::Datastore') }
4441
let(:datastore_properties) do
4542
{
4643
instance_double('VimSdk::Vim::Datastore') => accessible_datastore_properties,
47-
instance_double('VimSdk::Vim::Datastore') => inaccessible_datastore_properties,
48-
instance_double('VimSdk::Vim::Datastore') => vertically_inaccessible_datastore_properties
44+
instance_double('VimSdk::Vim::Datastore') => inaccessible_datastore_properties
4945
}
5046
end
51-
5247
before do
53-
accessible_ds = instance_double(VSphereCloud::Resources::Datastore,
54-
name: "datastore-name",
55-
maintenance_mode?: false,
56-
accessible_from?: true,
57-
accessible: true
58-
)
59-
inaccessible_ds = instance_double(VSphereCloud::Resources::Datastore,
60-
name: "inaccessible-datastore-name",
61-
maintenance_mode?: false,
62-
accessible_from?: true,
63-
accessible: false
64-
)
65-
vert_inaccessible_ds = instance_double(VSphereCloud::Resources::Datastore,
66-
name: "inaccessible-datastore-name",
67-
maintenance_mode?: false,
68-
accessible_from?: false,
69-
accessible: true
70-
)
71-
7248
host_properties = {
73-
'datastore' => [datastore_mob, inaccessible_datastore_mob, vertically_inaccessible_datastore_mob]
49+
'datastore' => [datastore_mob, inaccessible_datastore_mob]
7450
}
75-
allow(cloud_searcher).to receive(:get_properties).with(
76-
host_properties['parent'],
77-
VimSdk::Vim::ClusterComputeResource,
78-
"name",
79-
ensure_all: true,
80-
).and_return({obj: cluster_mob})
8151
allow(cloud_searcher).to receive(:get_properties).with(
8252
'vm-host',
8353
VimSdk::Vim::HostSystem,
@@ -90,11 +60,11 @@
9060
VSphereCloud::Resources::Datastore::PROPERTIES,
9161
ensure_all: true,
9262
).and_return(datastore_properties)
93-
expect(VSphereCloud::Resources::Datastore).to receive(:build_from_client).and_return([accessible_ds,inaccessible_ds,vert_inaccessible_ds])
9463
end
9564
describe '#accessible_datastores' do
9665
it 'returns list of accessible datastores' do
9766
expect(vm.accessible_datastores.keys).to match_array(['datastore-name'])
67+
expect(vm.accessible_datastores['datastore-name']).to be_a(VSphereCloud::Resources::Datastore)
9868
end
9969
end
10070
describe '#accessible_datastore_names' do

src/vsphere_cpi/spec/unit/cloud/vsphere/vm_config_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,8 @@ def fake_datastore(name, free_space, mob = nil)
388388
end
389389
let(:global_clusters) { [cluster_1, cluster_2] }
390390
let(:host_runtime_info) { instance_double(VimSdk::Vim::Host::RuntimeInfo, in_maintenance_mode: false) }
391-
let(:host_mount_info) { instance_double(VimSdk::Vim::Host::MountInfo, accessible: true) }
392391
let(:host_system) {instance_double(VimSdk::Vim::HostSystem, runtime: host_runtime_info)}
393-
let(:datastore_host_mount) { [instance_double('VimSdk::Vim::Datastore::HostMount', key: host_system, mount_info: host_mount_info)]}
392+
let(:datastore_host_mount) { [instance_double('VimSdk::Vim::Datastore::HostMount', key: host_system)]}
394393
let(:smaller_datastore_mob) { instance_double('VimSdk::Vim::Datastore', host: datastore_host_mount) }
395394
let(:larger_datastore_mob) { instance_double('VimSdk::Vim::Datastore', host: datastore_host_mount) }
396395
let(:smaller_ds) { fake_datastore( 'smaller-ds', 512, smaller_datastore_mob) }

0 commit comments

Comments
 (0)