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

[infra] upgrade python #9532

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

[infra] upgrade python #9532

wants to merge 6 commits into from

Conversation

jonathanmetzman
Copy link
Contributor

No description provided.

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py all --sanitizer coverage address --fuzzing-engine libfuzzer

@jonathanmetzman
Copy link
Contributor Author

Github is breaking this by messing with something bazel (which i really wish we weren't installing in base images) depends on: https://twitter.com/mihaimaruseac/status/1620179105038876672

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py all --sanitizer coverage address --fuzzing-engine libfuzzer

@jonathanmetzman
Copy link
Contributor Author

failures
tint
spirv-tools
pycrypto
wheel
proto-plus-python
http-pattern-matcher
airflow

spurious
wolfssl
cel-cpp
wolfmqtt
tinyusb
tensorflow
jersey

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py tint spirv-tools pycrypto wheel proto-plus-python http-pattern-matcher airflow --sanitizer coverage address --fuzzing-engine libfuzzer

@jonathanmetzman
Copy link
Contributor Author

@nareddyt this CL will break http-pattern-matcher when it lands.

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py all

@nareddyt
Copy link
Contributor

http-pattern-matcher is stable and in maintenance mode, so I am not too worried. Fuzzer hasn't found anything recently

@jonathanmetzman
Copy link
Contributor Author

it's really hard to make sense of the failures because of the libxml2 repo breakage and introspector's bad state (breaking everywhere) I'm gonna retry without introspector.

fails:
glib https://pantheon.corp.google.com/cloud-build/builds;region=us-central1/9d040cc7-10a3-4bcd-80b0-544423fdc6e4?project=oss-fuzz
gdk-pixbuf https://pantheon.corp.google.com/cloud-build/builds;region=us-central1/24d24b26-6f9d-4aaa-a2aa-82fc6f25a944?project=oss-fuzz
wheel https://pantheon.corp.google.com/cloud-build/builds;region=us-central1/27eac926-2554-4f1f-a192-2b634fcac6d8?project=oss-fuzz
python-rsa https://pantheon.corp.google.com/cloud-build/builds;region=us-central1/8f20b1f8-fcfc-42a5-bdaf-03a7dc53457a;tab=detail?project=oss-fuzz
proto-plus-python https://pantheon.corp.google.com/cloud-build/builds;region=us-central1/41313c36-c59f-4042-bd8b-d15554e79687;tab=detail?project=oss-fuzz

spurious:
ffmpeg
libprotobuf-mutator
libarchive
irssi
tinyusb
naga
htmlunit
graphicsmagick
fwupd
fluxcd
gstreamer
igraph
wolfssl
wolfmqtt
poppler
ostree
mapserver
lxml
libxslt
libxml2

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py all --sanitizer coverage address memory undefined none

@jonathanmetzman
Copy link
Contributor Author

spurious:
cloud-hypervisor
fabric
cryptofuzz
minify
miniz
ygot
suricata
htmlunit
bitcoin-core

real:
wheel
pycrypto
proto-plus-python
http-pattern-matcher
libecc
tinyusb

?
wolfmqtt
libecc
wolfssl
tensorflow
cel-cpp

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py wolfmqtt libecc wolfssl tensorflow cel-cpp wheel pycrypto proto-plus-python http-pattern-matcher libecc tinyus bcloud-hypervisor fabric cryptofuzz minify miniz ygot suricata htmlunit bitcoin-core --sanitizer coverage address memory undefined none

@jonathanmetzman
Copy link
Contributor Author

If this breaks less than 10 projects in the end I think i will merge.

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py wolfmqtt libecc wolfssl tensorflow cel-cpp wheel pycrypto proto-plus-python http-pattern-matcher libecc tinyus bcloud-hypervisor fabric cryptofuzz minify miniz ygot suricata htmlunit bitcoin-core --sanitizer coverage address memory undefined none

@jonathanmetzman
Copy link
Contributor Author

Fuzz introspector depends on python3.9 right @DavidKorczynski ?

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py wolfmqtt libecc wolfssl tensorflow cel-cpp wheel pycrypto proto-plus-python http-pattern-matcher libecc tinyus bcloud-hypervisor fabric cryptofuzz minify miniz ygot suricata htmlunit bitcoin-core --sanitizer coverage address memory undefined none introspector

@DavidKorczynski
Copy link
Collaborator

Fuzz introspector depends on python3.9 right @DavidKorczynski ?

In general Python 3.9+ should be fine, but let me double check tomorrow if 3.10.8 has no issues and update if so.

One area where we depend on 3.9 is

# We must ensure python3.9, this is because we use certain
# AST logic from there.
# The below should probably be refined
apt-get install -y python3.9
apt-get update
apt-get install -y python3-pip
python3.9 -m pip install virtualenv
python3.9 -m virtualenv .venv
and this may take some bigger effort to resolve, because that logic relies on AST parsing which may (I think it did) change between 3.9 and 3.10.8. But I assume we can leave those lines as is?

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py wolfmqtt libecc wolfssl tensorflow cel-cpp wheel pycrypto proto-plus-python http-pattern-matcher libecc tinyus bcloud-hypervisor fabric cryptofuzz minify miniz ygot suricata htmlunit bitcoin-core --sanitizer coverage address memory undefined none introspector

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py all

@jonathanmetzman
Copy link
Contributor Author

/gcbrun trial_build.py wolfmqtt

DaveLak added a commit to DaveLak/oss-fuzz that referenced this pull request Jun 4, 2024
The changes introduced here upgrade Python from 3.8 to 3.10.14 inside
the base-builder and base-runner images.

 ### base-builder changes:

Prior to these changes, base-builder compiled Python 3.8 from source
using sources downloaded from the official release servers at
https://www.python.org/ftp/python/. This updates the compiled version
to 3.10.14 (the latest 3.10 release) instead.

 ### base-runner changes:

Prior to these changes, base-runner installed Python 3.8 from the
default apt repository provided by the Ubuntu 20.04 image it's based
on. These apt repositories do not have a version of Python 3.10
available by default. This updates the base-runner to instead use a
multi-stage build to copy the same Python interpreter compiled by the
base-builder image into the runner image, which ensures both Python
versions remain in-sync while saving build time by re-using a pre-built
version.

 ## Motivation

- Code coverage does not work on Python projects that use Python 3.10+
  syntax, and will not work until this or similar changes are landed
  (see google#11419)
- Upgrading the base-image to use Ubuntu 22.04 (which provides more
  recent Python versions via apt) has been stated as being unlikely to
  happen any time soon (see google#3290)
- Many OSS-Fuzz integrated Python projects no longer support Python 3.8
  and have resorted to implementing ad-hoc workarounds to upgrade to
  newer Python versions, including installing Python from the Dead
  Snakes PPA.
  - This leads to fragmentation and hard to debug issues. Maintenance
    is easier when everyone is using the same version without issue.
- With [Python 3.8 reaching end of life soon (in 2024-10)][python-
  versions-EOL], it is likely that more Python projects will begin
  dropping support for 3.8, further increasing the number of broken
  builds and ad-hoc workarounds.
- Previous attempts at upgrading Python have stalled.

 ## Known & Expected Issues

Several project Dockerfiles and build scripts contain hard coded
references to python3.8 file system paths, and many more have implanted
ad-hoc workarounds to upgrade to newer Python versions than 3.8
(typically 3.9.) Additional changes are required to each of these
projects to ensure they successfully build after this upgrade to Python
3.10.

 ### Fuzz Introspector Caveat

Fuzz Introspector currently uses Python 3.9. While an upgrade to 3.10 is
not expected to introduce any new issues, it was not tested on these
changes and may require additional work.

 ## Possible Areas of Improvement

Using the base-builder image in a multi-stage build to copy the pre-
compiled Python into base-runner is effective, but feels like a
workaround that may be introducing tech debt. A cleaner approach would
be to extract the Python compilation into a discrete base image similar
to how `base-clang` works, and use that as the multi-stage builder in
images that need it.

---

Fixes:
- google#11419

Supersedes:
- google#9532
- google#11420

[python-versions-EOL]: https://devguide.python.org/versions/
@DaveLak
Copy link
Contributor

DaveLak commented Jun 4, 2024

@jonathanmetzman I took a slightly different approach at this in #12027. I've tested it locally with most of the projects that failed on this PR. Most of them seem to be passing, and I've flagged or drafted a patch for those that didn't.

Would you please take a look and let me know what you think whenever you get a chance?

Thanks!

@jonathanmetzman
Copy link
Contributor Author

Let me try when I get back in the office, sure

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.

None yet

4 participants