Skip to content

pipelines: ship effective config inside the source upload#3919

Open
gauron99 wants to merge 1 commit into
knative:mainfrom
gauron99:push-ulyqmtltmpwu
Open

pipelines: ship effective config inside the source upload#3919
gauron99 wants to merge 1 commit into
knative:mainfrom
gauron99:push-ulyqmtltmpwu

Conversation

@gauron99

Copy link
Copy Markdown
Contributor

Remote (direct upload) builds wrote func.yaml to disk before uploading sources, so
the on-cluster deploy step would pick up deploy-time flags.

Instead, synthesize the uploaded func.yaml from the in-memory function:
sourcesAsTarStream serializes the effective config into the stream (via the new
fn.MarshalFuncYaml, shared with Function.Write) and skips the on-disk copy

Changes

  • 🐛 A failed remote deploy no longer mutates the working tree; func.yaml is written only after success, like local deploys.
  • 🧹 Replace the pre-deploy func.yaml write with in-memory synthesis into the source upload.
  • 🧹 Add fn.MarshalFuncYaml, shared by Function.Write and the upload path.

/kind bug

…eploy func.yaml write

Remote (direct upload) builds previously wrote func.yaml to disk before
the pipeline uploaded sources, so the on-cluster deploy step would see
deploy-time flags (--image-pull-secret, --service-account, --deployer, the
target namespace, ...). That was a workaround with two real costs: a mere
deployment attempt mutated the user's working tree before success, and for
git-flavor builds it never worked at all (the pipeline checks out the
remote repository; a local write cannot reach it).

Instead, synthesize the uploaded func.yaml from the in-memory, fully
configured function: sourcesAsTarStream now serializes the effective
configuration into the stream (via the new fn.MarshalFuncYaml, shared with
Function.Write) and skips the on-disk copy. The on-cluster deploy step
reads the same file it always did -- it just now reflects the actual
request. The working tree is persisted only after the deployment succeeds,
exactly like local deploys.

Git-flavor builds are intentionally unchanged: they deploy the committed
configuration, which is the GitOps contract.
@gauron99 gauron99 requested a review from Copilot June 25, 2026 12:08
@knative-prow knative-prow Bot added the kind/bug Bugs label Jun 25, 2026
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos June 25, 2026 12:08
@knative-prow

knative-prow Bot commented Jun 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99

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

@knative-prow knative-prow Bot added approved 🤖 PR has been approved by an approver from all required OWNERS files. size/L 🤖 PR changes 100-499 lines, ignoring generated files. labels Jun 25, 2026
@gauron99 gauron99 requested review from lkingland and matejvasek and removed request for dsimansk and jrangelramos June 25, 2026 12:08

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 fixes remote (direct-upload) deploy behavior so the func.yaml included in the uploaded sources reflects the effective in-memory function configuration (including deploy-time flag overrides), while avoiding any pre-deploy mutation of the working tree.

Changes:

  • Validate the in-memory fn.Function before direct-upload and serialize its effective config directly into the uploaded tar stream as source/func.yaml.
  • Add Function.MarshalFuncYaml() and reuse it from Function.Write() so both disk persistence and upload serialization share the same formatting (schema header + YAML).
  • Remove the pre-pipeline func.yaml write from remote deploys and adjust/add tests to ensure the working tree is only written after successful deploy.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/pipelines/tekton/pipelines_provider.go Validates f before direct-upload and injects a synthesized func.yaml into the upload tar stream while skipping the on-disk func.yaml.
pkg/pipelines/tekton/pipelines_provider_test.go Adds coverage ensuring exactly one func.yaml is uploaded, matches MarshalFuncYaml(), parses correctly, and does not mutate the on-disk file.
pkg/functions/function.go Introduces MarshalFuncYaml() and refactors Write() to use it, centralizing func.yaml serialization.
cmd/deploy.go Removes the pre-remote-deploy f.Write() so remote deploy attempts don’t dirty the working tree.
cmd/deploy_test.go Updates remote deploy test expectations: effective config is passed to pipeline, disk is unchanged until success, then persisted after success.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/functions/function.go
Comment on lines +456 to +457
// and by direct-upload remote build which use this in-memory serialization
// of func.yaml instead of the on-disk one (which can be outdated via flag
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.81395% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.01%. Comparing base (0ecc7a1) to head (0100879).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/pipelines/tekton/pipelines_provider.go 54.83% 11 Missing and 3 partials ⚠️
pkg/functions/function.go 58.33% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3919   +/-   ##
=======================================
  Coverage   54.00%   54.01%           
=======================================
  Files         200      200           
  Lines       23687    23706   +19     
=======================================
+ Hits        12793    12804   +11     
- Misses       9659     9666    +7     
- Partials     1235     1236    +1     
Flag Coverage Δ
e2e 34.07% <51.16%> (+0.01%) ⬆️
e2e go 29.45% <64.70%> (+0.05%) ⬆️
e2e node 25.79% <64.70%> (+0.07%) ⬆️
e2e python 29.78% <64.70%> (+0.05%) ⬆️
e2e quarkus 25.91% <64.70%> (+0.06%) ⬆️
e2e rust 25.33% <64.70%> (+0.06%) ⬆️
e2e springboot 24.07% <64.70%> (+0.06%) ⬆️
e2e typescript 25.90% <64.70%> (+0.06%) ⬆️
e2e-config-ci 26.88% <20.58%> (-0.03%) ⬇️
integration 15.75% <64.70%> (+0.05%) ⬆️
unit macos-14 43.09% <64.70%> (+0.04%) ⬆️
unit macos-latest 43.09% <64.70%> (+0.04%) ⬆️
unit ubuntu-24.04-arm 43.38% <55.81%> (+0.01%) ⬆️
unit ubuntu-latest 43.95% <64.70%> (+0.03%) ⬆️
unit windows-latest 43.16% <64.70%> (+0.04%) ⬆️

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.

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. kind/bug Bugs size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants