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

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

Closed
Gio-R opened this issue Jul 20, 2023 · 6 comments · Fixed by #1725
Closed

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

Gio-R opened this issue Jul 20, 2023 · 6 comments · Fixed by #1725
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Gio-R
Copy link

Gio-R commented Jul 20, 2023

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

  • Kubernetes version:

    Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.3", GitCommit:"25b4e43193bcda6c7328a6d147b1fb73a33f1598", GitTreeState:"clean", BuildDate:"2023-06-14T09:47:38Z", GoVersion:"go1.20.5", Compiler:"gc", Platform:"darwin/arm64"}
    Kustomize Version: v5.0.1
    Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:13:28Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"linux/arm64"}
    
  • Tekton Pipeline version: v0.47.0

  • Tekton Triggers version: v0.24.0

@Gio-R Gio-R added the kind/bug Categorizes issue or PR as related to a bug. label Jul 20, 2023
@khrm
Copy link
Contributor

khrm commented Jul 20, 2023

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
Copy link
Author

Gio-R commented Jul 20, 2023

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.

@Gio-R Gio-R changed the title Triggers called multiple times by EventListener Triggers called multiple times by EventListener or never called at all Jul 21, 2023
@lifeym
Copy link

lifeym commented Jul 31, 2023

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
Copy link
Contributor

khrm commented Aug 23, 2023

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.

@khrm khrm added this to the Triggers v0.26 milestone Oct 18, 2023
@cugykw
Copy link

cugykw commented Nov 4, 2023

/cc @cugykw

@cugykw
Copy link

cugykw commented Nov 4, 2023

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 .

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

Successfully merging a pull request may close this issue.

5 participants