Skip to content

Commit 3e02e0f

Browse files
author
Shivam Mukhade
committed
Wait for tekton.dev/pipeline label to add checkrun id label
this updates controller to wait for pipeline label in order to avoid race condition. this is a temporaray fix, we will update this with a proper fix soon. this will not any performance change as pipelinerun is created and started and waiting for adding label will not any effect on execution of pipelinerun. in case of concurreny, there may be delay of a few seconds in starting of first pipelinerun from .tekton directory. Signed-off-by: Shivam Mukhade <[email protected]>
1 parent 2ecdc87 commit 3e02e0f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pkg/provider/github/status.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ func (v *Provider) getOrUpdateCheckRunStatus(ctx context.Context, tekton version
109109
return err
110110
}
111111
}
112-
if err := v.updatePipelineRunWithCheckRunID(ctx, tekton, status.PipelineRun, checkRunID); err != nil {
113-
return err
114-
}
115112
}
116113

117114
checkRunOutput := &github.CheckRunOutput{
@@ -137,6 +134,15 @@ func (v *Provider) getOrUpdateCheckRunStatus(ctx context.Context, tekton version
137134
}
138135

139136
_, _, err = v.Client.Checks.UpdateCheckRun(ctx, runevent.Organization, runevent.Repository, *checkRunID, opts)
137+
if err != nil {
138+
return err
139+
}
140+
141+
if !found {
142+
if err := v.updatePipelineRunWithCheckRunID(ctx, tekton, status.PipelineRun, checkRunID); err != nil {
143+
return err
144+
}
145+
}
140146
return err
141147
}
142148

@@ -150,6 +156,13 @@ func (v *Provider) updatePipelineRunWithCheckRunID(ctx context.Context, tekton v
150156
if err != nil {
151157
return err
152158
}
159+
// temp fix: wait for tekton.dev/pipeline label to avoid race condition
160+
// https://github.com/openshift-pipelines/pipelines-as-code/issues/786
161+
if _, ok := pr.Labels["tekton.dev/pipeline"]; !ok {
162+
v.Logger.Infof("PipelineRun %v/%v don't have tekton label yet, waiting for it", pr.GetNamespace(), pr.GetName())
163+
time.Sleep(2 * time.Second)
164+
continue
165+
}
153166
pr = pr.DeepCopy()
154167
pr.GetLabels()[filepath.Join(apipac.GroupName, checkRunIDKey)] = strconv.FormatInt(*checkRunID, 10)
155168

0 commit comments

Comments
 (0)