Python: build and deploy legacy parliament functions (deprecated)#3927
Conversation
|
Skipping CI for Draft Pull Request. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3927 +/- ##
==========================================
+ Coverage 54.00% 54.18% +0.18%
==========================================
Files 200 203 +3
Lines 23687 23807 +120
==========================================
+ Hits 12793 12901 +108
- Misses 9659 9669 +10
- Partials 1235 1237 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d61ecd5 to
9cb4e9b
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds explicit support for deprecated “parliament-style” Python functions (root func.py with def main(context) and a python -m parliament Procfile) so they continue to build and deploy on modern func via pack and s2i, while rejecting other pre-v1.18 Procfile-based Python layouts with a clear migration error. It also ensures legacy builds pin cloudevents to <2 (required by parliament), and blocks legacy layouts on the host builder/runner with actionable errors.
Changes:
- Detect legacy parliament vs. unsupported legacy Procfile Python layouts and route build/run behavior accordingly.
- Add legacy build paths: pack writes/uses
constraints.txt(cloudevents pin) and s2i writes a legacyassemblescript + pins python-39 builder image. - Update Tekton buildpack task to propagate
PIP_CONSTRAINTwhenconstraints.txtis present, plus add unit/e2e coverage across builders.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/s2i/scaffolder.go | Bypasses modern scaffolding for legacy parliament; rejects other legacy Procfile layouts. |
| pkg/s2i/legacy_parliament.go | Adds legacy s2i assemble writer + python-39 builder pinning for parliament functions. |
| pkg/s2i/legacy_parliament_test.go | Unit tests for legacy s2i scaffold behavior, assemble script contents, and image override logic. |
| pkg/s2i/builder.go | Applies legacy image pin via BuilderImage to cover local + generated remote pipelines. |
| pkg/pipelines/tekton/task-buildpack.yaml.tmpl | Sets PIP_CONSTRAINT for remote builds when legacy constraints.txt exists. |
| pkg/pipelines/tekton/legacy_parliament_test.go | Verifies Tekton task rendering includes the PIP_CONSTRAINT wiring. |
| pkg/oci/legacy_parliament.go | Defines host-builder rejection error for legacy parliament functions. |
| pkg/oci/legacy_parliament_test.go | Tests host builder rejects legacy parliament and unsupported legacy Procfile layouts, but not modern Python. |
| pkg/oci/builder.go | Adds early rejections for legacy parliament and unsupported legacy Procfile Python layouts on host builder. |
| pkg/functions/legacy_parliament.go | Implements filesystem-based detection for legacy parliament and unsupported legacy Procfile Python layouts. |
| pkg/functions/legacy_parliament_test.go | Unit tests for legacy parliament detection and false-positive guards. |
| pkg/buildpacks/scaffolder.go | Skips modern pack scaffolding for legacy parliament and rejects unsupported legacy Procfile layouts. |
| pkg/buildpacks/legacy_parliament.go | Implements legacy pack path: warn, clear stale scaffolding, write constraints, and inject PIP_CONSTRAINT. |
| pkg/buildpacks/legacy_parliament_test.go | Unit tests for legacy pack scaffolding, constraints writing behavior, and env injection. |
| pkg/buildpacks/builder.go | Skips python pre-buildpack for legacy parliament and injects constraints env instead. |
| e2e/e2e_core_test.go | Adds e2e coverage to ensure legacy parliament functions deploy with both pack and s2i. |
| cmd/run.go | Rejects legacy parliament and unsupported legacy Procfile layouts for func run --builder=host. |
| cmd/legacy_parliament_test.go | CLI tests ensuring host-run rejects legacy parliament and unsupported legacy Procfile layouts before build/run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lkingland
left a comment
There was a problem hiding this comment.
🎉 This is really looking great. More was needed than I expected, that's for sure
e6112d4 to
e1e2e9b
Compare
Old parliament-style Python functions (bare func.py with def main(context), Procfile "web: python -m parliament .", requirements.txt) keep building and deploying on modern func instead of breaking in the ASGI scaffolding: - pack + s2i detect the legacy layout and skip modern scaffolding, building the pre-v1.18 way from the user's own Procfile + requirements.txt. - cloudevents is pinned below 2.0 during the build (parliament-functions leaves it unpinned; cloudevents 2.x removed cloudevents.http and crashes the stack): pack via constraints.txt + PIP_CONSTRAINT (local and remote/Tekton), s2i via the legacy assemble script. The s2i builder image is pinned back to ubi8/python-39 unless the user overrides it. - host builder and host runner reject with a clear error pointing at pack/s2i. - the other pre-v1.18 Procfile-based python layouts (the old flask/wsgi templates: root Procfile, no root pyproject.toml) are detected and rejected with a clear migration error instead of failing confusingly inside modern scaffolding. - a deprecation warning is emitted on every build, pointing at the current Python function layout docs. All legacy logic lives in per-package legacy_parliament.go files; every inline touch is a marked one-liner (grep "LEGACY PYTHON") so sunset removal is: delete the files, grep, delete the guards, compile.
e1e2e9b to
2283ed6
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gauron99, lkingland The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| if [ -f "$src_path/constraints.txt" ]; then | ||
| echo "--> Legacy parliament function detected, setting PIP_CONSTRAINT" | ||
| echo -n "constraints.txt" > "${ENV_DIR}/PIP_CONSTRAINT" | ||
| fi |
Old parliament-style Python functions (bare func.py with def main(context), Procfile "web: python -m parliament .", requirements.txt) keep building and deploying on modern func instead of breaking in the ASGI scaffolding:
All legacy logic lives in per-package legacy_parliament.go files; every inline touch is a marked one-liner (grep "LEGACY PYTHON") so sunset removal is: delete the files, grep, delete the guards, compile.