vsphere-automation-sdk-python icon indicating copy to clipboard operation
vsphere-automation-sdk-python copied to clipboard

sddc_crud.py samples throws exception when waiting for task to complete.

Open tianhao64 opened this issue 7 years ago • 1 comments

  • [X] I am using the latest SDK version
  • [X] This API is compatible with my vCenter version (You can get the info from 'vcenter_version' in each sample)
  • [X] I have searched existing issues

Environment

  • sdk package version:

pyvmomi (6.7.0) service-identity (17.0.0) vapi-client-bindings (1.3.0) vapi-common-client (2.9.0) vapi-runtime (2.9.0) vapi-vmc-client (2.9.0) vmc-app-python-sdk (2.2.0.0.0.15184434) vmc-client-bindings (1.2.0)

  • python version:

Python 3.6.3

  • vSphere version: VMware cloud on AWS

Steps or code snippet to reproduce

(py3) het-m03:vsphere-automation-sdk-python het$ python samples/vmc/sddc/sddc_crud.py -r $TOKEN -o $ORG -cs

Example: Create a SDDC (Sample SDDC 31) in org 058f47c4-92aa-417f-8747-87f3ed61cb45:

Wait for task 5f10f0e2-fa6e-49a1-a98d-0dd15ade56ad to finish Checking task status every 60 seconds Estimated time remaining: 108 minutes Traceback (most recent call last): File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request six.raise_from(e, None) File "", line 2, in raise_from File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request httplib_response = conn.getresponse() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse response.begin() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin version, status, reason = self._read_status() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/adapters.py", line 445, in send timeout=timeout File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment raise six.reraise(type(error), error, _stacktrace) File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise raise value.with_traceback(tb) File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request six.raise_from(e, None) File "", line 2, in raise_from File "/Users/het/envs/py3/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request httplib_response = conn.getresponse() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse response.begin() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin version, status, reason = self._read_status() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 266, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "samples/vmc/sddc/sddc_crud.py", line 200, in main() File "samples/vmc/sddc/sddc_crud.py", line 192, in main sddc_operations.create_sddc() File "samples/vmc/sddc/sddc_crud.py", line 137, in create_sddc interval_sec=self.interval_sec) File "/Users/het/github/vsphere-automation-sdk-python/samples/vmc/helpers/vmc_task_helper.py", line 35, in wait_for_task task = task_client.get(org_id, task_id) File "/Users/het/envs/py3/lib/python3.6/site-packages/com/vmware/vmc/orgs_client.py", line 521, in get 'task': task, File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 317, in _invoke return self._api_interface.native_invoke(ctx, _method_name, kwargs) File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 243, in native_invoke method_result = self.invoke(ctx, method_id, data_val) File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 179, in invoke ctx) File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/security/client/security_context_filter.py", line 99, in invoke self, service_id, operation_id, input_value, new_ctx) File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/provider/filter.py", line 76, in invoke service_id, operation_id, input_value, ctx) File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/rest_connector.py", line 95, in invoke operation_rest_metadata, self._is_vapi_rest) File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/rest_connector.py", line 146, in _invoke http_response = self._http_provider.do_request(http_request) File "/Users/het/envs/py3/lib/python3.6/site-packages/vmware/vapi/protocol/client/rpc/requests_provider.py", line 98, in do_request cookies=http_request.cookies, timeout=timeout) File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/sessions.py", line 512, in request resp = self.send(prep, **send_kwargs) File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/sessions.py", line 622, in send r = adapter.send(request, **kwargs) File "/Users/het/envs/py3/lib/python3.6/site-packages/requests/adapters.py", line 495, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

Expected behavior

Pull task every 1min until the task is finished.

tianhao64 avatar Jun 15 '18 05:06 tianhao64

I'm also seeing this issue when testing the sample code found here: https://github.com/vmware/pyvmomi-community-samples/issues/247 To work around the issue, I'm decorating my method with https://github.com/jd/tenacity

tgelter avatar Sep 11 '19 17:09 tgelter