I am using argo events/sensors to create a Kubernetes Job , the sensor gets triggered correctly but it is giving me error "the server could not find the requested resource"
Here is my 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
And here is the error details.
{"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"}
But it does not tell what resource is not found. Can someone please help? I don't know what is the mistake here.
So the error was , instead of
resource: Job
it should be
resource: jobs
That fixed this issue.