automatiko-io / automatiko-approval-task

Tekton Pipeline Custom task implementation to add approval capabilities into the pipelines
Apache License 2.0
42 stars 14 forks source link

Help wanted debugging approvalUrl "Task you're looking for has not been found" #18

Closed brainbug95 closed 3 weeks ago

brainbug95 commented 3 weeks ago

Hello,

I successfully deployed automatiko-approval-task to the NS "tekton-cd" on my k3s-based arm64 cluster. I created a pipeline which successfully creates customruns and approvaltask. The issue is that I am not able to actually approve the task allowing the pipeline to continue. If I try accessing the link presented inside the task "approvalUrl: /management/tasks/link/c2luZ2xlfGYyMjhiNjRjLTU0NjktM2NlOC1iYzJmLWNiOGUxMDgxZTc0Zjo4OTZkMzBmZC1kYjViLTRkNzktOWIwZi05ODMxZThlN2Q0YjV8MzFiNzU1ZDAtZjFkNi00N2VkLWJhOGEtZDZiYmMzMGRlMWFifA=="

I just get

image

logs show some errors which might be related:

kk -n tekton-cd logs pod/automatiko-approval-task-5966ff987c-9knpj
 ______     __  __     ______   ______     __    __     ______     ______   __     __  __     ______
/\  __ \   /\ \/\ \   /\__  _\ /\  __ \   /\ "-./  \   /\  __ \   /\__  _\ /\ \   /\ \/ /    /\  __ \
\ \  __ \  \ \ \_\ \  \/_/\ \/ \ \ \/\ \  \ \ \-./\ \  \ \  __ \  \/_/\ \/ \ \ \  \ \  _"-.  \ \ \/\ \
 \ \_\ \_\  \ \_____\    \ \_\  \ \_____\  \ \_\ \ \_\  \ \_\ \_\    \ \_\  \ \_\  \ \_\ \_\  \ \_____\
  \/_/\/_/   \/_____/     \/_/   \/_____/   \/_/  \/_/   \/_/\/_/     \/_/   \/_/   \/_/\/_/   \/_____/
                                                                          Powered by Quarkus 3.2.2.Final
2024-06-21 06:32:52,168 INFO  [io.und.websockets] (main) UT026003: Adding annotated server endpoint class io.automatiko.engine.addons.events.ws.ProcessEventsEndpoint for path /process/events
2024-06-21 06:32:53,927 INFO  [io.qua.ope.run.ConfigurationServiceRecorder] (main) Leader election deactivated because it is only activated for [prod] profiles. Currently active profiles: [withemail]
2024-06-21 06:32:54,037 INFO  [io.qua.ope.run.OperatorProducer] (main) Quarkus Java Operator SDK extension 6.2.1 (commit: 2ba533d on branch: 2ba533dc2c2cf7ab3083a641f7a1badca5d68a62) built on Tue Jul 04 13:00:42 GMT 2023
2024-06-21 06:32:54,065 INFO  [io.qua.ope.run.AppEventListener] (main) Starting operator.
2024-06-21 06:32:54,909 WARN  [io.fab.kub.cli.dsl.int.VersionUsageUtils] (InformerWrapper [customruns.tekton.dev/v1beta1] 33) The client is using resource type 'customruns' with unstable version 'v1beta1'
2024-06-21 06:32:54,910 WARN  [io.fab.kub.cli.dsl.int.VersionUsageUtils] (InformerWrapper [approvaltasks.tekton.automatiko.io/v1beta1] 34) The client is using resource type 'approvaltasks' with unstable version 'v1beta1'
2024-06-21 06:32:55,372 INFO  [io.quarkus] (main) automatiko-approval-task 0.10.1 on JVM (powered by Quarkus 3.2.2.Final) started in 4.295s. Listening on: http://0.0.0.0:8080
2024-06-21 06:32:55,372 INFO  [io.quarkus] (main) Profile withemail activated.
2024-06-21 06:32:55,372 INFO  [io.quarkus] (main) Installed features: [automatiko, cdi, jdbc-sqlite, kubernetes, kubernetes-client, mailer, micrometer, openshift-client, operator-sdk, qute, rest-client-reactive, resteasy-reactive, resteasy-reactive-jackson, resteasy-reactive-qute, security, smallrye-context-propagation, smallrye-health, smallrye-openapi, swagger-ui, vertx, websockets, websockets-client]
2024-06-21 06:32:55,456 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Could not find variable scope for variable "Approval task for " +resource.getSpec().getPipeline()
2024-06-21 06:32:55,457 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) when trying to replace variable in string for Work Item Human Task
2024-06-21 06:32:55,458 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Continuing without setting parameter.
2024-06-21 06:32:55,458 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Could not find variable scope for variable emailSubject(resource)
2024-06-21 06:32:55,460 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) when trying to replace variable in string for Work Item Human Task
2024-06-21 06:32:55,461 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Continuing without setting parameter.
2024-06-21 06:32:55,461 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Could not find variable scope for variable approversAsString(resource)
2024-06-21 06:32:55,462 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) when trying to replace variable in string for Work Item Human Task
2024-06-21 06:32:55,463 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Continuing without setting parameter.
2024-06-21 06:32:55,463 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Could not find variable scope for variable resource.getSpec()
2024-06-21 06:32:55,464 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) when trying to replace variable in string for Work Item Human Task
2024-06-21 06:32:55,465 ERROR [io.aut.eng.wor.pro.ins.nod.WorkItemNodeInstance] (ReconcilerExecutor-approvals-40) Continuing without setting parameter.
2024-06-21 06:32:55,514 WARN  [io.aut.eng.add.use.sla.SlackNotificationEmitter] (ReconcilerExecutor-approvals-40) No slack channel webhook url defined for task approval in process single, ignoring slack notification
2024-06-21 06:32:55,515 WARN  [io.aut.eng.add.use.tea.TeamsNotificationEmitter] (ReconcilerExecutor-approvals-40) No slack channel webhook url defined for task approval in process single, ignoring teams notification

