tektoncd / triggers

Event triggering with Tekton!
Apache License 2.0
552 stars 416 forks source link

Triggers called multiple times by EventListener or never called at all #1617

Closed Gio-R closed 4 months ago

Gio-R commented 1 year ago

Expected Behavior

With the following EventListener I expect the selected Triggers to be called:

apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
  name: push-listener
  namespace: default
spec:
  serviceAccountName: tekton-robot
  triggerGroups:
  - name: gitlab
    interceptors:
    - name: gitlab
      ref:
        name: "gitlab"
      params:
      - name: secretRef
        value:
          secretName: gitlabSecret
          secretKey: secretToken
      - name: eventTypes
        value: ["Push Hook"]
    triggerSelector:
      labelSelector:
        matchLabels:
          idp/trigger-type: component-ci
      namespaceSelector:
        matchNames:
        - '*'

Actual Behavior

The selected Triggers are not called and adding the following spec.namespaceSelector section to the above EventListener causes the Trigger to be called two times instead of the expected one:

  namespaceSelector:
    matchNames: 
    - '*'

Steps to Reproduce the Problem

  1. Install the Tekton Operator version 0.67
  2. Create the above EventListener and a Trigger that satisfies the triggerSelector
  3. Send a Gitlab webhook push payload to the EventListener Service

Additional Info

khrm commented 1 year ago

https://github.com/tektoncd/triggers/blob/main/docs/eventlisteners.md#constraining-eventlisteners-to-specific-namespaces

At present, if an EventListeners has Triggers inside its own spec as well as namespace-selector, Triggers in spec as well as in selected namespaces will be processed for a request. Triggers inside EventListener spec when using namespace-selector mode is deprecated and ability to specify both will be removed.

Gio-R commented 1 year ago

That explains why adding the spec.namespaceSelector makes the Trigger run two times, but it doesn't explain why without that selector the Trigger is never run. At the moment, as a workaround, I have triggerGroups select the Triggers I want to run, spec.namespaceSelector select all namespaces and spec.labelSelector select no Triggers (to avoid double runs). Without the spec.namespaceSelector no Trigger is run, even if correctly selected by the triggerGroup.

lifeym commented 1 year ago

I reached same issue. Without spec.namespaceSelector, the triggers seleted by spec.triggerGroup never run. Finally I have the spec.namespaceSelector to match a non-exist namesapce, then the triggerGroup ran as expected(once). for exsample:

spec:
  namespaceSelector:
    matchNames:
      - not-exists

Through the document mentioned by @khrm , and explained by @Gio-R , triggers in spec as well as in selected namespaces will be processed for a request which is the expected behavior. The issue is that without the spec.namespaceSelector, no triggers will be processed.

khrm commented 1 year ago

Sorry, I was busy with other components. This looks like a bug. Hopefully, I will fix this by v0.26.0 unless someone else want to pick this up.

cugykw commented 10 months ago

/cc @cugykw

cugykw commented 10 months ago

This problem seems to be that spec.namespaceSelector is not set, and the is-multi-ns parameter is set to false, causing el to only listen to the triggers in the namespace where el is located. Triggers in other namespaces will not be triggered. It may be the same problem as the issue #1652 .