Skip to content

Commit a67b38b

Browse files
committed
Add documentation for allow_pre_post_step_overrides safety flag
1 parent bf94fdd commit a67b38b

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

content/en/docs/architecture/step-registry.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,14 @@ In this example, the `ci-operator` configuration simply specifies the desired cl
316316
example for the [`Workflow`](#workflow) section above.
317317

318318
Since the `ci-operator` configuration and workflows share the same fields, it is possible to override fields specified in a workflow.
319-
In cases where both the workflow and a `ci-operator` configuration specify the same field, the `ci-operator` configurations field has
319+
In cases where both the workflow and a `ci-operator` configuration specify the same field, the `ci-operator` configuration's field has
320320
priority (i.e. the value from the `ci-operator` configuration is used). List and mapping fields have a few special rules, described
321321
in the [hierarchical propagation](#hierarchical-propagation) section.
322322

323+
{{< alert title="Important" color="info" >}}
324+
**Restriction on `pre` and `post` Step Overrides**: By default, tests cannot override `pre` and `post` steps defined in workflows to prevent accidental resource leaks. If you need to override these steps, you must explicitly set `allow_pre_post_step_overrides: true`. See [Overriding pre and post Step Definitions](#overriding-pre-and-post-step-definitions) for more details.
325+
{{< /alert >}}
326+
323327
Example of a `ci-operator` configuration that overrides a workflow field:
324328

325329
{{< highlight yaml >}}
@@ -352,6 +356,76 @@ tests:
352356

353357
## Options to Change Control Flow
354358

359+
### Overriding `pre` and `post` Step Definitions
360+
361+
By default, `ci-operator` prevents tests from overriding the `pre` and `post` step definitions that are specified in a workflow. This is a safety measure to prevent accidental resource leaks that could occur when setup steps (in `pre`) or cleanup steps (in `post`) are unintentionally modified or removed.
362+
363+
To explicitly allow overriding of `pre` and `post` steps when using a workflow, the `allow_pre_post_step_overrides` field must be set to `true` in the test configuration. Without this flag, attempts to override `pre` or `post` steps will result in a validation error.
364+
365+
{{< alert title="Warning" color="warning" >}}
366+
Overriding `pre` or `post` steps can lead to resource leaks if setup or cleanup operations are not performed correctly. Only override these steps if you fully understand the implications and have verified that all necessary setup and cleanup operations are still performed.
367+
{{< /alert >}}
368+
369+
Example of allowing `pre` and `post` step overrides:
370+
371+
{{< highlight yaml >}}
372+
tests:
373+
- as: e2e-custom-setup
374+
steps:
375+
allow_pre_post_step_overrides: true # explicitly allow overriding pre/post steps
376+
cluster_profile: aws
377+
workflow: origin-e2e
378+
pre: # this overrides the pre steps from the workflow
379+
- ref: custom-cluster-setup
380+
post: # this overrides the post steps from the workflow
381+
- ref: custom-cluster-cleanup
382+
{{< / highlight >}}
383+
384+
Without the `allow_pre_post_step_overrides: true` setting, the above configuration would fail validation. When this flag is set to `true`, the test takes full responsibility for ensuring proper resource management.
385+
386+
#### Examples
387+
388+
**Attempting to override without the flag (this will fail validation):**
389+
390+
{{< highlight yaml >}}
391+
tests:
392+
- as: e2e-bad-example
393+
steps:
394+
cluster_profile: aws
395+
workflow: ipi-aws
396+
post: # ERROR: This will fail validation
397+
- ref: custom-cleanup # because allow_pre_post_step_overrides is not set
398+
{{< / highlight >}}
399+
400+
**Correctly overriding with explicit permission:**
401+
402+
{{< highlight yaml >}}
403+
tests:
404+
- as: e2e-good-example
405+
steps:
406+
allow_pre_post_step_overrides: true
407+
cluster_profile: aws
408+
workflow: ipi-aws
409+
pre: # OK: Overrides pre steps from ipi-aws workflow
410+
- ref: custom-pre-setup
411+
- chain: modified-install
412+
post: # OK: Overrides post steps from ipi-aws workflow
413+
- ref: gather-custom-artifacts
414+
- chain: modified-deprovision
415+
{{< / highlight >}}
416+
417+
**Overriding only test steps (no flag needed):**
418+
419+
{{< highlight yaml >}}
420+
tests:
421+
- as: e2e-test-only
422+
steps:
423+
cluster_profile: aws
424+
workflow: ipi-aws
425+
test: # OK: test step overrides don't require the flag
426+
- ref: custom-e2e-test
427+
{{< / highlight >}}
428+
355429
### Skipping `post` Steps On Success
356430

357431
`ci-operator` can be configured to skip some or all `post` steps when all `test` steps pass. Skipping a `post` step when all tests have

0 commit comments

Comments
 (0)