Basically I'm running https://github.com/automatiko-io/automatiko-approval-task/blob/main/k8s/v1beta1/kubernetes-basic.yml adjusted for the namespace "tekton-cd" instead of "default".

The pipeline definition itself is configured like this:

  - name: approval
    runAfter: ["pre-deploy"]
    taskRef:
      apiVersion: tekton.automatiko.io/v1beta1
      kind: ApprovalTask
      name: approvaltask
    params:
      - name: pipeline
        value: "$(context.pipelineRun.name)"
      - name: description
        value: "Sample approval from pipeline $(context.pipeline.name)"

  - name: approved
    when:
      - input: $(tasks.approval.results.decision)
        operator: in
        values: [ "true" ]
    taskRef:
      name: print-decision
    runAfter:
      - approval
    params:
      - name: decision
        value: "APPROVED"
      - name: comment
        value: $(tasks.approval.results.comment)

  - name: rejected
    when:
      - input: $(tasks.approval.results.decision)
        operator: in
        values: [ "false" ]
    taskRef:
      name: print-decision
    runAfter:
      - approval
    params:
      - name: decision
        value: "REJECTED"
      - name: comment
        value: $(tasks.approval.results.comment)

Any insights would be appreciated .

mswiderski commented 3 weeks ago

it looks like you have not assigned it to anyone so that means no-one will be able to approve it. Here is sample pipeline https://github.com/automatiko-io/automatiko-approval-task/blob/main/k8s/v1beta1/test/pipeline-single.yaml#L18

and here you can see the different options https://github.com/automatiko-io/automatiko-approval-task?tab=readme-ov-file#parameters and this section can also be useful https://github.com/automatiko-io/automatiko-approval-task?tab=readme-ov-file#my-approval-tasks

brainbug95 commented 3 weeks ago

Hi,

i had approvers configured beforehand which did not work so I removed them. I added them again but still no task is found.

  - name: approval
    runAfter: ["pre-deploy"]
    taskRef:
      apiVersion: tekton.automatiko.io/v1beta1
      kind: ApprovalTask
      name: approvaltask
    params:
      - name: pipeline
        value: "$(context.pipelineRun.name)"
      - name: description
        value: "Sample approval from pipeline $(context.pipeline.name)"
      - name: approvers
        value:
          - "john@email.com"
      - name: strategy
        value: SINGLE

e.g.

http://automatiko-approval-task.tekton-cd/management/tasks/link/c2luZ2xlfGE1OGQzMmQzLWQ4NzUtM2ZmYS04YjQyLTIwZWEzYTBmMWFiNDo4ODUwMThmNC1lNDI2LTQ0ZGMtOWNmMS00YzY2NDc5ZmFjMzZ8NDQwOTBmZmYtNWMxMy00ZjUzLTllZWUtYmMzOGIzNzg5MWU2fA==?user=john@email.com

/tasks.html does not show anything either when searching for tasks for user "john@email.com"

mswiderski commented 3 weeks ago

can you inspect the state via management ui? https://github.com/automatiko-io/automatiko-approval-task?tab=readme-ov-file#management-view-for-admins-only maybe there will be something interesting there why the tasks are not visible.

