Conversation
|
Skipping CI for Draft Pull Request. |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🟡 Changes recommended
Remote metadata, built source, and persisted deployment identity can diverge in several supported flows.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Enables remote git deployments without a local function checkout and includes the CoreDNS rollout prerequisite.
Changes:
- Loads and migrates
func.yamldirectly from git. - Resolves source commits and cleans Tekton workspaces before cloning.
- Updates CLI flows, tests, E2E coverage, and documentation.
File summaries
| File | Description |
|---|---|
pkg/pipelines/tekton/templates.go |
Supports rootless functions and commit labels. |
pkg/pipelines/tekton/templates_test.go |
Tests rootless pipeline rendering. |
pkg/pipelines/tekton/tasks_test.go |
Verifies cleanup-step ordering. |
pkg/pipelines/tekton/task-s2i.yaml.tmpl |
Cleans git source workspace. |
pkg/pipelines/tekton/task-buildpack.yaml.tmpl |
Cleans git source workspace. |
pkg/pipelines/tekton/source_commit_test.go |
Tests source commit resolution. |
pkg/pipelines/tekton/pipelines_provider.go |
Resolves commits before resource creation. |
pkg/functions/git_commit.go |
Adds remote commit lookup. |
pkg/functions/function.go |
Parses rootless serialized functions. |
pkg/functions/function_migrations.go |
Migrates directly from serialized bytes. |
pkg/functions/function_git.go |
Loads functions from git revisions. |
pkg/functions/function_git_test.go |
Tests git loading and migration. |
pkg/functions/client.go |
Reuses serialized-function parsing. |
pkg/cluster/dns.go |
Waits for the CoreDNS rollout. |
e2e/e2e_remote_test.go |
Removes local checkout workarounds. |
docs/reference/func_deploy.md |
Documents checkout-free deployment. |
cmd/run.go |
Supplies function context to prompts. |
cmd/deploy.go |
Selects and persists remote functions. |
cmd/deploy_test.go |
Tests checkout-free deploy behavior. |
cmd/config_git_set.go |
Supplies function context to prompts. |
cmd/build.go |
Supplies function context to prompts. |
Review details
- Files reviewed: 21/22 changed files
- Comments generated: 5
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
a2d8a9a to
4ebfbf9
Compare
4ebfbf9 to
0640992
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Remote configuration precedence, prompt source switching, and local state persistence can deploy or record the wrong function state.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 2
Open (3)
Resolved since last review (5)
This resolves the SHA only for the image label; the PipelineRun still receives… This state is not sufficient fordescribeordeletewhen the local and repository functions… The repository function is loaded only after the command defaults were derived from the local… Assigning the companion local function here falls through to the unconditionalStamp()below,… An interactive remote deployment can changeGitURLinPrompt, but this reload is skipped when…
0640992 to
acbe413
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Interactive choices can be overwritten, and rootless source revision handling can panic or apply an unrelated local commit label.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 2
Open (5)
Resolved since last review (2)
acbe413 to
a14955f
Compare
…d at The image's revision label came from the local checkout's HEAD for every remote build. For a function read from its repository that is the wrong commit, or none. Source gains an in-memory Commit, the hash the revision resolved to when the function was read; when set, the PipelineRun fetches that commit and labels the image with it, so what was read is what is built. Uploaded sources keep the local HEAD. The PipelineRun no longer turns an empty revision into a hard-coded "main": the revision goes to the fetch step as configured, and an empty one fetches the remote's default branch, whatever its name.
NewFunctionFromGit reads func.yaml from a revision of a remote repository (default branch, branch, tag or commit hash) in memory, and records the commit that revision resolved to in Build.Source.Commit, for the build to fetch and label. It reuses the credential lookup the template repositories already use. Migrations used to re-read the on-disk func.yaml from f.Root to see the previous structure, so a function with no working tree could not be migrated. hasInitializedFunction in the client hit the same problem by migrating an unmarshalled function that had no Root. Migrations now receive the serialized bytes they were parsed from, and NewFunction, NewFunctionFromGit and hasInitializedFunction share parseFunction. The build prompt takes the function instead of reading it from a path, so it works for a function that is not on disk. It no longer asks for the project path: every other default it offers already came from the function at the original path, and a changed answer was reloaded by build and run but silently ignored by deploy and config git set. The path is given with --path, as before, and each command reads the function once. Groundwork for knative#3203.
The git-clone StepAction runs as user 65532 and empties the source workspace before cloning. The previous run of the pipeline leaves the sources there owned by the build user (the prepare step chowns the tree to 1001 for the buildpacks lifecycle), which 65532 can neither delete nor create .git next to. Every remote build of a function from git after its first therefore failed in the fetch step, until func delete removed the volume. A clean-src step, run as root and gated on a git URL like fetch-src, now empties the workspace and hands the directory to the clone user before the clone. The upload path is unaffected, and the cache workspace is a separate directory that is left alone.
The flag defaults of deploy are derived from the function in the current directory when the command is built, so a local func.yaml is honoured unless a flag or environment variable overrides it. A function read from a git repository is known only at run time and got no such treatment: from an empty directory the static defaults applied, and Configure then overwrote, for example, the repository's s2i builder with pack. withFunctionDefaults gives the config the defaults NewDeployCmd would have registered had the repository's function been the local one, for every flag the user did not set. The reload after the prompt now also happens when the prompt changed the git source of a function that already came from git, not only when it made a local function remote.
A remote deployment of a git repository recorded the git settings and the outcome (image, namespace, deployer, exposure) on whatever local function was at the path, a habit from when the local func.yaml was the source of such a deployment. It was wrong for a checkout on another branch, misleading for a different function, and it stamped sources that were never built. Such a deployment is now a deployment by reference: the function is read from the repository, deployed, and nothing is written, neither to the repository nor to the current directory. To change a function that lives in a repository, clone it, edit it and deploy the working tree. A func.yaml may still carry build.source settings, which serve as the defaults of the --source flags. Loading is one function, loadFunction, without a local function to consult.
a14955f to
535e5cf
Compare
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
this PR is broken down into smaller items of which first one is #4064, closing that in favor of 4064 |



