-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response connection is None on 3.9.0 #7867
Comments
Unfortunately, thats not a lot to go on. Any chance that you can bisect to find the regression? |
This comment was marked as resolved.
This comment was marked as resolved.
#79f5266518b58e1a778450c9b03bf337a7e01901 is the first bad commit |
So it would seem that it’s likely that fixing #7864 will also fix this problem as well. The good news is that one has a reproducer so it will be a bit easier to track down. |
Just noticed you linked a PR. Will try that with #7864 |
Looks like #7864 still fails with that change so something more is going on |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
My problem is not related to #7864 |
I tried the current master (after #7869) and the issue still exists. |
Finally was able to reproduce without aiodocker (by copying the interesting parts). import json
import aiohttp
import asyncio
async def main():
container_id = 'abaf180acb95e32cc60ed699a99b5756ef8a48c22a7d92cffdf98d30ef7b59f2'
async with aiohttp.ClientSession(connector=aiohttp.UnixConnector('/run/docker.sock')) as session:
response = await session.request(
'POST',
f'unix://localhost/v1.43/containers/{container_id}/exec',
headers={'Content-Type': 'application/json'},
data=json.dumps({
'Container': container_id,
'Privileged': False, 'Tty': False, 'AttachStdin': False, 'AttachStdout': True,
'AttachStderr': True, 'Cmd': ['ls'], 'Env': None, 'WorkingDir': '', 'detachKeys': '', 'User': ''
})
)
exec_id = (await response.json())['Id']
response = await session.request(
'POST',
f'unix://localhost/v1.43/exec/{exec_id}/start',
headers={'Content-Type': 'application/json', 'Connection': 'Upgrade', 'Upgrade': 'tcp'},
data=json.dumps({'Detach': False, 'Tty': False}),
read_until_eof=False
)
data = await response.read()
conn = response.connection
print(conn)
asyncio.run(main()) The |
I might be wrong, but I just realised 3.9.0 might have broken the all |
I believe it is documented behaviour that has always existed. There is no reason not to release the connection if we have finished reading from it. The change in 3.9 is more subtle, it now waits for the writer to complete before releasing the connection. It's possible a subtle change in that logic was overlooked and causing some issue. |
So is that mean upgrading a connection is no longer available (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade)? |
Shouldn't be, there are several tests for upgrade which are still passing. |
So I guess I am using the API incorrectly (and so the author of aiodocker), can you please help me with understanding what I am missing? |
There may still be a regression, it's just probably a more subtle edge case than you thought. It'd go a long way if you can add a test in a PR which reproduces the issue. |
Will a test using docker (same as the code above) will be ok? Can you please refer me to the current tests? |
Probably not, we don't have docker in the CI, and we have downstream packagers who need to run tests without docker. Test would probably go in |
I tried writing a test. but since I am not familiar with your code it might take me a couple of weeks, your help would really be appreciated (a release without breaking the API but with python3.12 support would also be appreciated) |
Wait, I missed this. This should print |
In 3.8.6 it keeps the connection and aiodocker uses this to upgrade the connection to tcp |
We have tests on 3.8 that say it shouldn't: aiohttp/tests/test_client_response.py Lines 220 to 222 in b51610b
I think what you want to be printing is |
Wait a moment, I didn't see |
It seems to me that if you use that parameter, then |
From a quick look I saw that response is not accessible to the |
I'm just sorting out a test at the moment. I think that attribute is accessible, but will get the test sorted first. |
Hmm, struggling to get a test that validates. Do you know what the server response looks like? This fails on 3.8:
|
I am not sure, but when printing
|
Hmm, I can only get it to fail or to hang... |
@matan1008
Than you can extract the raw read/write calls from the calls.log file to see whats actually being sent |
This is the request:
And this is the response:
|
OK, it's completely unrelated to that parameter (which I still don't understand what it does). Should have a fix shortly. |
Nope, I take it back. This test reproduces without extensions:
But, still fails with extensions. Is it possible you've installed a version without wheels, or otherwise disabled the extensions? |
I installed it regularly with pip (through aiodocker) |
Ah, I think I was right previously. It seems that the C parser only considers the connection upgraded when the Upgrade header is present, whereas the Py parser doesn't care if that header is present. Probably a bug to fix in the Py parser there. If you can test the change in the PR to double check it solves the problem for you, that'd be great. |
Will do tomorrow morning, thanks! |
Works great, Thank you! |
Describe the bug
Sorry for the not easily reproducible bug, but since 3.9.0 connection upgrading doesn't work
To Reproduce
I experienced the bug using aiodocker exec, so forgive me for indirect reproduce of the bug:
exec_ = await container.exec(command)
(the command doesn't matter, can be ls)async with exec_.start(detach=False) as stream:
Expected behavior
I used aiodocker version 0.21.0, when using aiohttp version 3.8.6 it works well (but uninstallable for python3.12), on version 3.9.0 it fails with Status code: 101 (aio-libs/aiodocker#832)
Logs/tracebacks
aiohttp Version
multidict Version
yarl Version
OS
Ubuntu
Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: