Skip to content

Commit

Permalink
fix: Logs not shown, when stderr is populated
Browse files Browse the repository at this point in the history
  • Loading branch information
keskad committed May 22, 2024
1 parent 83aa916 commit e4d6e6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions charts/tekton-chart/values.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ controller:
image:
repository: quay.io/pipelines-feedback/tekton
pullPolicy: Always

rbac:
jobRules:
- apiGroups: ["tekton.dev"]
resources: ["pipelineruns", "taskruns", "pipelines"]
verbs: ["list", "get", "watch"]
11 changes: 10 additions & 1 deletion pkgs/core/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/kube-cicd/pipelines-feedback-core/pkgs/store"
"github.com/kube-cicd/pipelines-feedback-core/pkgs/templating"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/log"
"github.com/tektoncd/cli/pkg/options"
Expand Down Expand Up @@ -128,6 +129,12 @@ func (prp *PipelineRunProvider) ReceivePipelineInfo(ctx context.Context, name st

// fetchLogs is using tkn cli client code to fetch logs from a PipelineRun
func (prp *PipelineRunProvider) fetchLogs(pipelineRun *v1.PipelineRun) string {
defer func() {
if err := recover(); err != nil {
logrus.Println("panic occurred while trying to fetch Tekton logs: ", err)
}
}()

params := &cli.TektonParams{}
params.SetNamespace(pipelineRun.Namespace)
params.SetNoColour(true)
Expand All @@ -149,7 +156,9 @@ func (prp *PipelineRunProvider) fetchLogs(pipelineRun *v1.PipelineRun) string {
}

buf := new(bytes.Buffer)
log.NewWriter(log.LogTypePipeline, opts.Prefixing).Write(&cli.Stream{Out: buf}, logC, errC)
writer := log.NewWriter(log.LogTypePipeline, opts.Prefixing)
stream := &cli.Stream{Out: buf, Err: buf}
writer.Write(stream, logC, errC)
return buf.String()
}

Expand Down

0 comments on commit e4d6e6e

Please sign in to comment.