Changes
func deploy --remote --sourcebuilt the pipeline from the localfunc.yamlwhile the cluster cloned the repository and read its own. The local copy existed only to feed the CLI, so it was required and had to match the revision and directory being built.NewFunctionFromGitreadsfunc.yamlfrom the requested revision (the remote's default branch, a branch, a tag or a commit) and--source-dir, in memory and with no checkout, and the flags apply to that. A local function at the path is optional; when present it only records the source settings and the outcome (image, namespace, deployer, exposure). An unknown revision fails in the CLI before any cluster resource is created. Migrations take the serialized bytes instead of re-readingf.Root, so a function without a working tree can be migrated.Build.Source.Commit, never written tofunc.yaml), the PipelineRun fetches that hash, and the image carries it inorg.opencontainers.image.revision. Before, the cluster cloned by name, so a branch could move between the read and the build, and the label was the local checkout's HEAD: the wrong commit for a git source, and missing without one. Uploaded sources are unchanged and keep the local working tree's HEAD.main. It reaches the git-clone step as configured, and git then fetches the remote's default branch, whatever it is called. The revision is also quoted in both PipelineRun templates, so a tag such as1.10is no longer read as the number1.1.clean-srcstep empties the workspace before the clone; the upload path and the cache workspace are untouched.Pre-existing and out of scope: deploy intent given on the command line (
--env,--deployer,--expose,--service-account) does not reach the cluster in the git path. The PipelineRun carries build inputs only, and the deploy step reads the repository's committedfunc.yaml; on the upload path the same flags do travel, inside thefunc.yamlthe CLI writes into the volume.--namespaceis the exception: the PipelineRun runs in the namespace the CLI resolved and an unset namespace in the repository resolves to it, though a namespace committed infunc.yamlstill wins. Private repositories are also still fetched anonymously on the cluster, and the OpenShiftvcs-refannotation still comes frombuild.source.revisionrather than the built commit.testing
Verified on a kind cluster with Tekton, against a git server holding a repository whose default branch is
trunkwith nomainat all, tags1.0and1.10, and a branchfeature, each ref answering with its own body:--revision,trunkis built; before this branch the same deploy fails withcouldn't find remote ref main--revision 1.10builds that tag; before this branch the value reaches Tekton as the number1.1org.opencontainers.image.revisionis the built commit, and pushing to the branch between the read and the fetch no longer changes what is builtclean-srcstepThe existing
TestRemote_*e2e suite has not been rerun on this branch./kind enhancement
Relates to #3203
Release Note
Docs