Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC : CDEvents Webhook Adapter design review #42

Merged
merged 12 commits into from
Mar 19, 2024

Conversation

rjalander
Copy link
Contributor

Creating this PR, to review the current design approach and propose any changes that might help in creating a common cdevents-translator library.

Adding a page for Gerrit-CDEvents integration and mapping for various Gerrit events to CDEvents.

### Overview:
This proposal describes translating events from various source control systems into CDEvents and sending them to configured message-broker, by using a common cdevents-translator

A library cdevents-translator will be developed to receive various event types and convert them into CDEvents.
Copy link
Contributor

Choose a reason for hiding this comment

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

How this will work in terms of supporting multiple types?
Will the library provide an interface that various implementors can implement independently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes an interface EventTranslator will be created with the implementation needed for TranslateEvent() for different source of events(GitHub/Gerrit`/...etc)

type EventTranslator interface {
	TranslateEvent()
}

And will have a common methods to create and send CDEvents, will update the design as per this.

Instructions for configuring Gerrit webhooks and implementation details can be found in [gerrit-cdevent](gerrit-cdevents.md)

### Design approach
Create a Golang application with an API server configured to initialize SCM systems webhooks/endpoints to receive events and translate them into CDEvents.
Copy link
Contributor

Choose a reason for hiding this comment

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

The following just for info.

Tekton Triggers provides and API server that can reply to webhooks. It supports incoming CloudEvents as well as generic webhooks and it provides a powerful templating mechanism to extract information from incoming payloads and produce a YAML out of them. I used it in this POC https://github.com/afrittoli/cdeventer.

The approach of CDEventer is a bit more complex, but it has the advantage of decoupling the processing of incoming messages, which is then implemented as a set of input specific TriggerBindings, from the actual sending of the target CDEvents, through the use of an intermediate YAML.

The downside of CDEventer is the extra dependency to Tekton (and thus K8s).

@rjalander rjalander force-pushed the rfc_cdevents_translator branch from e72bf27 to cc9f1f0 Compare January 12, 2024 15:51
rfc/cdevents-translator.md Show resolved Hide resolved
@rjalander rjalander requested review from afrittoli and xibz January 25, 2024 10:04
@rjalander
Copy link
Contributor Author

Thank you @xibz for directing various approaches for the translator.

@afrittoli @xibz please let us know your views on these design proposals and review.

Copy link
Contributor

@xibz xibz left a comment

Choose a reason for hiding this comment

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

This looks much better @rjalander! One thing I noticed missing was a final "Conclusions" to summarize which was preferred by you, etc. Or did you want to leave that up for discussion?

This structure can be extended by adding more translator libraries in the future without modifying the main application code.</br>
The problem with this approach anyone who is wanting some custom set of translator would need to write their own main class.

### Approach 2 : Creating a Go's plugin system to implement different Translators
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably rename this to "Using Go plugins to implement different Translators"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated


For example the event structure is different for various events produced by Gerrit and an example struct of Gerrit project created event as below,

### Approach 3 : Creating Go Plugin System over RPC(gRPC) using HashiCorp's go-plugin
Copy link
Contributor

Choose a reason for hiding this comment

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

"Using RPC to add new Translators"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated



type GerritTranslator struct {
//Fields for Gerrit event Translator
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: // [.]+

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//Fields for Gerrit event Translator
// Fields for Gerrit event Translator


### Approach 3 : Creating Go Plugin System over RPC(gRPC) using HashiCorp's go-plugin

HashiCorp's [`go-plugin`](https://github.com/hashicorp/go-plugin) library simplifies the implementation of a plugin system in Go, it is a Go (golang) plugin system over RPC created by HashiCorp.</br>
Copy link
Contributor

Choose a reason for hiding this comment

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

plugin system in Go. It is a

Expose the functionality of Go translator plugins as an HTTP/REST API, if this needs be used from other languages.
- This structure can be extended by adding more translator plugins in the future without having to recompile the entire application.
- The plugins can be developed independently and reside in separate repositories.
- But the Go plugin system is currently only supported on Unix-like systems and has some limitations, such as the need to compile everything with the same Go version.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove the initial "But"

@rjalander
Copy link
Contributor Author

rjalander commented Feb 1, 2024

This looks much better @rjalander! One thing I noticed missing was a final "Conclusions" to summarize which was preferred by you, etc. Or did you want to leave that up for discussion?

Thank you @xibz for reviewing this PR,

Yes I think we can discuss in CDEvents Working Group meeting and reach a conclusion to select the most suitable one

@rjalander rjalander changed the title RFC : CDEvents-translator initial design review RFC : CDEvents-translator design review Feb 1, 2024
@rjalander rjalander requested a review from xibz February 1, 2024 16:50
@e-backmark-ericsson
Copy link
Contributor

Some general comments on this RFC:

  • A basic principle in CDEvents should be that the events are sent by their source itself, or as close to that source as possible. I understand that it will be challenging to get all tools (SCM tools in this case mostly) to adapt sending CDEvents, so we might need something to fill that gap. At least shor/mid-term. It would be good to see some statement about that in the RFC.
  • The RFC seems to propose a one-directional translation only, from XYZ to CDEvents. Are there ideas on translating events the other way around as well? I believe it would be a valid limitation to only support one-way translation, and thus that can be clearly stated in the introduction to the RFC. Translating from CDEvents to XYZ could require a much more complex set up, depending on what downstream systems/tools to support.
  • Could/should we limit what interface protocols this translator would support towards the SCM (or other) systems? Most (all?) systems support webhooks, so maybe we should limit to that? Gerrit also supports their own 'stream-events' over ssh (and also Kafka through a plugin), but I don't think we need to support that as the webhooks support is there..
  • I'd like to see a clearer scope of the intended solution. 99% of it talks about SCM related events. Could/should we limit this service to only manage SCM events, or should it be kept open for other types of CDEvents as well?
  • Based on my reflections above, I'm not sure about the term 'cdevents-translator' and 'translations' here. I believe the service should have a name that reflect better the intended scope of it. Some suggestions: 'scm_event_producer', 'scm_adapter', 'any_to_cdevents_adapter', 'webhook_cdevents_producer'
  • It will be easier to grasp the proposal if a simple picture was included, showing where services are deployed and their interfaces to the SCM system(s) and event brokers etc.
  • A consumer of these events will eventually want to provide feedback on the source change in the SCM system, so it would be great to see that included in use cases and in a schematic picture of this proposal. I don't expect this service itself to manage that feedback, or is that considered as an option as well?

Bottom line: I propose that this initiative is limited to manage SCM related events only, and that it is one-directional. The name should preferably in some way reflect that.

rfc/cdevents-translator.md Outdated Show resolved Hide resolved
rfc/cdevents-translator.md Outdated Show resolved Hide resolved
@rjalander
Copy link
Contributor Author

Some general comments on this RFC:

  • A basic principle in CDEvents should be that the events are sent by their source itself, or as close to that source as possible. I understand that it will be challenging to get all tools (SCM tools in this case mostly) to adapt sending CDEvents, so we might need something to fill that gap. At least shor/mid-term. It would be good to see some statement about that in the RFC.
  • The RFC seems to propose a one-directional translation only, from XYZ to CDEvents. Are there ideas on translating events the other way around as well? I believe it would be a valid limitation to only support one-way translation, and thus that can be clearly stated in the introduction to the RFC. Translating from CDEvents to XYZ could require a much more complex set up, depending on what downstream systems/tools to support.
  • Could/should we limit what interface protocols this translator would support towards the SCM (or other) systems? Most (all?) systems support webhooks, so maybe we should limit to that? Gerrit also supports their own 'stream-events' over ssh (and also Kafka through a plugin), but I don't think we need to support that as the webhooks support is there..
  • I'd like to see a clearer scope of the intended solution. 99% of it talks about SCM related events. Could/should we limit this service to only manage SCM events, or should it be kept open for other types of CDEvents as well?
  • Based on my reflections above, I'm not sure about the term 'cdevents-translator' and 'translations' here. I believe the service should have a name that reflect better the intended scope of it. Some suggestions: 'scm_event_producer', 'scm_adapter', 'any_to_cdevents_adapter', 'webhook_cdevents_producer'
  • It will be easier to grasp the proposal if a simple picture was included, showing where services are deployed and their interfaces to the SCM system(s) and event brokers etc.
  • A consumer of these events will eventually want to provide feedback on the source change in the SCM system, so it would be great to see that included in use cases and in a schematic picture of this proposal. I don't expect this service itself to manage that feedback, or is that considered as an option as well?

Bottom line: I propose that this initiative is limited to manage SCM related events only, and that it is one-directional. The name should preferably in some way reflect that.

@e-backmark-ericsson Thank you very much for your comments,

  • Updated the design including the first 4 comments as part of Goals, Non-Goals and Motivation and Rationale
  • And about the name change we discussed in the CDEvents Workgroup meeting yesterday, is that fine to change as webhook_cdevents_translator or webhook_cdevents_adapter, please comment.
  • Will try to add a picture for this proposal as suggested
  • I think a feedback from the consumer will be provided back to the message-broker with an another CDEvent, but the event will not be translated/send to SCM system, as stated above this translator supports one-way translation.

Jalander Ramagiri and others added 10 commits February 13, 2024 12:39
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Co-authored-by: xibz <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Co-authored-by: xibz <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
@rjalander rjalander force-pushed the rfc_cdevents_translator branch from 75f28db to ffb63fd Compare February 13, 2024 12:39
@rjalander rjalander requested a review from xibz February 13, 2024 12:40
Copy link
Contributor

@e-backmark-ericsson e-backmark-ericsson left a comment

Choose a reason for hiding this comment

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

To me it makes sense to rename this proposed implementation to webhook_cdevents_adapter. A translator to me implies that there would be a one-to-one translation, but that might not always be the case I think.

rfc/cdevents-translator.md Outdated Show resolved Hide resolved
@rjalander
Copy link
Contributor Author

@e-backmark-ericsson @afrittoli @xibz Thank you all for reviewing and providing your comments.
Please approve this RFC If no other comments.

Copy link
Contributor

@e-backmark-ericsson e-backmark-ericsson left a comment

Choose a reason for hiding this comment

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

I don't have a valid opinion on whether alternative 3 or any of the other are preferred but I'd say go ahead to this and if needed we could always make a different attempt later.
The proposal has some inconsistencies in the naming between 'adapter' and 'translator', but we could sort those out during the actual PR review later. I assume that based on this RFC we will create a repo under the cdevents org called 'webhook_cdevents_adapter'.

@rjalander
Copy link
Contributor Author

Yes I requested @afrittoli to create project under cdevents org with the name "webhook-cdevents-adapter" (replaced _ with -), just to follow other projects naming conventions under cdevents org

And about using translator, referring plugin implementation projects for various SCM tools as <scm_tool_name>-translator-cdevents(can be a separate project under different org.)

Ex: gerrit-translator-cdevents and the interface name EventTranslator.TranslateEvent() to be implemented.

Please suggest, If I can rename this too with gerrit-adaptor-cdevents and the interface name EventAdaptor.TranslateEvent() to implement ?

@rjalander rjalander changed the title RFC : CDEvents-translator design review RFC : CDEvents Webhook Adapter design review Feb 26, 2024
Signed-off-by: Jalander Ramagiri <[email protected]>
@rjalander
Copy link
Contributor Author

rjalander commented Mar 12, 2024

Yes I requested @afrittoli to create project under cdevents org with the name "webhook-cdevents-adapter" (replaced _ with -), just to follow other projects naming conventions under cdevents org

And about using translator, referring plugin implementation projects for various SCM tools as <scm_tool_name>-translator-cdevents(can be a separate project under different org.)

Ex: gerrit-translator-cdevents and the interface name EventTranslator.TranslateEvent() to be implemented.

Please suggest, If I can rename this too with gerrit-adaptor-cdevents and the interface name EventAdaptor.TranslateEvent() to implement ?

As discussed in one of the SIG event meets, keeping the plugins name with translator word and using adapter for CDEvents webhook.

@rjalander
Copy link
Contributor Author

@afrittoli @xibz can you please re-review and approve If no other comments with this RFC.

Copy link
Contributor

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

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

Thanks @rjalander - lgtm!
Commits need to squashed - we can do a squash and merge too.

rfc/cdevents-translator.md Show resolved Hide resolved
@rjalander
Copy link
Contributor Author

Can we merge this PR If no other comments. Thank you.

@afrittoli afrittoli merged commit 2bfea15 into cdevents:main Mar 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants