automatiko-io / automatiko-approval-task

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

approver do not recieve Email notification when approval task created #3

Closed hillbun closed 2 years ago

hillbun commented 2 years ago

I set approvers to email of xxx@xxxx.com

                        - name: approvers
                          value:
                            - "xxx@xxxx.com"

k8s/kubernetes-email.yml

            - name: QUARKUS_MAILER_FROM
              value: xxx@xxxx.com
            - name: QUARKUS_MAILER_HOST
              value: 12.34.56.78             
            - name: QUARKUS_MAILER_PORT
              value: "25"
            - name: QUARKUS_MAILER_USERNAME
              value: xxx@xxxx.com
            - name: QUARKUS_MAILER_PASSWORD
              value: xxxxxxxxxxxxxx

My SMTP server is not tls, just 25 port。

but xxx@xxxx.com do not get email notification when approval task created.

and kubectl logs automatiko-approval-task-7cb9c7764c-gwxzw can not get any info about this.

Please advice.

mswiderski commented 2 years ago

you need to add one extra environment variable to active emails see https://github.com/automatiko-io/automatiko-approval-task/blob/main/k8s/kubernetes-email.yml#L188

Looks like it is missing in readme file. Please let me know if that solved the issue and I will proceed with updating the readme or if you want please update readme yourself and send PR, contributions more than welcome :)

hillbun commented 2 years ago

Yes, I have these lines in k8s/kubernetes-email.yml

    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: QUARKUS_OPERATOR_SDK_NAMESPACES
              value: default
            - name: QUARKUS_AUTOMATIKO_SERVICE_URL
              value: http://automatiko-approval-task.default/
            - name: QUARKUS_MAILER_FROM
              value: xxx@xxx.com
            - name: QUARKUS_MAILER_HOST
              value: 12.34.56.78
            - name: QUARKUS_MAILER_PORT
              value: "25"
            - name: QUARKUS_MAILER_USERNAME
              value: ab-cd\xyz.yy
            - name: QUARKUS_MAILER_PASSWORD
              value: abc@1234
            - name: QUARKUS_PROFILE
              value: withemail
mswiderski commented 2 years ago

could you attach logs from the pod? Config wise it looks valid so not sure why the mail server is not accepting the message or delivering. Anything in the mail server logs?

hillbun commented 2 years ago

I just get following logs:

 ______     __  __     ______   ______     __    __     ______     ______   __     __  __     ______    
/\  __ \   /\ \/\ \   /\__  _\ /\  __ \   /\ "-./  \   /\  __ \   /\__  _\ /\ \   /\ \/ /    /\  __ \   
\ \  __ \  \ \ \_\ \  \/_/\ \/ \ \ \/\ \  \ \ \-./\ \  \ \  __ \  \/_/\ \/ \ \ \  \ \  _"-.  \ \ \/\ \  
 \ \_\ \_\  \ \_____\    \ \_\  \ \_____\  \ \_\ \ \_\  \ \_\ \_\    \ \_\  \ \_\  \ \_\ \_\  \ \_____\ 
  \/_/\/_/   \/_____/     \/_/   \/_____/   \/_/  \/_/   \/_/\/_/     \/_/   \/_/   \/_/\/_/   \/_____/ 
                                                                         Powered by Quarkus 2.10.0.Final
