Skip to content

Python: build and deploy legacy parliament functions (deprecated)#3927

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
gauron99:push-toorvmxkxrls
Jul 3, 2026
Merged

Python: build and deploy legacy parliament functions (deprecated)#3927
knative-prow[bot] merged 1 commit into
knative:mainfrom
gauron99:push-toorvmxkxrls

Conversation

@gauron99

@gauron99 gauron99 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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.

@knative-prow

knative-prow Bot commented Jul 2, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow Bot added the do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. label Jul 2, 2026
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos July 2, 2026 10:54
@knative-prow knative-prow Bot added approved 🤖 PR has been approved by an approver from all required OWNERS files. size/XXL 🤖 PR changes 1000+ lines, ignoring generated files. labels Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.19048% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.18%. Comparing base (0ecc7a1) to head (2283ed6).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pkg/buildpacks/legacy_parliament.go 65.51% 7 Missing and 3 partials ⚠️
pkg/s2i/legacy_parliament.go 52.38% 7 Missing and 3 partials ⚠️
pkg/functions/legacy_parliament.go 86.11% 3 Missing and 2 partials ⚠️
pkg/buildpacks/builder.go 62.50% 3 Missing ⚠️
pkg/buildpacks/scaffolder.go 83.33% 1 Missing ⚠️
pkg/s2i/scaffolder.go 83.33% 1 Missing ⚠️
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     
Flag Coverage Δ
e2e 34.16% <44.44%> (+0.10%) ⬆️
e2e go 29.29% <10.98%> (-0.11%) ⬇️
e2e node 25.62% <7.69%> (-0.09%) ⬇️
e2e python 29.65% <17.58%> (-0.08%) ⬇️
e2e quarkus 25.75% <7.69%> (-0.10%) ⬇️
e2e rust 25.19% <0.00%> (-0.08%) ⬇️
e2e springboot 23.88% <0.00%> (-0.13%) ⬇️
e2e typescript 25.73% <7.69%> (-0.10%) ⬇️
e2e-config-ci 26.84% <17.58%> (-0.06%) ⬇️
integration 15.66% <6.59%> (-0.03%) ⬇️
unit macos-14 43.32% <70.32%> (+0.26%) ⬆️
unit macos-latest 43.32% <70.32%> (+0.26%) ⬆️
unit ubuntu-24.04-arm 43.62% <67.46%> (+0.25%) ⬆️
unit ubuntu-latest 44.17% <70.32%> (+0.26%) ⬆️
unit windows-latest 43.37% <70.32%> (+0.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 legacy assemble script + pins python-39 builder image.
  • Update Tekton buildpack task to propagate PIP_CONSTRAINT when constraints.txt is 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.

Comment thread pkg/buildpacks/legacy_parliament.go Outdated

@lkingland lkingland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 This is really looking great. More was needed than I expected, that's for sure

Comment thread e2e/e2e_core_test.go Outdated
Comment thread pkg/buildpacks/builder.go Outdated
@gauron99 gauron99 force-pushed the push-toorvmxkxrls branch 2 times, most recently from e6112d4 to e1e2e9b Compare July 2, 2026 18:20
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.
@gauron99 gauron99 force-pushed the push-toorvmxkxrls branch from e1e2e9b to 2283ed6 Compare July 2, 2026 21:05
@gauron99 gauron99 marked this pull request as ready for review July 3, 2026 12:08
@knative-prow knative-prow Bot removed the do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. label Jul 3, 2026
@gauron99 gauron99 requested a review from Copilot July 3, 2026 12:08

@lkingland lkingland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label Jul 3, 2026
@knative-prow

knative-prow Bot commented Jul 3, 2026

Copy link
Copy Markdown

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.

Comment on lines +210 to +213
if [ -f "$src_path/constraints.txt" ]; then
echo "--> Legacy parliament function detected, setting PIP_CONSTRAINT"
echo -n "constraints.txt" > "${ENV_DIR}/PIP_CONSTRAINT"
fi
Comment thread pkg/s2i/legacy_parliament.go
@knative-prow knative-prow Bot merged commit 89a927f into knative:main Jul 3, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. size/XXL 🤖 PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants