Skip to content

Commit 05e788a

Browse files
committed
feature: implement PinP reconciliation and tests
[TEP-0056]: Third PR of Pipelines-in-Pipelines feature implementation. Child `PipelineRuns` (PinP) are created by the `PipelineRun` reconciler, equal to the `TaskRun/CustomRun` implementations. An event handler for child `PipelineRuns` is registered in controller entrypoint. This will trigger the reconciliation loop when child `PipelineRuns` change their state. Extend `resolvePipelineState` with getter for child `PipelineRuns` using lister and extend `runNextSchedulableTask` with a condition check for a `PipelineTask` which is a `Pipeline` and implement the creation of a new `PipelineRun` from the resolved pipeline state and pipeline facts. Setting the `ChildReferences` was extended for child `PipelineRuns`. Rename label/annotation factory. The unit/e2e test framework was refactored and extended to prepare for future tests. The test setup is a parent pipeline with one or more embedded child/grandchild pipelines using the `PipelineSpec` (alpha) field. It follows the given-when-then test flow arrangement. The pipeline manifests yaml definitions use variables for every field which is validated. Multiple helper functions were created equal to reconciliation unit tests for TaskRuns/CustomRuns. Test data factory functions were put in the `testing` package in the `factory.go` file. The unit tests validates: - the status and condition of the parent PipelineRuns which should trigger the creation of the child PipelineRuns, - the actual created child/grandchild PipelineRuns if they have the correct metadata i.e. name, owner reference, etc. and the embedded pipelines from the `PipelineSpec` fields in the pipeline tasks of the parent pipeline. Similar checks are performed in `TestReconcile` for `TaskRun` and in `TestReconcile_V1Beta1CustomTask` for `CustomTasks`. The e2e tests validate: - parent PipelineRun creation, - child PipelineRun creation, - successful finish of all resources, - correct label and annotation propagation, - amount of events published. Similar checks are performed in `TestPipelineRun|TestPipelineRunStatusSpec|...` for `TaskRun` and in `TestCustomTask` for `CustomTask`. Issues #8760, #7166. Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
1 parent d8f7b93 commit 05e788a

File tree

9 files changed

+1349
-34
lines changed

9 files changed

+1349
-34
lines changed

pkg/reconciler/pipelinerun/controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ func NewController(opts *pipeline.Options, clock clock.PassiveClock) func(contex
116116
logging.FromContext(ctx).Panicf("Couldn't register PipelineRun informer event handler: %w", err)
117117
}
118118

119+
if _, err := pipelineRunInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
120+
FilterFunc: controller.FilterController(&v1.PipelineRun{}),
121+
Handler: controller.HandleAll(impl.EnqueueControllerOf),
122+
}); err != nil {
123+
logging.FromContext(ctx).Panicf("Couldn't register PipelineRun informer event handler: %w", err)
124+
}
125+
119126
if _, err := taskRunInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
120127
FilterFunc: controller.FilterController(&v1.PipelineRun{}),
121128
Handler: controller.HandleAll(impl.EnqueueControllerOf),

pkg/reconciler/pipelinerun/pipelinerun.go

Lines changed: 150 additions & 32 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)