A few more details on the issue:

Calico includes a workaround to this bug that ties our hands [1]. If I
proceed with the SRU as it is currently proposed, it will break Calico
on Ubuntu 22.04 and 24.04. If I don't, the bug will continue to exist in
22.04 and 24.04.

For clarity, I will be referring to the etcd3gw upstream at [2].

It is possible to adjust the patch to keep it from breaking Calico:
```py
kwargs['timeout'] = self.timeout
resp = getattr(self.session, method)(*args, **kwargs)
```
instead of this:
```py
resp = getattr(self.session, method)(*args, timeout=self.timeout, **kwargs)
```

However, that change would be incorrect. The existing code fails when a
timeout is passed to `Etcd3Client._request` (or its predecessor `post`
in older versions). This is because the semantically correct way of
enforcing a timeout on Etcd3Client's requests is to pass the timeout to
the client's constructor instead of passing it to each request [3].

If the timeout could be specified for each request (e.g. the `create` or
`delete` methods [3]), then there might be an argument that timeouts
should be request/transport-scoped in the Etcd3Client as they are in the
requests library [4]. This is a conversation that would need to happen
with upstream.

The change above introduces ambiguity: which timeout takes priority when
passed as kwargs to `Etcd3Client._request`? A user might reasonably
expect to pass a timeout to the client but allow that value to be
overridden on a per-request basis. As it stands, the client's timeout
always wins, and a user expecting per-request timeouts will get an
error. The change above masks that error.

In order to fix this bug properly we'd need to have a conversation with
upstream to resolve request/transport-scoped timeouts, and it's far from
clear that the result of that coversation would be compatible with the
problematic Calico code.

[1] 
https://github.com/projectcalico/calico/blob/master/networking-calico/networking_calico/etcdv3.py#L492-L500
[2] 
https://opendev.org/openstack/etcd3gw/src/branch/master/etcd3gw/client.py#L115
[3] https://docs.openstack.org/etcd3gw/latest/api/etcd3gw.client.html
[4] https://github.com/psf/requests/issues/1130


** Bug watch added: github.com/psf/requests/issues #1130
   https://github.com/psf/requests/issues/1130

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2012261

Title:
  Timeout not correctly set inside requests session object

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-etcd3gw/+bug/2012261/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to