Libcloud
  1. Libcloud
  2. LIBCLOUD-199

Add http connection timeout to openstack and libcloud connections

    Details

      Description

      Authentication calls to an openstack endpoint (in this case Rackspace) will occasionally create a connection that will stay open indefinitely. By adding a timeout I can force the connection to close after a few seconds. That way I can catch this behavior with an exception and log the error before the server request times out. In this branch I add a timeout kwarg and set a reasonable default of 200 seconds.

        Activity

        Hide
        Tomaz Muraus added a comment -

        Merged into trunk, thanks.

        Show
        Tomaz Muraus added a comment - Merged into trunk, thanks.
        Hide
        Chris Gilmer added a comment -

        Added an openstack connection class test.

        Show
        Chris Gilmer added a comment - Added an openstack connection class test.
        Hide
        Chris Gilmer added a comment -

        This includes only the change to openstack common and a test that instantiates the base Connection class with the timeout variable set. The change to the libcloud common base was already merged.

        Show
        Chris Gilmer added a comment - This includes only the change to openstack common and a test that instantiates the base Connection class with the timeout variable set. The change to the libcloud common base was already merged.
        Hide
        Chris Gilmer added a comment -

        This is a fix to the openstack timeout default. I change it from 200s to None.

        Show
        Chris Gilmer added a comment - This is a fix to the openstack timeout default. I change it from 200s to None.
        Hide
        Chris Gilmer added a comment -

        Thanks for merging the timeout part. I'll work on the test case and I think I should leave out the timeout entirely for auth and set it as None. The original timeout of 200s is high but I grabbed that value from another connection timeout that was specified in the code. However, for backwards compatibility and to ensure I'm not setting a timeout that will break things, setting the value to None seems the better option. Again, thanks for helping me with this.

        Show
        Chris Gilmer added a comment - Thanks for merging the timeout part. I'll work on the test case and I think I should leave out the timeout entirely for auth and set it as None. The original timeout of 200s is high but I grabbed that value from another connection timeout that was specified in the code. However, for backwards compatibility and to ensure I'm not setting a timeout that will break things, setting the value to None seems the better option. Again, thanks for helping me with this.
        Hide
        Tomaz Muraus added a comment -

        Please also add a test case for instantiating the Connection class with a timeout argument. Thanks.

        Show
        Tomaz Muraus added a comment - Please also add a test case for instantiating the Connection class with a timeout argument. Thanks.
        Hide
        Tomaz Muraus added a comment -

        I merged your patch, but I skipped the changes in libcloud/common/openstack.py, because the timeout you specified (200 seconds) is too high imo.

        Show
        Tomaz Muraus added a comment - I merged your patch, but I skipped the changes in libcloud/common/openstack.py, because the timeout you specified (200 seconds) is too high imo.
        Hide
        Chris Gilmer added a comment -

        This patch fixes python 2.5 compatibility.

        Show
        Chris Gilmer added a comment - This patch fixes python 2.5 compatibility.
        Hide
        Chris Gilmer added a comment -

        I know we check the version of python to import certain libraries. Would this be a case for checking the version number and either calling a timeout or not? I'm also open to other ideas about how to get the timeout behavior I'm looking for.

        Show
        Chris Gilmer added a comment - I know we check the version of python to import certain libraries. Would this be a case for checking the version number and either calling a timeout or not? I'm also open to other ideas about how to get the timeout behavior I'm looking for.
        Hide
        Tomaz Muraus added a comment -

        I just checked the code and it looks like httplib in Python 2.5 doesn't support setting a timeout*.

        We need to make sure it also works with 2.5. One of the option would be to set a timeout on a socket, but I don't like this approach, because it's a global setting and also affects other socket operations (e.g. when calling deploy node, etc.)

        Show
        Tomaz Muraus added a comment - I just checked the code and it looks like httplib in Python 2.5 doesn't support setting a timeout*. We need to make sure it also works with 2.5. One of the option would be to set a timeout on a socket, but I don't like this approach, because it's a global setting and also affects other socket operations (e.g. when calling deploy node, etc.) http://docs.python.org/library/httplib.html
        Hide
        Chris Gilmer added a comment -

        This is the associated patch.

        Show
        Chris Gilmer added a comment - This is the associated patch.

          People

          • Assignee:
            Tomaz Muraus
            Reporter:
            Chris Gilmer
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2h
              2h
              Remaining:
              Remaining Estimate - 2h
              2h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development