Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting a few info into debug message #916

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, pr *v1beta1.PipelineRun)
func (r *Reconciler) FinalizeKind(ctx context.Context, pr *v1beta1.PipelineRun) pkgreconciler.Event {
// Check to make sure the PipelineRun is finished.
if !pr.IsDone() {
logging.FromContext(ctx).Infof("pipelinerun is still running")
logging.FromContext(ctx).Debugf("pipelinerun \"%s/%s\" is still running", pr.Namespace, pr.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of plumbing through the namespace/name in each log statement, you can set this in the context:

log := logging.FromContext(ctx).With(
  "pipelinerun", fmt.Sprintf("%s/%s", pr.Namespace, pr.Name),
)
ctx = logging.WithLogger(ctx, log)

This will make sure that other logs further down the callstack have similar fields set!

return nil
}
pro := objects.NewPipelineRunObject(pr)

// Check to see if it has already been signed.
if signing.Reconciled(ctx, r.Pipelineclientset, pro) {
logging.FromContext(ctx).Infof("pipelinerun has been reconciled")
logging.FromContext(ctx).Infof("pipelinerun \"%s/%s\" has been reconciled", pr.Namespace, pr.Name)
return nil
}

Expand All @@ -78,7 +78,7 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, pr *v1beta1.PipelineRun)
// has exceeded. Wait to process the PipelineRun on the next update, see
// https://github.com/tektoncd/pipeline/issues/4916
if ptrs.Status == nil || ptrs.Status.CompletionTime == nil {
logging.FromContext(ctx).Infof("taskrun %s within pipelinerun is not yet finalized: embedded status is not complete", trName)
logging.FromContext(ctx).Infof("taskrun \"%s\" within pipelinerun \"%s\" is not yet finalized: embedded status is not complete", trName, pr.Name)
return nil
}
trs = append(trs, trName)
Expand All @@ -95,7 +95,7 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, pr *v1beta1.PipelineRun)
for _, name := range trs {
tr, err := r.TaskRunLister.TaskRuns(pr.Namespace).Get(name)
if err != nil {
logging.FromContext(ctx).Errorf("Unable to get reconciled status of taskrun %s within pipelinerun", name)
logging.FromContext(ctx).Errorf("Unable to get reconciled status of taskrun \"%s\" within pipelinerun \"%s\"", name, pr.Name)
if errors.IsNotFound(err) {
// Since this is an unrecoverable scenario, returning the error would prevent the
// finalizer from being removed, thus preventing the PipelineRun from being deleted.
Expand All @@ -104,16 +104,16 @@ func (r *Reconciler) FinalizeKind(ctx context.Context, pr *v1beta1.PipelineRun)
return err
}
if tr == nil {
logging.FromContext(ctx).Infof("taskrun %s within pipelinerun is not found", name)
logging.FromContext(ctx).Infof("taskrun \"%s\" within pipelinerun \"%s\" is not found", name, pr.Name)
return nil
}
if tr.Status.CompletionTime == nil {
logging.FromContext(ctx).Infof("taskrun %s within pipelinerun is not yet finalized: status is not complete", name)
logging.FromContext(ctx).Infof("taskrun \"%s\" within pipelinerun \"%s\" is not yet finalized: status is not complete", name, pr.Name)
return r.trackTaskRun(tr, pr)
}
reconciled := signing.Reconciled(ctx, r.Pipelineclientset, objects.NewTaskRunObject(tr))
if !reconciled {
logging.FromContext(ctx).Infof("taskrun %s within pipelinerun is not yet reconciled", name)
logging.FromContext(ctx).Infof("taskrun \"%s\" within pipelinerun \"%s\" is not yet reconciled", name, pr.Name)
return r.trackTaskRun(tr, pr)
}
pro.AppendTaskRun(tr)
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tr *v1beta1.TaskRun) pkg
func (r *Reconciler) FinalizeKind(ctx context.Context, tr *v1beta1.TaskRun) pkgreconciler.Event {
// Check to make sure the TaskRun is finished.
if !tr.IsDone() {
logging.FromContext(ctx).Infof("taskrun %s/%s is still running", tr.Namespace, tr.Name)
logging.FromContext(ctx).Debugf("taskrun \"%s/%s\" is still running", tr.Namespace, tr.Name)
return nil
}

obj := objects.NewTaskRunObject(tr)

// Check to see if it has already been signed.
if signing.Reconciled(ctx, r.Pipelineclientset, obj) {
logging.FromContext(ctx).Infof("taskrun %s/%s has been reconciled", tr.Namespace, tr.Name)
logging.FromContext(ctx).Infof("taskrun \"%s/%s\" has been reconciled", tr.Namespace, tr.Name)
return nil
}

Expand Down
Loading