UpCloudLtd / upcloud-ansible

Dynamic inventory and modules for managing servers via UpCloud's API
50 stars 17 forks source link

default_timeout: A float is required #25

Closed Teucka closed 4 years ago

Teucka commented 4 years ago

After the latest changes in master, we started encountering a type problem with the new "default_timeout" variable that was introduced. See the stack trace.

I'm sure a simple type conversion for "default_timeout" to float (or even int) before passing it to ServerManager or CloudManager does the trick.

I can try to provide more information if needed.

Here's the stack trace:

Traceback (most recent call last):
  File \"/tmp/ansible_aSi7uT/ansible_module_upcloud.py\", line 331, in main
    run(module, server_manager)
  File \"/tmp/ansible_aSi7uT/ansible_module_upcloud.py\", line 235, in run
    server = server_manager.find_server(uuid, hostname)
  File \"/tmp/ansible_aSi7uT/ansible_module_upcloud.py\", line 190, in find_server
    servers = self.manager.get_servers()
  File \"/usr/lib/python2.7/site-packages/upcloud_api/cloud_manager/server_mixin.py\", line 44, in get_servers
    servers = self.get_request(request)['servers']['server']
  File \"/usr/lib/python2.7/site-packages/upcloud_api/cloud_manager/base.py\", line 60, in get_request
    return self.request('GET', endpoint, timeout=timeout)
  File \"/usr/lib/python2.7/site-packages/upcloud_api/cloud_manager/base.py\", line 47, in request
    timeout=call_timeout)
  File \"/usr/lib/python2.7/site-packages/requests/api.py\", line 76, in get
    return request('get', url, params=params, **kwargs)
  File \"/usr/lib/python2.7/site-packages/requests/api.py\", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File \"/usr/lib/python2.7/site-packages/requests/sessions.py\", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File \"/usr/lib/python2.7/site-packages/requests/sessions.py\", line 643, in send
    r = adapter.send(request, **kwargs)
  File \"/usr/lib/python2.7/site-packages/requests/adapters.py\", line 449, in send
    timeout=timeout
  File \"/usr/lib/python2.7/site-packages/urllib3/connectionpool.py\", line 677, in urlopen
    chunked=chunked,
  File \"/usr/lib/python2.7/site-packages/urllib3/connectionpool.py\", line 381, in _make_request
    self._validate_conn(conn)
  File \"/usr/lib/python2.7/site-packages/urllib3/connectionpool.py\", line 978, in _validate_conn
    conn.connect()
  File \"/usr/lib/python2.7/site-packages/urllib3/connection.py\", line 309, in connect
    conn = self._new_conn()
  File \"/usr/lib/python2.7/site-packages/urllib3/connection.py\", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File \"/usr/lib/python2.7/site-packages/urllib3/util/connection.py\", line 71, in create_connection
    sock.settimeout(timeout)
  File \"/usr/lib64/python2.7/socket.py\", line 224, in meth
    return getattr(self._sock,name)(*args)
TypeError: a float is required
PopoSensei commented 4 years ago

Thanks for submitting. I'll look into it.

PopoSensei commented 4 years ago

Related PR #26

Teucka commented 4 years ago

Thanks for the quick response and fix! After a quick test, I can confirm that the error no longer appears with these changes.

PopoSensei commented 4 years ago

Merged