Skip to content
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

u-u: import "email.genators" package early as workaround #371

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

mvo5
Copy link
Owner

@mvo5 mvo5 commented Nov 10, 2024

This commit works around an issue when python itself is upgraded
by u-u and the content of email.message now needs a newer email.errors
but u-u already (implicitely) loaded that module so there is a
old version in sys.modules. So instead import email.generators early
so that it is available in memory and there is no mismatch.

See python/cpython#124170 and
https://bugs.launchpad.net/ubuntu/+source/python3.8/+bug/2080940
for details.

Unfortunately while this commit fixes the autopkgtest failure that
is now triggered by this the real issue that the users see is not
fixed because the "old" unattended-upgrades will perform the upgrade
and it will upgrade both the problematic python and the fixed u-u
but because u-u does not re-exec the "old" u-u still runs and the
fixed code from u-u will not be used.

Thanks to Julian Klode for his excellent analysis.

@mvo5 mvo5 force-pushed the workaround-lp2080940 branch 5 times, most recently from 9fa4d29 to b2a85ab Compare November 10, 2024 12:45
@julian-klode
Copy link
Contributor

It does but it's also not doing anything at all for this issue - the python update is already released and we can't make unattended-upgrades upgrade itself first and then re-exec itself to enable the fix.

For the future proofing, it may be nicer to avoid the lazy import inside the function and handle all imports up-front, but I don't think that helps enough because the email module imports more modules dynamically.

It's been some time since looking at this.

@mvo5 mvo5 changed the title u-u: reload the "email.errors" package to workaround (LP: 2080940) u-u: load the "email.generators" package to workaround (LP: 2080940) Nov 10, 2024
@mvo5
Copy link
Owner Author

mvo5 commented Nov 10, 2024

It does but it's also not doing anything at all for this issue - the python update is already released and we can't make unattended-upgrades upgrade itself first and then re-exec itself to enable the fix.
[..]

Yeah, that is of course true, merging this at least helps with the autopkgtest failure. I guess if we wanted to fix for real we would have to add a "Breaks: u-u (<< 2.12)" to the problematic python upgrade, then send a sigterm from the u-u postinst to u-u itself for this one upgrade. This should stop it gracefully and then the postinst would have to restart it by triggering the daily time job again. But that of course is all pretty ugly and error prone :( Plus the problematic update went out a while ago already.

For the future proofing, it may be nicer to avoid the lazy import inside the function and handle all imports up-front, but I don't think that helps enough because the email module imports more modules dynamically.

Another idea for future proofing might be to always upgrade u-u first and re-exec if u-u is part of the upgrade set(?).

It's been some time since looking at this.

Thanks, for your super useful analysis :)

I will merge mostly for the benefit of autopkgtest but you are right, this will not help with the real issue unless people upgrade u-u manually early.

This commit works around an issue when python itself is upgraded
by u-u and the content of email.message now needs a newer email.errors
but u-u already (implicitely) loaded that module so there is a
old version in sys.modules. So instead import email.generators early
so that it is available in memory and there is no mismatch.

See python/cpython#124170 and
https://bugs.launchpad.net/ubuntu/+source/python3.8/+bug/2080940
for details.

Unfortunately while this commit fixes the autopkgtest failure that
is now triggered by this the real issue that the users see is not
fixed because the "old" unattended-upgrades will perform the upgrade
and it will upgrade both the problematic python and the fixed u-u
but because u-u does not re-exec the "old" u-u still runs and the
fixed code from u-u will not be used.

Thanks to Julian Klode for his excellent analysis.
@mvo5 mvo5 force-pushed the workaround-lp2080940 branch from b2a85ab to b908b17 Compare November 10, 2024 18:44
@mvo5 mvo5 changed the title u-u: load the "email.generators" package to workaround (LP: 2080940) u-u: import "email.genators" package early as workaround Nov 10, 2024
@mvo5 mvo5 merged commit ca9c9e0 into master Nov 10, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants