从传感器创建作业会出现“找不到请求的资源”错误

Creating a job from a sensor gives “could not find the requested resource” error

我正在使用 argo events/sensors 创建一个 Kubernetes 作业,传感器被正确触发但它给我错误“服务器找不到请求的资源”

这是我的sensor.yaml

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: exp-webhook
spec:
  template:
    serviceAccountName: crypto-job-sa
  dependencies:
    - name: payload
      eventSourceName: webhook
      eventName: devops-toolkit
  triggers:
    - template:
        name: sample-job
        k8s:
          group: batch
          version: v1
          resource: Job
          operation: create
          source:
            resource:
              apiVersion: batch/v1
              kind: Job
              metadata:
                name: exp-job-crypto
#                annotations:
#                  argocd.argoproj.io/hook: PreSync
#                  argocd.argoproj.io/hook-delete-policy: HookSucceeded
              spec:
                ttlSecondsAfterFinished: 100
                template:
                  spec:
                    restartPolicy: OnFailure
                    containers:
                      - name: crypto-job
                        image: docker.artifactory.xyz.com/xyz/pqr:master-b1b347a

这是错误的详细信息。

   {"level":"error","ts":1624900390.6760905,"logger":"argo-events.sensor","caller":"sensors/listener.go:271","msg":"failed to execute a trigger","sensorName":"exp-webhook","error":"failed to execute trigger: timed out waiting for the condition: the server could not find the requested resource",
            "errorVerbose":"timed out waiting for the condition: the server could not find the requested resource\nfailed to execute trigger\ngithub.com/argoproj/argo-events/sensors.
    (*SensorContext).triggerOne\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:328\ngithub.com/argoproj/argo-events/sensors.(*SensorContext).triggerActions\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:269\ngithub.com/argoproj/argo-events/sensors.(*SensorContext).listenEvents.func1.3\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:181\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1357","triggerName":"sample-job","triggeredBy":["payload"],"triggeredByEvents":["32396264373063382d306336312d343039322d616536652d623965383531346666373234"],"stacktrace":"github.com/argoproj/argo-events/sensors.
        
    (*SensorContext).triggerActions\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:271\ngithub.com/argoproj/argo-events/sensors.(*SensorContext).listenEvents.func1.3\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:181"}

但它并没有说明找不到什么资源。有人可以帮忙吗?我不知道这里有什么错误。

所以错误是 ,而不是

resource: Job

应该是

resource: jobs

解决了这个问题。