Skip to content

feat: shp buildrun gather subcommand to extract the details of the failed BuildRun#380

Open
kaizakin wants to merge 3 commits intoshipwright-io:mainfrom
kaizakin:feat/shp-gather
Open

feat: shp buildrun gather subcommand to extract the details of the failed BuildRun#380
kaizakin wants to merge 3 commits intoshipwright-io:mainfrom
kaizakin:feat/shp-gather

Conversation

@kaizakin
Copy link
Copy Markdown
Contributor

@kaizakin kaizakin commented Mar 21, 2026

Changes

  • added dynamic client support in params to fetch taskrun objects
  • added buildrun gather command that collects buildrun taskrun pod Objects and individual pod logs
  • --output flag determines the output location, default value is . currect directory.
  • --archive flag determines the output to be compressed as .tar.gz

Edit:

  • gather now supports PipelineRun executor as well
  • added options helper for dynamicClient and extended WithClientset NewParamsForTest to support dynamicClient

Fixes #250


Type of PR

/kind feature

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Kind label has been set
  • Release notes block has been filled in, or marked NONE
2026-03-22.20-23-03.mp4

Release Notes

Add "shp buildrun gather" subcommand

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 21, 2026
@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note labels Mar 21, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 21, 2026

@kaizakin: The label(s) kind/your-label-here cannot be applied, because the repository doesn't have them.

Details

In response to this:

Changes

Fixes #250

Related Issue

Fixes #

Type of PR

/kind your-label-here

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Kind label has been set
  • 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

your release note here

Instructions 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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 21, 2026

[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

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 22, 2026
@kaizakin kaizakin changed the title Feat: add shp buildrun gather subcommand feat: shp buildrun gather subcommand to extract the details of the failed BuildRun Mar 22, 2026
@kaizakin kaizakin marked this pull request as ready for review March 22, 2026 16:03
Copilot AI review requested due to automatic review settings March 22, 2026 16:03
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 22, 2026
@openshift-ci openshift-ci bot requested review from HeavyWombat and qu1queee March 22, 2026 16:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new shp buildrun gather subcommand to collect BuildRun diagnostics (BuildRun/TaskRun/Pod objects + pod logs) into a directory or .tar.gz archive, to help debug failed BuildRuns (Fixes #250).

Changes:

  • Add a dynamic.Interface client to CLI params for fetching Tekton objects.
  • Introduce shp buildrun gather subcommand with --output and --archive flags to export YAMLs and logs.
  • Add generated CLI docs for the new subcommand and link it from shp buildrun docs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/shp/params/params.go Adds dynamic client support for retrieving Tekton resources (TaskRuns).
pkg/shp/cmd/buildrun/gather.go Implements the new gather subcommand, YAML/log collection, and optional tar.gz archiving.
pkg/shp/cmd/buildrun/buildrun.go Registers gather under the buildrun command group.
docs/shp_buildrun_gather.md Adds generated documentation for shp buildrun gather.
docs/shp_buildrun.md Links the new gather subcommand in the BuildRun command index.

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

Comment on lines +98 to +115
func (c *GatherCommand) Run(p *params.Params, ioStreams *genericclioptions.IOStreams) error {
ctx := c.cmd.Context()
namespace := p.Namespace()

shpClient, err := p.ShipwrightClientSet()
if err != nil {
return err
}

kubeClient, err := p.ClientSet()
if err != nil {
return err
}

buildRun, err := shpClient.ShipwrightV1beta1().BuildRuns(namespace).Get(ctx, c.name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get BuildRun %q: %w", c.name, err)
}
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

New gather functionality isn’t covered by unit tests. Other BuildRun subcommands in this package (e.g. cancel, logs) have tests, so it would be good to add tests for at least: writing buildrun/taskrun/pod YAML, handling missing TaskRun/Pod, and --archive path behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@IrvingMg IrvingMg left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @kaizakin!

I have a few suggestions for the first pass:

  1. Please address Copilot’s review comments.
  2. Fix the linter issues reported by CI.
  3. Feel free to squash the commits as well.

Regarding your questions:

  1. IIUC, supporting PipelineRun would add more complexity. So, in my opinion, it would be better to keep this PR focused on BuildRun, but I’d like to hear others’ opinions.
  2. It would be nice to have unit tests, at least for basic scenarios.

@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 Mar 26, 2026
Signed-off-by: karthik balasubramanian <karthikbalasubramanian08@gmail.com>
Signed-off-by: karthik balasubramanian <karthikbalasubramanian08@gmail.com>
Signed-off-by: karthik balasubramanian <karthikbalasubramanian08@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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] Debug utility command: shp buildrun gather

4 participants