Skip to content

feat: add --step-resources and --buildrun-name to build upload - #416

Open
psrvere wants to merge 2 commits into
shipwright-io:mainfrom
psrvere:worktree-build-upload-step-resources
Open

psrvere wants to merge 2 commits into
shipwright-io:mainfrom
psrvere:worktree-build-upload-step-resources

Conversation

@psrvere

@psrvere psrvere commented Sep 16, 2026 •

Copy link
Copy Markdown

Changes

Closes #415.

shp build upload created its own BuildRun and exposed only a fixed set of BuildRun fields as flags. A Local-source build could not ask for per-step compute resources, and a local folder could not be streamed into a BuildRun created some other way. This came up while migrating OpenShift BuildConfigs that set spec.resources to Shipwright with the crane plugin.

This PR adds both flags proposed in the issue.

  • --step-resources is repeatable and sets BuildRunSpec.StepResources, in the form <step>=<limits|requests>.<resource>=<quantity>, for example build-and-push=limits.memory=2Gi. Entries for the same step merge. It goes through BuildRunSpecFromFlags, so shp build run and shp buildrun create get it too.
  • --buildrun-name streams the local source into an existing BuildRun instead of creating one. That covers any BuildRun field the CLI has no flag for.

--buildrun-name fails early, with an error, in these cases.

  • It is combined with a flag that only shapes a new BuildRun, such as --sa-name. That flag would have no effect. Global flags such as --namespace are still accepted.
  • The Build uses a source bundle image. Its BuildRun pulls the bundle from a registry and never waits for the CLI.
  • The BuildRun references another Build. The upload finds the build pod by the Build name, so it would never match and would wait forever.
  • The BuildRun has no Local source. Its pod has no container waiting for the upload.

The pod of an existing BuildRun is often already running when the upload starts. The upload reacts to the first event it sees for the pod, so it streams at once instead of waiting until the BuildRun times out.

The PR has two commits. 07e9276 adds the two flags. aa15a22 fixes four ways --buildrun-name failed when tested on a cluster: it rejected --namespace, it sat idle when the BuildRun's pod was already running, it waited forever on a BuildRun of another Build, and it gave an unclear error on a BuildRun without a Local source.

Checks run locally: go build ./..., make test-unit and make verify-docs pass. The new unit tests fail on 07e9276 and pass on aa15a22.

Each case above was also run on two clusters, a kind cluster running Shipwright Build and an OpenShift 4.20 cluster with Builds for Red Hat OpenShift 1.9.0. On both, 07e9276 showed all four failures. With aa15a22 the upload streams through --namespace and into a BuildRun whose pod is already running, and both builds succeed. The other cases stop at once with an error that names the problem. A plain upload without --buildrun-name still builds.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

`shp build upload` gains `--step-resources` to override per-step compute resources and `--buildrun-name` to stream local source into an existing BuildRun.

Co-Authored-By: Claude

@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 16, 2026
@openshift-ci openshift-ci Bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Sep 16, 2026
@openshift-ci

openshift-ci Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign saschaschwarze0 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@psrvere
psrvere force-pushed the worktree-build-upload-step-resources branch from 5503744 to 8d412aa Compare September 16, 2026 11:41
@psrvere psrvere changed the title Add --step-resources and --buildrun-name flags to build upload feat: add --step-resources and --buildrun-name to build upload Sep 16, 2026
@openshift-ci openshift-ci Bot added release-note and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 16, 2026
@psrvere

psrvere commented Sep 16, 2026

Copy link
Copy Markdown
Author

/kind feature

@openshift-ci openshift-ci Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 16, 2026
`shp build upload` created its own BuildRun and exposed only a fixed set
of BuildRun fields, so a Local-source build could not request step
compute resources and could not be streamed into a BuildRun created
elsewhere. This closes the gap flagged when migrating OpenShift
BuildConfigs (with spec.resources) to Shipwright.

- --step-resources (repeatable): sets BuildRunSpec.StepResources as
  <step>=<limits|requests>.<resource>=<quantity>, e.g.
  build-and-push=limits.memory=2Gi. Wired through BuildRunSpecFromFlags,
  so it is also available on `build run` and `buildrun create`.
- --buildrun-name: streams the local source into an existing BuildRun
  instead of creating one, covering any BuildRun field the CLI does not
  expose as a flag. Guarded against combination with creation-only flags
  and against source-bundle builds.

Adds unit tests for the flag parser and upload flow, plus e2e cases, and
regenerates the command docs.

Closes: shipwright-io#415

Co-authored-by: Claude
Signed-off-by: Prateek Singh Rathore <prateek.singh.rathore@gmail.com>
@psrvere
psrvere force-pushed the worktree-build-upload-step-resources branch from 8d412aa to 07e9276 Compare September 16, 2026 11:45
Comment thread pkg/shp/cmd/build/upload.go
Comment thread pkg/shp/cmd/build/upload.go
Testing `shp build upload --buildrun-name` on a cluster showed four
ways it failed.

The flag check rejected global flags, so --namespace and --kubeconfig
could not be used with --buildrun-name. The check now looks only at the
upload command's own flags.

The pod of an existing BuildRun is often already running when the
upload starts. The upload only reacted to changes in the pod, and a
waiting pod does not change, so it sat idle until the pod's upload
waiter gave up and then failed with "container not found". It now
also reacts to the first event it sees for the pod.

A BuildRun of another Build made the command wait forever, because the
upload finds the build pod by the Build name. A BuildRun without a
Local source failed with an unclear error about a missing container,
because its pod has nothing waiting for the upload. Both are now
checked before the upload starts, and the error names the BuildRun.

Unit tests cover each case and fail on the code before this commit. The
e2e case now waits for the pod to be running before it uploads, passes
--namespace, and checks the memory limit on the step container.

Co-Authored-By: Claude
Signed-off-by: Prateek Singh Rathore <prateek.singh.rathore@gmail.com>
@pull-request-size pull-request-size Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 29, 2026
@psrvere

psrvere commented Sep 29, 2026

Copy link
Copy Markdown
Author

Thanks for the review, @sayan-biswas. Testing your two questions turned up four bugs in --buildrun-name, all fixed in aa15a22.

  1. It rejected --namespace and the other global flags.
  2. When the BuildRun's pod was already running, the upload sat idle until the pod stopped waiting, about 60 seconds, and then failed with "container not found". It now reacts to the pod's first event as well.
  3. A BuildRun of a different Build made the command wait forever. It now stops with an error.
  4. A BuildRun without a Local source gave an unclear error. It now says the BuildRun needs a Local source.

I ran every case on a kind cluster and on OpenShift 4.20 with Builds for Red Hat OpenShift 1.9.0. Each case fails on 07e9276 and works on aa15a22. The new unit tests fail on the old code and pass on the new.

@sayan-biswas

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[FEATURE] shp build upload: pass step resources, or stream into an existing BuildRun

3 participants