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

[BUG] vcsim: vim.VirtualMachine.snapshot property causes runtime error when not set #3337

Closed
rmcqueen-cb opened this issue Jan 12, 2024 · 3 comments

Comments

@rmcqueen-cb
Copy link

rmcqueen-cb commented Jan 12, 2024

Describe the bug
vcsim: vim.VirtualMachine.snapshot property causes runtime error when not set (particularly when using pyvmomi)

To Reproduce
Steps to reproduce the behavior:

  1. Connect to vcsim.
  2. Create a VM.
  3. Check the value of the vm.snapshot property.

Expected behavior

Client should receive a 'HTTP/1.1 200 OK\r\n' response for the vim.VirtualMachine.snapshot property, even if it is not set. However, currently no response is returned due to runtime error.

Affected version
govmomi v0.34.2 Latest

Screenshots/Debug Output

  • vcsim -trace
2024-01-12 12:14:24 Request: <?xml version="1.0" encoding="UTF-8"?>
2024-01-12 12:14:24 <soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2024-01-12 12:14:24 <soapenv:Body><Fetch xmlns="urn:vim25"><_this versionId="6.5" type="VirtualMachine">vm-69</_this><prop versionId="6.5">snapshot</prop></Fetch></soapenv:Body>
2024-01-12 12:14:24 </soapenv:Envelope>
2024-01-12 12:14:24 2024/01/12 17:14:24 http: panic serving 192.168.65.1:57175: runtime error: index out of range [0] with length 0
2024-01-12 12:14:24 goroutine 108 [running]:
2024-01-12 12:14:24 net/http.(*conn).serve.func1()
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/net/http/server.go:1854 +0xbf
2024-01-12 12:14:24 panic({0xff8c00, 0xc0004ae4f8})
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/runtime/panic.go:890 +0x263
2024-01-12 12:14:24 github.com/vmware/govmomi/simulator.(*PropertyCollector).Fetch(0x2?, 0xc0002b5170, 0xc0002c7940)
2024-01-12 12:14:24 /home/runner/work/govmomi/govmomi/simulator/property_collector.go:858 +0x7b7
2024-01-12 12:14:24 reflect.Value.call({0x1033540?, 0xc00059c700?, 0x7f0c2d1def18?}, {0x1066a54, 0x4}, {0xc0005dbf50, 0x2, 0xc0006bf2e0?})
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/reflect/value.go:586 +0xb07
2024-01-12 12:14:24 reflect.Value.Call({0x1033540?, 0xc00059c700?, 0xc0006bf368?}, {0xc0005dbf50?, 0xc0005fe000?, 0x1063dc0?})
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/reflect/value.go:370 +0xbc
2024-01-12 12:14:24 github.com/vmware/govmomi/simulator.(*Service).call.func1()
2024-01-12 12:14:24 /home/runner/work/govmomi/govmomi/simulator/simulator.go:217 +0x3a
2024-01-12 12:14:24 github.com/vmware/govmomi/simulator.(*Registry).WithLock(0xc0005288a0?, 0xc00059c700?, {0x11fa280?, 0xc00059c700?}, 0xc0006bf5d0)
2024-01-12 12:14:24 /home/runner/work/govmomi/govmomi/simulator/registry.go:634 +0x37
2024-01-12 12:14:24 github.com/vmware/govmomi/simulator.(*Service).call(0xc00019e600, 0xc0002b5170, 0xc0002b5290)
2024-01-12 12:14:24 /home/runner/work/govmomi/govmomi/simulator/simulator.go:216 +0xf39
2024-01-12 12:14:24 github.com/vmware/govmomi/simulator.(*Service).ServeSDK(0xc00019e600, {0x1202330, 0xc000515260}, 0xc00053e800)
2024-01-12 12:14:24 /home/runner/work/govmomi/govmomi/simulator/simulator.go:501 +0x570
2024-01-12 12:14:24 net/http.HandlerFunc.ServeHTTP(0x0?, {0x1202330?, 0xc000515260?}, 0xc0006bfab0?)
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/net/http/server.go:2122 +0x2f
2024-01-12 12:14:24 net/http.(*ServeMux).ServeHTTP(0x0?, {0x1202330, 0xc000515260}, 0xc00053e800)
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/net/http/server.go:2500 +0x149
2024-01-12 12:14:24 net/http.serverHandler.ServeHTTP({0x12011e8?}, {0x1202330, 0xc000515260}, 0xc00053e800)
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/net/http/server.go:2936 +0x316
2024-01-12 12:14:24 net/http.(*conn).serve(0xc000716360, {0x12026f0, 0xc0007440c0})
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/net/http/server.go:1995 +0x612
2024-01-12 12:14:24 created by net/http.(*Server).Serve
2024-01-12 12:14:24 /opt/hostedtoolcache/go/1.20.12/x64/src/net/http/server.go:3089 +0x5ed
  • pyvmomi
    if self.vm.snapshot is None:
  File "/venv/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py", line 592, in __call__
    return self.f(*args, **kwargs)
  File "/venv/lib/python3.9/site-packages/pyVmomi/VmomiSupport.py", line 397, in _InvokeAccessor
    return self._stub.InvokeAccessor(self, info)
  File "/venv/lib/python3.9/site-packages/pyVmomi/StubAdapterAccessorImpl.py", line 58, in InvokeAccessor
    return self.InvokeMethod(mo, info, (prop, ))
  File "/venv/lib/python3.9/site-packages/pyVmomi/SoapAdapter.py", line 1534, in InvokeMethod
    resp = conn.getresponse()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1345, in getresponse
    response.begin()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