brainbug95 commented 3 weeks ago

I am running automatiko-approval-task standalone. How can I access this management view?

mswiderski commented 3 weeks ago

it should be available at this path /management/processes/ui and just a double check by standalone you mean within Kubernetes cluster or outside of it?

brainbug95 commented 3 weeks ago

Yes, automatiko-approval-task is running on a kubernetes cluster with most recent tekton-operator. What I meant was that there are is nothing else from the automatiko project installed.

brainbug95 commented 3 weeks ago

Management UI looks like this:

image

I exported some json files from the UI as well. 387bcbd8-0c80-333e-a010-34dc90dafb5a (1).json 387bcbd8-0c80-333e-a010-34dc90dafb5a.json

Maybe this helps.

mswiderski commented 3 weeks ago

thanks for that, I think what is going on - it is actually caused by the base image I suggested in the other issue. It uses java 21 and there is one issue with mvel library that must be upgraded.

Using java 17 should make it work. Could you please rebuild the image with arm64v8/eclipse-temurin:17-ubi9-minimal as base image instead?

brainbug95 commented 3 weeks ago

Thanks, I will rebuild and deploy on Monday.

mswiderski commented 3 weeks ago

just updated all required libraries and built new version that can be pulled from ghcr.io/automatiko-io/automatiko-approval-task:0.11.0-arm64 you can give it a try instead of building yourself.

brainbug95 commented 3 weeks ago

Hi. I just changed the image to the one you provided. Still the same issue: "Task you are looking for was not found". Anything else I can help with?

mswiderski commented 3 weeks ago

can you provide the logs from the pod?

brainbug95 commented 3 weeks ago

Sure thing: automatiko-approval-task-89f6546ff-tkhbw.pod.log

mswiderski commented 3 weeks ago

can you create new instance of the pipeline. I don't see any issues in the logs as it was before and the last line shows the previous was deleted because it timed out.

brainbug95 commented 3 weeks ago

I deleted all approval-task resources and referencing pipeline and than created everything anew to be sure. Then I triggered a pipelinerun and attached you'll find the logfile of the new pod.

automatiko-approval-task-89f6546ff-jm5qw.pod.log

I cannot see anything obviously failing. Please note that that neither calling approvalUrl nor tasks.html produce any log entries. Don't know if it's supposed to be like this.

mswiderski commented 3 weeks ago

can you do the same as you did here https://github.com/automatiko-io/automatiko-approval-task/issues/18#issuecomment-2182593456

brainbug95 commented 3 weeks ago

Tab 1

image

Tab 2

image

Exports:

b42c0a27-d101-39bc-95ee-b931e0e8c870 (1).json b42c0a27-d101-39bc-95ee-b931e0e8c870_50b88877-b245-4f9d-a0ac-94e05f126276.json b42c0a27-d101-39bc-95ee-b931e0e8c870.json

mswiderski commented 3 weeks ago

this all looks as expected, data is properly assigned, do you add user info to the url of the task? - john@email.com is the user who has access to the task to be completed.

mswiderski commented 3 weeks ago

here is an url that should give you direct access to the task - it is the one that is sent over email to individuals assigned http://localhost:8080/management/tasks/link/c2luZ2xlfGI0MmMwYTI3LWQxMDEtMzliYy05NWVlLWI5MzFlMGU4Yzg3MDo1MGI4ODg3Ny1iMjQ1LTRmOWQtYTBhYy05NGUwNWYxMjYyNzZ8MWQ1MWUyOGMtOTZiZC00MWFiLWFmZGYtOGI2ZDQ1ODY1ZDhhfGpvaG5AZW1haWwuY29t

brainbug95 commented 3 weeks ago

I did add the user on friday but forgot today. Sorry for that...

http://localhost:8080/management/tasks/link/c2luZ2xlfGI0MmMwYTI3LWQxMDEtMzliYy05NWVlLWI5MzFlMGU4Yzg3MDo1MGI4ODg3Ny1iMjQ1LTRmOWQtYTBhYy05NGUwNWYxMjYyNzZ8MWQ1MWUyOGMtOTZiZC00MWFiLWFmZGYtOGI2ZDQ1ODY1ZDhhfA==?user=john@email.com

Worked now as expected

image
mswiderski commented 3 weeks ago

good to hear that!

brainbug95 commented 3 weeks ago

Thanks for all your help. I really would like to get this working. Its the last missing piece to get rid of AWS Codepipelines.

mswiderski commented 3 weeks ago

no problem at all. Good luck then, happy to see it is useful :)