Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcsim: fix: ignore unknown refs in Datacenter.PowerOnMultiVM #3449

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions simulator/datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ func (dc *Datacenter) PowerOnMultiVMTask(ctx *Context, req *types.PowerOnMultiVM
res.Attempted = []types.ClusterAttemptedVmInfo{}

for _, ref := range req.Vm {
vm := ctx.Map.Get(ref).(*VirtualMachine)

vm, ok := ctx.Map.Get(ref).(*VirtualMachine)
if !ok {
continue
}
// This task creates multiple subtasks which violates the assumption
// of 1:1 Context:Task, which results in data races in objects
// like the Simulator.Event manager. This is the minimum context
Expand Down
5 changes: 4 additions & 1 deletion simulator/datacenter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ func TestDatacenterPowerOnMultiVMs(t *testing.T) {
}
}

dcTask, err := dc.PowerOnVM(ctx, testVMs)
// real VC ignores unknown VM refs
unknown := types.ManagedObjectReference{Type: "VirtualMachine", Value: "unknown"}

dcTask, err := dc.PowerOnVM(ctx, append(testVMs, unknown))
if err != nil {
t.Fatal(err)
}
Expand Down
Loading