Skip to content
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

Support for Default Values in Tekton TriggerBinding Parameters #1676

Open
jangel97 opened this issue Nov 24, 2023 · 2 comments
Open

Support for Default Values in Tekton TriggerBinding Parameters #1676

jangel97 opened this issue Nov 24, 2023 · 2 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@jangel97
Copy link

Use Case: Managing DNS Records for LoadBalancer Services with Knative and Tekton

Context

In our current workflow, we use Knative to trigger a Tekton EventListener when a Kubernetes service of type LoadBalancer is removed. The purpose of this trigger is to initiate a pipeline that removes the corresponding DNS records from our intranet, ensuring that our DNS configuration remains up-to-date and free of stale entries.

Challenge

The challenge arises when dealing with optional annotations on the Kubernetes service. These annotations provide critical information for the DNS record removal process. However, when a service is deleted, we lose access to these annotations, and since they are optional, we cannot guarantee their presence in every service.

In the current Tekton TriggerBinding implementation, there is no way to specify default values for parameters. This limitation becomes a significant issue in our scenario because:

  1. Lack of Default Values: When a service is deleted, and certain optional annotations are not present, our TriggerBinding cannot bind these missing values. This lack of information leads to incomplete or erroneous pipeline execution.

  2. Error Handling Complexity: Without default values, we have to implement complex error handling in our pipelines to manage missing data, which adds unnecessary complexity and potential failure points.

Proposed Solution

By enabling default values in TriggerBinding parameters, we can significantly streamline our pipeline. For instance, if an optional annotation is not present, the TriggerBinding could use a predefined default value, allowing the pipeline to proceed smoothly with known defaults. This enhancement would simplify our pipeline logic and reduce the risk of errors due to missing data.

Example

Here's an example of how this feature could be used in our scenario:

apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
  name: service-deletion-binding
spec:
  params:
  - name: serviceName
    value: $(body.metadata.name)
  - name: optionalAnnotation
    value: $(body.metadata.annotations.optionalAnnotation)
    default: "default-value"

In this example, if the optionalAnnotation is not present in the service being deleted, the TriggerBinding would use "default-value" as the fallback, ensuring that the pipeline has all the necessary information to proceed.

Benefits

Implementing this feature would:

  • Ensure more robust and reliable pipeline executions in scenarios where optional data may be missing.
  • Reduce the complexity of error handling in pipelines dealing with conditional or optional data.
  • Improve the overall flexibility and usability of Tekton in dynamic, event-driven environments like ours.
@jangel97 jangel97 added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 24, 2023
@vdemeester vdemeester transferred this issue from tektoncd/pipeline Nov 24, 2023
@vdemeester
Copy link
Member

Transferring this issue to tektoncd/triggers as it's about TriggerBinding, which is in it.

@AlanGreene
Copy link
Member

Default param values can be set in the TriggerTemplate. These are used in a number of cases including when the TriggerBinding is unable to provide a value. See the docs for more details: https://tekton.dev/docs/triggers/triggertemplates/#specifying-parameters

Tekton applies the value of the default field for each entry in the params array of your TriggerTemplate if it can’t find a corresponding value in the associated TriggerBinding or cannot successfully extract the value from an HTTP header or body payload.

Is this suitable for your needs? If not, any details on the gaps would be helpful for the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

3 participants