-
Story
-
Resolution: Done
-
Minor
-
None
-
None
-
None
-
Pipelines Sprint Pioneers 25, Pipelines Sprint Pioneers 26, Pipelines Sprint Pioneers 27, Pipelines Sprint Pioneers 28
Story (Required)
As a Pipelines as Code (Pac) User trying to define PipelineRuns with clear and predictable behavior, I want to receive warnings when using conflicting annotations, specifically `on-cel-expression` alongside `on-target-branch` or `on-event`, to prevent unexpected PipelineRun triggers.
Background (Required)
Pipelines as Code currently allows users to define both `on-cel-expression` and `on-target-branch`/`on-event` annotations in a PipelineRun. However, `on-cel-expression` takes precedence, effectively ignoring the other trigger conditions. This can lead to unexpected PipelineRun executions and frustration for users who are unaware of this behavior.
Out of scope
_This story does not include:
- Automatic correction of the conflicting annotations.
- Changes to the precedence logic of `on-cel-expression`.
- Any UI or CLI changes beyond the event creation and log messages._
Approach (Required)
_1. *Controller-side Warning:*
- Modify the Pac controller to check for the presence of both `on-cel-expression` and either `on-target-branch` or `on-event` annotations during PipelineRun processing.
- If both are found, log a `WARN` message in the controller logs. The log message should clearly indicate the conflict and explain the precedence of `on-cel-expression`.
- Example log message: `WARN: PipelineRun "example-pipeline" in namespace "user-namespace" has conflicting annotations (`on-cel-expression` and `on-event`/`on-target-branch`). `on-cel-expression` will take precedence.`
2. *User Events Namespace Warning:*
- Implement a validation check in the Pac controller that triggers when both `on-cel-expression` and either `on-target-branch` or `on-event` are present.
- When the conflict is detected, emit a Kubernetes `Warning` event in the user's namespace.
- The event message should clearly explain the conflict and the precedence of `on-cel-expression`.
- Example event message: `Warning: The PipelineRun "example-pipeline" has both `on-cel-expression` and `on-event`/`on-target-branch` annotations. The `on-cel-expression` will take precedence, and the other annotations will be ignored.`
- Optionally add an annotation to the pipelinerun itself that contains the warning.
Dependencies
_This story depends on:
- Access to the Pac controller codebase.
- Ability to emit Kubernetes events in user namespaces.
- Ability to log warning messages in the Pac controller logs._
Acceptance Criteria (Mandatory)
_1. When a PipelineRun is created with `on-cel-expression` and `on-target-branch`, a `Warning` event is emitted in the user's namespace.
2. When a PipelineRun is created with `on-cel-expression` and `on-event`, a `Warning` event is emitted in the user's namespace.
3. When a PipelineRun is created with `on-cel-expression` and either `on-target-branch` or `on-event`, a `WARN` log message is generated in the Pac controller logs.
4. The warning messages in both the event and the logs are clear, concise, and accurately describe the conflict and the precedence of `on-cel-expression`.
5. If an optional annotation is added to the pipelinerun, it also contains the correct warning message._
INVEST Checklist
- Dependencies identified ✅
- Blockers noted and expected delivery timelines set ✅
- Design is implementable ✅
- Acceptance criteria agreed upon ✅
- Story estimated ✅
Legend
- ✅ Verified
- Unknown
- Unsatisfied
Done Checklist
- Code is completed, reviewed, documented and checked in ✅
- Unit and integration test automation have been delivered and running cleanly in continuous integration/staging/canary environment ✅
- Continuous Delivery pipeline(s) is able to proceed with new code included ✅
- Customer facing documentation, API docs etc. are produced/updated, reviewed and published ✅
- Acceptance criteria are met ✅