2022-08-12 08:49:34,949 INFO  [io.qua.sma.ope.run.OpenApiRecorder] (main) Default CORS properties will be used, please use 'quarkus.http.cors' properties instead
2022-08-12 08:49:34,972 INFO  [io.qua.ope.run.AppEventListener] (main) Quarkus Java Operator SDK extension 3.0.8 (commit: ef221b3 on branch: ef221b39cd8eb90fdc88fe85d742d669195727c0) built on Wed Jun 08 13:55:41 GMT 2022
2022-08-12 08:49:35,004 WARN  [io.fab.kub.cli.int.VersionUsageUtils] (ForkJoinPool.commonPool-worker-3) The client is using resource type 'runs' with unstable version 'v1alpha1'
2022-08-12 08:49:35,004 WARN  [io.fab.kub.cli.int.VersionUsageUtils] (main) The client is using resource type 'approvaltasks' with unstable version 'v1alpha1'
2022-08-12 08:49:35,088 INFO  [io.quarkus] (main) automatiko-approval-task 0.3.3 native (powered by Quarkus 2.10.0.Final) started in 0.176s. Listening on: http://0.0.0.0:8080
2022-08-12 08:49:35,088 INFO  [io.quarkus] (main) Profile withemail activated. 
2022-08-12 08:49:35,088 INFO  [io.quarkus] (main) Installed features: [automatiko, automatiko-operator, cdi, kubernetes, kubernetes-client, mailer, micrometer, openshift-client, operator-sdk, qute, resteasy-reactive, resteasy-reactive-jackson, resteasy-reactive-qute, security, smallrye-context-propagation, smallrye-health, smallrye-openapi, swagger-ui, vertx, websockets, websockets-client]
2022-08-12 08:53:19,689 INFO  [io.aut.tek.tas.app.int.ApprovalTaskResourceOperations] (EventHandler-runs) New approval task has been created RunStatus [startTime=2022-08-12T08:53:19Z, results=null, conditions=[{reason=Succeeded, message=Approval Task has been created, status=Unknown}]]
2022-08-12 08:53:19,690 INFO  [io.aut.eng.add.per.fil.job.FileSystemBasedJobService] (EventHandler-runs) Timer scheduled for date 2022-08-12T09:53:19.690191Z[GMT] will expire in 3599999
2022-08-12 08:58:58,179 INFO  [io.aut.tek.tas.app.int.ApprovalTaskResourceOperations] (EventHandler-runs) New approval task has been created RunStatus [startTime=2022-08-12T08:58:58Z, results=null, conditions=[{reason=Succeeded, message=Approval Task has been created, status=Unknown}]]
2022-08-12 08:58:58,179 INFO  [io.aut.eng.add.per.fil.job.FileSystemBasedJobService] (EventHandler-runs) Timer scheduled for date 2022-08-12T09:58:58.179658Z[GMT] will expire in 3599999
2022-08-17 07:45:32,026 INFO  [io.aut.tek.tas.app.int.ApprovalTaskResourceOperations] (EventHandler-runs) New approval task has been created RunStatus [startTime=2022-08-17T07:45:32Z, results=null, conditions=[{reason=Succeeded, message=Approval Task has been created, status=Unknown}]]
2022-08-17 07:45:32,047 INFO  [io.aut.eng.add.per.fil.job.FileSystemBasedJobService] (EventHandler-runs) Timer scheduled for date 2022-08-17T08:45:32.046352Z[GMT] will expire in 3599998

And I can not reach smtp server to get logs.

mswiderski commented 2 years ago

let's try if disabling the start pls will make any difference, please add following env to the deployment resource

- name: QUARKUS_MAILER_START_TLS
  value: DISABLED

In addition can you validate your actual emails against this regex (^\s*?(.+)@(.+?)\s*$)? For instance you can use this website https://regex101.com This regex is used to check if the approvers are actually email addresses and only then attempt to send emails.

Another investigation step is to enable mock of emails and that should not connect to email server but just log the email body to the logs. To do so add following

- name: QUARKUS_MAILER_MOCK
  value: true
hillbun commented 2 years ago

I add env to deployment

and it solved.

How to customize email Template?

mswiderski commented 2 years ago

very good to hear that it was solved by that. Will include in the readme.

How to customize email Template?

It's currently not possible, could you please open new issue for ability to customise email templates?

mswiderski commented 2 years ago

closing this one as email sending is now solved and email templates will be addressed via https://github.com/automatiko-io/automatiko-approval-task/issues/4