在 Argo Events 传感器触发器中遇到了无法使 rateLimit 正常工作的问题。

huangapple go评论62阅读模式
英文:

Having trouble getting rateLimit working in Argo Events sensor trigger

问题

I'm trying to limit the number of Argo workflows started per minute in an Argo events sensor trigger using the rateLimit parameter as specified in https://argoproj.github.io/argo-events/sensors/more-about-sensors-and-triggers/. But no luck so far.

Here's a snippet of my sensor YAML test script:

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: amqp-level0
spec:
  template:
    serviceAccountName: operate-workflow-sa
  dependencies:
    - name: test-dep
      eventSourceName: amqp-interval
      eventName: interval
  triggers:
    - rateLimit:
        unit: Minute
        requestsPerUnit: 5
    - template:
        name: amqp-workflow-trigger
        k8s:
          operation: create
          source:
            resource:
              apiVersion: argoproj.io/v1alpha1
              kind: Workflow
              ...

Without the rateLimit block, the sensor loads into k8s fine. But with that block, it doesn't run, and I see the following in the controller-manager logs:

{"level":"error","ts":1680700596.098304,"logger":"argo-events.eventbus-controller","caller":"sensor/controller.go:74","msg":"reconcile error","namespace":"argo-events","sensor":"amqp-level0","error":"trigger template can't be nil","stacktrace":"github.com/argoproj/argo-events/controllers/sensor.(*reconciler).Reconcile\n\t/home/runner/work/argo-events/argo-events/controllers/sensor/controller.go:74\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:114\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:311\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:227"}

(Note the "trigger template can't be nil", which seems to be the issue, but I haven't figured out how to resolve.)

The Argo events installed is 1.7.6, and Argo is

> argo version
argo: v3.4.6
  BuildDate: 2023-03-31T19:53:49Z
  GitCommit: 988706dd131cf98808f09fb7cc03780e2af94c73
  GitTreeState: clean
  GitTag: v3.4.6
  GoVersion: go1.18.10
  Compiler: gc
  Platform: linux/amd64

Any ideas? Thanks.

英文:

I'm trying to limit the number of Argo workflows started per minute in an Argo events sensor trigger using the rateLimit parameter as specified in https://argoproj.github.io/argo-events/sensors/more-about-sensors-and-triggers/. But no luck so far.

Here's a snippet of my sensor YAML test script:

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: amqp-level0
spec:
  template:
    serviceAccountName: operate-workflow-sa
  dependencies:
    - name: test-dep
      eventSourceName: amqp-interval
      eventName: interval
  triggers:
    - rateLimit:
        unit: Minute
        requestsPerUnit: 5
    - template:
        name: amqp-workflow-trigger
        k8s:
          operation: create
          source:
            resource:
              apiVersion: argoproj.io/v1alpha1
              kind: Workflow
              ...

Without the rateLimit block, the sensor loads into k8s fine. But with that block, it doesn't run, and I see the following in the controller-manager logs:

{"level":"error","ts":1680700596.098304,"logger":"argo-events.eventbus-controller","caller":"sensor/controller.go:74","msg":"reconcile error","namespace":"argo-events","sensor":"amqp-level0","error":"trigger template can't be nil","stacktrace":"github.com/argoproj/argo-events/controllers/sensor.(*reconciler).Reconcile\n\t/home/runner/work/argo-events/argo-events/controllers/sensor/controller.go:74\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:114\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:311\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.2/pkg/internal/controller/controller.go:227"}

(Note the "trigger template can't be nil", which seems to be the issue, but I haven't figured out how to resolve.)

The Argo events installed is 1.7.6, and Argo is

> argo version
argo: v3.4.6
  BuildDate: 2023-03-31T19:53:49Z
  GitCommit: 988706dd131cf98808f09fb7cc03780e2af94c73
  GitTreeState: clean
  GitTag: v3.4.6
  GoVersion: go1.18.10
  Compiler: gc
  Platform: linux/amd64

Any ideas? Thanks.

答案1

得分: 0

Ok,最终回到这个并找出了正确的命名规范。 rateLimit 块需要以以下语法输入(或至少可以与之一起使用):

triggers:
  - template:
      name: amqp-workflow-trigger
      k8s:
        operation: create
        source:
          ...

    rateLimit:
      unit: Minutes
      requestsPerUnit: 5

有了这个,传感器以指定的速率读取事件消息。

英文:

Ok, finally got back to this and figured out the proper nomenclature. The rateLimit block needs to be entered with (or at least works with) the following syntax:

triggers:
  - template:
      name: amqp-workflow-trigger
      k8s:
        operation: create
        source:
          ...

    rateLimit:
      unit: Minutes
      requestsPerUnit: 5

With that, the sensor is reading event messages at the prescribed rate.

huangapple
  • 本文由 发表于 2023年4月6日 23:03:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75951014.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定