Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hey @divyansh42! Got this ready for review. Whenever you get some time PTAL |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues drop requested timestamps from text logs, contaminate JSON output with plain-text diagnostics, and can cause a panic on null termination-message entries.
3 open issues
What changed in this PR
Adds structured log output to tkn pipelinerun logs and tkn taskrun logs for agents and automated tools, using the shared log-reading and formatting infrastructure.
Changes:
- Adds
-o/--output jsonfor newline-delimited JSON, including follow mode. - Carries Kubernetes timestamps into structured records with task, step, and message fields.
- Updates command references and man pages; human-readable output remains the default.
| File | Description |
|---|---|
pkg/pods/container.go |
Extracts timestamps from Kubernetes log lines. |
pkg/options/logs.go |
Adds the output-format option. |
pkg/log/writer.go |
Encodes structured log records as NDJSON. |
pkg/log/task_reader.go |
Forwards timestamps and changes termination-result decoding. |
pkg/log/pipeline_reader.go |
Forwards timestamps through pipeline logs. |
pkg/log/log.go |
Adds timestamps to shared log records. |
pkg/cmd/taskrun/logs.go |
Exposes and configures JSON output for TaskRun logs. |
pkg/cmd/pipelinerun/logs.go |
Exposes and configures JSON output for PipelineRun logs. |
docs/man/man1/tkn-taskrun-logs.1 |
Documents the TaskRun output flag. |
docs/man/man1/tkn-pipelinerun-logs.1 |
Documents the PipelineRun output flag. |
docs/cmd/tkn_taskrun_logs.md |
Updates the TaskRun command reference. |
docs/cmd/tkn_pipelinerun_logs.md |
Updates the PipelineRun command reference. |
Review effort: Balanced
ac436dc to
d0584b3
Compare
|
@divyansh42 I have addressed the review suggestions PTAL whenever you are free. Thanks! |
|
Also the k8s-plus-one E2E check failed on TestPipelineInteractiveStartE2E (-f + --last). Couldn't find anything conclusive in the logs. Could you rerun it once? |
|
/retest |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues split long log lines with incorrect timestamps, drop genuine EOFLOG messages, mix selection output into JSON stdout, and silently accept unsupported output formats.
5 open issues
JSON log selection writes diagnostics and prompts to stdout · New Unsupported output formats are silently accepted · New Real EOFLOG messages are mistaken for end-of-step markers · New Long log lines split into fragments with invalid timestamps · New Nil termination entries can panic log-failed processing
2 resolved since last review
Review effort: Balanced
cfcb1a3 to
a722779
Compare
|
Addressed the review suggestions. |
a722779 to
b78e17a
Compare
|
I've addressed the review comments as well. Could you please rerun the failed test? It seems to be an intermittent CI issue. Thanks! |
|
/retest |
7193858 to
aad95fa
Compare
|
Addressed the reviews |
aad95fa to
e8c507a
Compare
|
Addressed the review, PTAL when you get a chance |
|
@Debashich could you please attach a sample output in the description for better understanding? |
77d9193 to
f2bf635
Compare
Signed-off-by: Debashich <debashishsinha555@gmail.com> Add wait for goroutine in pipeline_reader Ensure goroutine waits for completion before returning. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> test: buffer inHandler channel to prevent test hang Return error when no PipelineRuns are found Change error handling to return an error when no PipelineRuns are found. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> fix: make agent-friendly logs JSON output consistent Signed-off-by: Debashich <debashishsinha555@gmail.com> test: verify JSON runtime errors and exit codes Signed-off-by: Debashich <debashishsinha555@gmail.com>
584f506 to
d7a847b
Compare
|
I have addressed the reviews, PTAL when you get a chance. |
| } | ||
|
|
||
| if opts.Output == "json" && opts.PipelineRunName == "" && !opts.Last { | ||
| return fmt.Errorf("JSON output requires a PipelineRun name or --last") |
| } | ||
|
|
||
| // ReadContext reads container logs until the context is cancelled. | ||
| func (lr *LogReader) ReadContext(ctx context.Context) (<-chan Log, <-chan error, error) { |


Changes
Add JSON output support to
tkn pipelinerun logsandtkn taskrun logs, making log output easier for agents, scripts, and automated tools to consume.-o/--outputflag to both commands.--follow.Sample Output
Run either command with
-o jsonto receive newline-delimited JSON records:Each line represents an individual log entry, making it straightforward to process records incrementally without parsing human-readable terminal output.
Example format (illustrative; replace with actual CLI output):
{"task":"build","step":"build","timestamp":"2026-11-24T10:30:00Z","message":"Building application..."} {"task":"build","step":"build","timestamp":"2026-11-24T10:30:01Z","message":"Build completed."}Closes #2854
Submitter Checklist
make check(no lint issues in this PR; remaining findings are pre-existing and unrelated).make generated.See the [contribution guide](https://github.com/tektoncd/cli/blob/master/CONTRIBUTING.md) for more details.
Release Notes