Skip to content

Commit

Permalink
Merge pull request #739 from agrare/fix_cache_failure_missing_key_ass…
Browse files Browse the repository at this point in the history
…ignment

Handle if the property change target doesn't exist

(cherry picked from commit d91497e)
  • Loading branch information
Fryguy committed Jul 29, 2021
1 parent cd973ac commit d5e8c4d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def process_prop_change(prop_hash, prop_change)
h[tag] = prop_change.val
end
end
rescue => err
_log.warn("Failed to process property change #{prop_change.name}: #{err}")
end

def hash_target(base_hash, key_string)
Expand All @@ -108,7 +110,7 @@ def hash_target(base_hash, key_string)
key, array_key = tag_and_key(key)
if array_key
array, idx = get_array_entry(h[key], array_key)
raise "hashTarget: Could not traverse tree through array element #{k}[#{array_key}] in #{key_string}" unless array
raise "Could not traverse tree through array element #{key}[#{array_key}] in #{key_string}" unless array

h = array[idx]
else
Expand Down Expand Up @@ -171,5 +173,7 @@ def get_array_entry(array, key)
return array, n if entry_key.to_s == key
end
end

return nil, nil
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
:device => [2000],
:hotAddRemove => true,
:sharedBus => "noSharing",
:scsiCtlrUnitNumber => 7,
:scsiCtlrUnitNumber => 7
),
RbVmomi::VIM::VirtualDisk(
:key => 2000,
:deviceInfo => RbVmomi::VIM::Description(:label => "Hard disk 1", :summary => "41,943,040 KB"),
:backing => RbVmomi::VIM::VirtualDiskFlatVer2BackingInfo(
:key => 2000,
:deviceInfo => RbVmomi::VIM::Description(:label => "Hard disk 1", :summary => "41,943,040 KB"),
:backing => RbVmomi::VIM::VirtualDiskFlatVer2BackingInfo(
:fileName => "[datastore] vm1/vm1.vmdk",
:datastore => RbVmomi::VIM::Datastore(nil, "datastore-1"),
:diskMode => "persistent",
:thinProvisioned => true,
:uuid => "6000C294-264b-3f91-8e5c-8c2ebac1bfe8",
:uuid => "6000C294-264b-3f91-8e5c-8c2ebac1bfe8"
),
:controllerKey => 1000,
:unitNumber => 0,
:capacityInKB => 41_943_040,
:controllerKey => 1000,
:unitNumber => 0,
:capacityInKB => 41_943_040
),
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@
expect(child_snapshot.parent).to eq(root_snapshot)
end

it "datastore mount info with invalid host doesn't fail the refresh" do
run_targeted_refresh(
targeted_update_set(
[
RbVmomi::VIM.ObjectUpdate(
:kind => "modify",
:obj => RbVmomi::VIM.Datastore(vim, "datastore-15"),
:changeSet => [RbVmomi::VIM.PropertyChange(:name => "host[\"host-garbage\"].mountInfo", :op => "assign", :val => nil)]
)
]
)
)
expect(ems.reload.last_refresh_error).to be_nil
end

it "renaming a distributed virtual portgroup" do
lan = ems.distributed_virtual_lans.first
expect(lan.name).to eq("DC0_DVPG1")
Expand Down

0 comments on commit d5e8c4d

Please sign in to comment.