Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-1045

Python SDK 3.0.5 doesn't have error enum status for PingState

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.5
    • 3.0.7
    • None
    • None
    • 1
    • SDK46: TTL Imp., Bdura, Docs

    Description

      The Current Python SDK does not provide an "error" status in PingSate enumerator. Currently, it only has `Ok` and `Unknown` status but the server can raise an 'error' like in the example of an 'LCB_ERR_SOCKET_SHUTDOWN (1025): The remote host closed the connection' error.

      Step for Reproduction:

      • Deploy Couchbase Server and create a bucket. For my example, I used `travel-sample`.
      • Run the following code. This will start printing status as 'ok` continuously.

      from couchbase.cluster import Cluster, ClusterOptions
      from couchbase.cluster import PasswordAuthenticator
       
      cluster = Cluster('couchbase://10.112.201.101', ClusterOptions(PasswordAuthenticator('Administrator', 'password')))
      cb = cluster.bucket('travel-sample')
       
      while True:
          status = cb.ping()
       
          for name, endpoints in status.endpoints.items():
              for endpoint in endpoints:
                  status = endpoint.state.value
                  print(status)
      

      • Suspend your instance which will halt the cluster connection. On console, you will stop seeing "ok" getting printed. After some time a timeout will occur and the following error is generated

      ok
      ok
      ok
      timeout
      ValueError: 'error' is not a valid PingState
       
      During handling of the above exception, another exception occurred:
       
      Traceback (most recent call last):
        File "/Users/yuvrajkanwar/PycharmProjects/demo1/demo.py", line 13, in <module>
          status = endpoint.state.value
        File "/Users/yuvrajkanwar/PycharmProjects/demo1/venv/lib/python3.7/site-packages/couchbase/diagnostics.py", line 212, in state
          return PingState(self._src_ping.get('status', None))
        File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/enum.py", line 310, in __call__
          return cls.__new__(cls, value)
        File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/enum.py", line 564, in __new__
          raise exc
        File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/enum.py", line 548, in __new__
          result = cls._missing_(value)
        File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/enum.py", line 577, in _missing_
          raise ValueError("%r is not a valid %s" % (value, cls.__name__))
      ValueError: 'error' is not a valid PingState
      

      Please also find attached the screenshot of my reproduction.

      Attachments

        For Gerrit Dashboard: PYCBC-1045
        # Subject Branch Project Status CR V

        Activity

          There are no comments yet on this issue.

          People

            david.kelly David Kelly
            yuvraj.kanwar Yuvraj Kanwar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty