-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[REGRESSION] Unable to cancel pipeline run - error PipelineRunCouldntCancel reported on a pending custom task #5282
Comments
Thank you for the bug report @rafalbigaj - it sounds like we don't have test coverage for this. |
@rafalbigaj Does the cancel happen right away? |
👍 Agreed! |
cc #5120 |
Would this require changing pluming to deploy wait task controller or can it be done via |
I wrote a reproducer unit test, so we can test this even without e2e tests, nonetheless it would be good to install the /*
Copyright 2022 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pipelinerun
import (
"fmt"
"testing"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
"github.com/tektoncd/pipeline/test"
"github.com/tektoncd/pipeline/test/parse"
corev1 "k8s.io/api/core/v1"
logtesting "knative.dev/pkg/logging/testing"
_ "knative.dev/pkg/system/testing" // Setup system.Namespace()
)
func TestReconcileTwoCustomTasks(t *testing.T) {
pipelineRunName := "cancel-test-run"
prs := []*v1beta1.PipelineRun{parse.MustParsePipelineRun(t, `metadata:
name: cancel-test-run
namespace: foo
spec:
pipelineSpec:
tasks:
- name: wait-1
taskSpec:
apiVersion: example.dev/v0
kind: Wait
params:
- name: duration
value: 1h
- name: wait-2
runAfter:
- wait-1
taskSpec:
apiVersion: example.dev/v0
kind: Wait
params:
- name: duration
value: 10s
`)}
cms := []*corev1.ConfigMap{withCustomTasks(newFeatureFlagsConfigMap())}
d := test.Data{
PipelineRuns: prs,
ConfigMaps: cms,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
pr, clients := prt.reconcileRun("foo", pipelineRunName, []string{}, false)
fmt.Printf("%v", pr)
err := cancelPipelineRun(prt.TestAssets.Ctx, logtesting.TestLogger(t), pr, clients.Pipeline)
if err != nil {
t.Fatalf("Error found: %v", err)
}
} I used $ git bisect start v0.37.0 v0.36.0 --
$ git bisect run go test -v github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun -run TestReconcileTwoCustomTasks
(...)
9d60d0adf41e74f78029a0eaab73140fa4f7206a is the first bad commit On the surface it looks unrelated, I need to dig in to understand what happened. |
The issue happens only with full status - with minimal status it works fine - i.e. in the test, using: cms := []*corev1.ConfigMap{withCustomTasks(withEmbeddedStatus(newFeatureFlagsConfigMap(), config.MinimalEmbeddedStatus))} Works on |
Fixes tektoncd#5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
Fixes tektoncd#5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
When a pipelinerun is cancelled, it may be that some of the resources managed by the pipelinerun are missing (NotFound). In this case we should not fail, and let the pipelinerun be cancelled. Discussion about this was initially triggered by tektoncd#5282, but this feature makes sense regardless of the bug that exposed its need. Signed-off-by: Andrea Frittoli <[email protected]>
Fixes tektoncd#5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
Fixes tektoncd#5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
Fixes #5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
Fixes tektoncd#5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
Fixes tektoncd#5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. cherry-picked from tektoncd#5287, with some additional modifications to child reference population for custom tasks without a `Run` which have been fixed in v0.38.x. Signed-off-by: Andrew Bayer <[email protected]>
Fixes #5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. cherry-picked from #5287, with some additional modifications to child reference population for custom tasks without a `Run` which have been fixed in v0.38.x. Signed-off-by: Andrew Bayer <[email protected]>
Fixes tektoncd#5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
Fixes #5282 When removing conditions, I accidentally made `GetRunsStatus` not skip including custom task `ResolvedPipelineTask`s without `Run`s in the `PipelineRun.Status.Runs` map. This resulted in cancellation failing, because the cancellation logic tries to patch each `Run` or `TaskRun` in the `PipelineRun` status (either in the `Runs` and `TaskRuns` maps for full embedded status, or `ChildReferences` for minimal or both embedded status). Unscheduled `PipelineTask`s for `Task`s were already properly excluded from the status map, and `ChildReferences` was fine either way, but due to the oversight I mentioned above, unscheduled `PipelineTask`s for custom tasks _were_ included in the full embedded status map, and cancellation would error due to that. Signed-off-by: Andrew Bayer <[email protected]>
When a pipelinerun is cancelled, it may be that some of the resources managed by the pipelinerun are missing (NotFound). In this case we should not fail, and let the pipelinerun be cancelled. Discussion about this was initially triggered by #5282, but this feature makes sense regardless of the bug that exposed its need. Signed-off-by: Andrea Frittoli <[email protected]>
Expected Behavior
Pipeline run with unscheduled custom test should be cancellable.
Regression: This scenario works correctly on v0.33.1.
Actual Behavior
When cancelling a pipeline run, which contains unscheduled custom test, the error
PipelineRunCouldntCancel
occurs.Steps to Reproduce the Problem
spec.status
to "Cancelled". The finalPipelineRun
status is:Additional Info
Kubernetes version:
Output of
kubectl version
:The text was updated successfully, but these errors were encountered: