Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

publish notification to GCP Pub/Sub #90

Merged
merged 3 commits into from
Apr 24, 2020
Merged

Conversation

honnix
Copy link
Member

@honnix honnix commented Apr 14, 2020

TL;DR

Add support of GCP Pub/Sub for publishing workflow execution events.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

Tested on a GCP project with configuration:

notifications:
  type: gcp
  projectId: "flyte-test"
  publisher:
    topicName: "flyte"
  emailer:
    subject: "Notice: Execution \"{{ name }}\" has {{ phase }} in \"{{ domain }}\"."
    sender:  "[email protected]"
    body: >
      Execution \"{{ name }}\" has {{ phase }} in \"{{ domain }}\". View details at
      <a href=\http://example.com/projects/{{ project }}/domains/{{ domain }}/executions/{{ name }}>
      http://example.com/projects/{{ project }}/domains/{{ domain }}/executions/{{ name }}</a>. {{ error }}

Subscriber and emailer are NOT implemented in this PR, and the emailer configuration is only use to verify the correctness of message body.

Tracking Issue

flyteorg/flyte#268

Follow-up issue

NA

@honnix
Copy link
Member Author

honnix commented Apr 14, 2020

I have a thought around the publishing part.

To me tailoring the message (with rigid email structure) already at publishing stage is a bit too early. I can understand this notification was probably designed for emailing purpose only, however I think it could be used for other things if the message only contains informative fields, e.g. project, domain, error, name, and the subscriber can decide how to reshape it later on.

katrogan
katrogan previously approved these changes Apr 14, 2020
@katrogan
Copy link
Contributor

To me tailoring the message (with rigid email structure) already at publishing stage is a bit too early

Agreed, we built out the notifications feature with the original intent of just being able to produce email notifications but the eventual goal is to have a rich notification system that spans beyond emails and includes additional user-topic queues and of course, flexible notification message structures. This is all on the back-log unfortunately :(

@kumare3
Copy link
Contributor

kumare3 commented Apr 15, 2020

@honnix yes, eventual goal is to publish subscribable notifications to some pubsub system. I think the biggest thing we need to do is define the egress structure. But, this is awesome, 💯

@@ -129,7 +129,9 @@ type NotificationsConfig struct {
// scheme is used.
Type string `json:"type"`
// Some cloud providers require a region to be set.
Region string `json:"region"`
Region string `json:"region"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should have 2 different structures.
AWS {
Region:
}

GCP {
projectID
}

etc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense. Unfortunately that would be a breaking change. How do we handle this kind of change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also there are a few other places having Region defined, should we change them all? It does feel out of scope of this PR though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played with this idea a bit. PTAL honnix#1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @kumare3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is out of the scope of this PR. But, if you can create a follow up issue we are golden :)

@honnix
Copy link
Member Author

honnix commented Apr 15, 2020

I tried a bit to add unit tests, but it seems this is where dependency injection happens, so I guess it is fine to skip unit test than adding another layer of injection?

@honnix
Copy link
Member Author

honnix commented Apr 15, 2020

@katrogan @kumare3 We configured the message body to be a JSON, but due to no proper escaping, it's like playing with fire (as an example we cannot put error there):

  emailer:
    ...
    body: >-
      {
        "project": "{{ project }}",
        "domain": "{{ domain }}",
        "name": "{{ name }}",
        "phase": "{{ phase }}",
        "workflowProject": "{{ workflow.project }}",
        "workflowDomain": "{{ workflow.domain }}",
        "workflowName": "{{ workflow.name }}",
        "workflowVersion": "{{ workflow.version }}",
        "launchPlanProject": "{{ launch_plan.project }}",
        "launchPlanDomain": "{{ launch_plan.domain }}",
        "launchPlanName": "{{ launch_plan.name }}",
        "launchPlanVersion": "{{ launch_plan.version }}"
      }

have dedicated config sections for aws and gcp
@kumare3
Copy link
Contributor

kumare3 commented Apr 23, 2020

@katrogan ^^ did you see the mess

@katrogan @kumare3 We configured the message body to be a JSON, but due to no proper escaping, it's like playing with fire (as an example we cannot put error there):

  emailer:
    ...
    body: >-
      {
        "project": "{{ project }}",
        "domain": "{{ domain }}",
        "name": "{{ name }}",
        "phase": "{{ phase }}",
        "workflowProject": "{{ workflow.project }}",
        "workflowDomain": "{{ workflow.domain }}",
        "workflowName": "{{ workflow.name }}",
        "workflowVersion": "{{ workflow.version }}",
        "launchPlanProject": "{{ launch_plan.project }}",
        "launchPlanDomain": "{{ launch_plan.domain }}",
        "launchPlanName": "{{ launch_plan.name }}",
        "launchPlanVersion": "{{ launch_plan.version }}"
      }

@katrogan did you see this message?

@kumare3
Copy link
Contributor

kumare3 commented Apr 23, 2020

@honnix can we take this as a separate issue and merge this one. I think your changes look good.

@katrogan
Copy link
Contributor

+1 to filing a separate issue for message formatting

@honnix
Copy link
Member Author

honnix commented Apr 24, 2020

@katrogan @kumare3 Absolutely as it should be. I will create an issue to track that. Thanks for reviewing the PR!

@honnix honnix merged commit 6825482 into flyteorg:master Apr 24, 2020
@honnix honnix deleted the gcp-pubsub branch April 24, 2020 06:16
@honnix
Copy link
Member Author

honnix commented Apr 24, 2020

Here it is flyteorg/flyte#293

eapolinario pushed a commit that referenced this pull request Sep 6, 2023
* publish notification to GCP Pub/Sub

* have dedicated config sections for aws and gcp

Close flyteorg/flyte#268
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants