Giter VIP home page Giter VIP logo

tekton-step-observer's Introduction

Top Langs

tekton-step-observer's People

Contributors

dependabot-preview[bot] avatar tom24d avatar

Stargazers

 avatar

Watchers

 avatar

tekton-step-observer's Issues

Cannot get the latest resource from TaskRun Informer

Describe the bug
when step observe controller detects the state that should be reported as CloudEvent, emit it and mark that has been actually "reported" in the metadata.annotation&PATCH it. However, 50% ratio the controller cannot get latest info with latest annotation from the TaskRun informer, so it cannot manage event emission status.

To Reproduce

  1. Install pipeline, step-observe-controller
  2. Apply task:
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: hello1
spec:
  steps:
    - name: hello1
      image: ubuntu
      command:
        - sleep
      args:
        - "15"
    - name: hello2
      image: ubuntu
      command:
        - sleep
      args:
        - "10 && exit 111"
    - name: hello3
      image: ubuntu
      command:
        - echo
      args:
        - "Hello World! ver 2"
  1. tkn task start hello1
  2. See duplicate started emission for step hello1 in the log:
{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"step/reconciler.go:100","msg":"EVENT EMISSION step: hello1, type: dev.tekton.events.plugin.step.started.v1, annotation: &{[{hello1 [dev.tekton.events.plugin.step.started.v1]} {hello2 []} {hello3 []}]}","knative.dev/traceid":"e8522690-e741-46f3-935f-cf4c0c16ef31","knative.dev/key":"default/hello1-run-6dtq7"}
{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"step/reconciler.go:79","msg":"PATCH: {\"metadata\":{\"creationTimestamp\":null,\"annotations\":{\"tom24d.plugin.step-observer/result\":\"{\\\"statuses\\\":[{\\\"name\\\":\\\"hello1\\\",\\\"emitted\\\":[\\\"dev.tekton.events.plugin.step.started.v1\\\"]},{\\\"name\\\":\\\"hello2\\\",\\\"emitted\\\":[]},{\\\"name\\\":\\\"hello3\\\",\\\"emitted\\\":[]}]}\"}},\"spec\":{\"serviceAccountName\":\"\"},\"status\":{\"podName\":\"\"}}","knative.dev/traceid":"e8522690-e741-46f3-935f-cf4c0c16ef31","knative.dev/key":"default/hello1-run-6dtq7"}
{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"controller/controller.go:474","msg":"Reconcile succeeded. Time taken: 24.3282ms","knative.dev/traceid":"e8522690-e741-46f3-935f-cf4c0c16ef31","knative.dev/key":"default/hello1-run-6dtq7"}

{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"step/reconciler.go:34","msg":"RECEIVED annotation: &{[{hello1 [dev.tekton.events.plugin.step.started.v1]} {hello2 []} {hello3 []}]}","knative.dev/traceid":"e256592a-3798-4e44-be0c-c011e407ff43","knative.dev/key":"default/hello1-run-6dtq7"}
{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"step/reconciler.go:79","msg":"PATCH: {\"metadata\":{\"creationTimestamp\":null,\"annotations\":{\"tom24d.plugin.step-observer/result\":\"{\\\"statuses\\\":[{\\\"name\\\":\\\"hello1\\\",\\\"emitted\\\":[\\\"dev.tekton.events.plugin.step.started.v1\\\"]},{\\\"name\\\":\\\"hello2\\\",\\\"emitted\\\":[]},{\\\"name\\\":\\\"hello3\\\",\\\"emitted\\\":[]}]}\"}},\"spec\":{\"serviceAccountName\":\"\"},\"status\":{\"podName\":\"\"}}","knative.dev/traceid":"e256592a-3798-4e44-be0c-c011e407ff43","knative.dev/key":"default/hello1-run-6dtq7"}
{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"controller/controller.go:474","msg":"Reconcile succeeded. Time taken: 24.3593ms","knative.dev/traceid":"e256592a-3798-4e44-be0c-c011e407ff43","knative.dev/key":"default/hello1-run-6dtq7"}

{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"step/reconciler.go:34","msg":"RECEIVED annotation: &{[{hello1 []} {hello2 []} {hello3 []}]}","knative.dev/traceid":"e9279bec-1345-4db2-a7bb-1e5091942cba","knative.dev/key":"default/hello1-run-6dtq7"}
{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"step/reconciler.go:100","msg":"EVENT EMISSION step: hello1, type: dev.tekton.events.plugin.step.started.v1, annotation: &{[{hello1 [dev.tekton.events.plugin.step.started.v1]} {hello2 []} {hello3 []}]}","knative.dev/traceid":"e9279bec-1345-4db2-a7bb-1e5091942cba","knative.dev/key":"default/hello1-run-6dtq7"}
{"level":"info","logger":"step-observe-controller.step-observe-controller","caller":"step/reconciler.go:79","msg":"PATCH: {\"metadata\":{\"creationTimestamp\":null,\"annotations\":{\"tom24d.plugin.step-observer/result\":\"{\\\"statuses\\\":[{\\\"name\\\":\\\"hello1\\\",\\\"emitted\\\":[\\\"dev.tekton.events.plugin.step.started.v1\\\"]},{\\\"name\\\":\\\"hello2\\\",\\\"emitted\\\":[]},{\\\"name\\\":\\\"hello3\\\",\\\"emitted\\\":[]}]}\"}},\"spec\":{\"serviceAccountName\":\"\"},\"status\":{\"podName\":\"\"}}","knative.dev/traceid":"e9279bec-1345-4db2-a7bb-1e5091942cba","knative.dev/key":"default/hello1-run-6dtq7"}

Expected behavior
It should get the latest resource

Version info:

  • Pipeline: 1.14.0
  • Kubernetes: 1.16.x

Assert CloudEvent time in some way

ContainerStateRunning.StartedAt != ContainerStateTerminated makes hard to assert CloudEvent Time. consider it or give up.

Event log:

 Validation: valid
 Context Attributes,
   specversion: 1.0
   type: dev.tekton.events.plugin.step.succeeded.v1
   source: /api/v1/namespaces/tekton-pipelines/pods/tekton-step-observer
   id: c4b6214d-1a53-4960-bd3a-efe1aa69a477
   time: 2020-08-05T13:16:28Z
   datacontenttype: application/json
 Extensions,
   knativearrivaltime: 2020-08-05T13:16:29.6568031Z
   knativehistory: inmemorychannel-kne-trigger-kn-channel.test-event-assertion-single-task-in-memory-channel-messagindmkw.svc.cluster.local
 Data,
   {
     "podRef": {
       "kind": "Pod",
       "namespace": "test-event-assertion-single-task-in-memory-channel-messagindmkw",
       "name": "e2e-test-step-observed-run-pod-n9ptp",
       "apiVersion": "v1"
     },
     "log": "hello1\n",
     "step": {
       "name": "",
       "image": "busybox@sha256:895ab622e92e18d6b461d671081757af7dbaa3b00e3e28e12505af7817f73649",
       "command": [
         "/bin/sh"
       ],
       "args": [
         "-c",
         "echo hello1"
       ],
       "resources": {}
     },
     "stepState": {
       "terminated": {
         "exitCode": 0,
         "reason": "Completed",
         "startedAt": "2020-08-05T13:16:28Z",
         "finishedAt": "2020-08-05T13:16:28Z",
         "containerID": "containerd://a75e04dfc9f21e4f77c671bce594954034758a369ad029c95fd59d5620114898"
       },
       "name": "unnamed-0",
       "container": "step-unnamed-0",
       "imageID": "docker.io/library/busybox@sha256:895ab622e92e18d6b461d671081757af7dbaa3b00e3e28e12505af7817f73649"
     }
   }

and

 2020/08/05 13:16:27 eventdetails:
 Validation: valid
 Context Attributes,
   specversion: 1.0
   type: dev.tekton.events.plugin.step.started.v1
   source: /api/v1/namespaces/tekton-pipelines/pods/tekton-step-observer
   id: f440e80e-3455-4b7c-a91a-88c2c4ec1637
   time: 2020-08-05T13:16:26Z
   datacontenttype: application/json
 Extensions,
   knativearrivaltime: 2020-08-05T13:16:27.7858596Z
   knativehistory: inmemorychannel-kne-trigger-kn-channel.test-event-assertion-single-task-in-memory-channel-messagindmkw.svc.cluster.local
 Data,
   {
     "podRef": {
       "kind": "Pod",
       "namespace": "test-event-assertion-single-task-in-memory-channel-messagindmkw",
       "name": "e2e-test-step-observed-run-pod-n9ptp",
       "apiVersion": "v1"
     },
     "step": {
       "name": "",
       "image": "busybox@sha256:895ab622e92e18d6b461d671081757af7dbaa3b00e3e28e12505af7817f73649",
       "command": [
         "/bin/sh"
       ],
       "args": [
         "-c",
         "echo hello1"
       ],
       "resources": {}
     },
     "stepState": {
       "running": {
         "startedAt": "2020-08-05T13:16:26Z"
       },
       "name": "unnamed-0",
       "container": "step-unnamed-0",
       "imageID": "docker.io/library/busybox@sha256:895ab622e92e18d6b461d671081757af7dbaa3b00e3e28e12505af7817f73649"
     }
   }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.