Additional context

  • Debug log from testing with pyvmomi and vsphere (for a VM without any snapshot):
send: b'<?xml version="1.0" encoding="UTF-8"?>\n<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">\n<soapenv:Body><Fetch xmlns="urn:vim25"><_this versionId="7.0.3.0" type="VirtualMachine">vm-917010</_this><prop versionId="7.0.3.0">snapshot</prop></Fetch></soapenv:Body>\n</soapenv:Envelope>'

reply: 'HTTP/1.1 200 OK\r\n'
  • Debug log from testing with pyvmomi and vcsim (for a VM without any snapshot):
send: b'<?xml version="1.0" encoding="UTF-8"?>\n<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">\n<soapenv:Body><Fetch xmlns="urn:vim25"><_this versionId="6.5" type="VirtualMachine">vm-69</_this><prop versionId="6.5">snapshot</prop></Fetch></soapenv:Body>\n</soapenv:Envelope>'

reply: ''
Copy link
Contributor

Howdy 🖐   rmcqueen-cb ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

@rmcqueen-cb rmcqueen-cb changed the title [BUG] vcsim: vim.VirtualMachine.snapshot property causes runtime error when not present [BUG] vcsim: vim.VirtualMachine.snapshot property causes runtime error when not set Jan 12, 2024
@bardielle
Copy link
Contributor

bardielle commented Mar 4, 2024

I'm facing the same issue. There is any solution? or workaround?
I added a commit as a workaround for now - bardielle@cd20cec

And build the vcsim image locally. Now it's working for me

@bardielle
Copy link
Contributor

#3381

@dougm dougm closed this as completed in fd3840e Mar 6, 2024
bardielle added a commit to bardielle/cloud.vmware_ops that referenced this issue Mar 24, 2024
Since the vcsim fix for m properties was released (vmware/govmomi#3337)

Signed-off-by: Danielle Barda <[email protected]>
bardielle added a commit to bardielle/cloud.vmware_ops that referenced this issue Mar 24, 2024
Since the vcsim fix for m properties was released (vmware/govmomi#3337)

Signed-off-by: Danielle Barda <[email protected]>
bardielle added a commit to bardielle/cloud.vmware_ops that referenced this issue Mar 25, 2024
Since the vcsim fix for m properties was released (vmware/govmomi#3337)

Signed-off-by: Danielle Barda <[email protected]>
bardielle added a commit to bardielle/cloud.vmware_ops that referenced this issue Mar 26, 2024
Since the vcsim fix for m properties was released (vmware/govmomi#3337)

Signed-off-by: Danielle Barda <[email protected]>
bardielle added a commit to redhat-cop/cloud.vmware_ops that referenced this issue Mar 26, 2024
Since the vcsim fix for m properties was released (vmware/govmomi#3337)

Signed-off-by: Danielle Barda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants