Skip to content

Introduce AutoFlow client to send arbitrary events

Timo Furrer requested to merge autoflow/initial into master

What does this MR do and why?

This change set introduces AutoFlow for the first time. The KAS client now implements a method (send_autoflow_event) to send arbitrary cloud events to AutoFlow.

The implementation is behind the autoflow_enabled feature flag. For this to work it's also required to properly setup KAS with AutoFlow, which is also disabled by default.

ToDos

How to test locally

autoflow:
  temporal:
    host_port: localhost:7233
  • Create (or re-use) and GDK project and add the following file at .gitlab/autoflow/main.star:
def handle_test_event(w, ev):
    print("Handling test event: " + str(ev["data"]))
            
on_event(
    type="com.gitlab.events.test_event",
    handler=handle_test_event,
)
  • Enable autoflow_enabled FF: Feature.enabled?(:autoflow_enabled, p) where p is your project where you've added the script above
  • Open gdk rails console and trigger an event like this:
[14] pry(main)> client = Gitlab::Kas::Client.new()
=> #<Gitlab::Kas::Client:0x000000014b27e5b0>
[15] pry(main)> client.send_autoflow_event(project: p, type: 'com.gitlab.events.test_event', id: 'some-id', data: {'some-key': 42})
=> <Gitlab::Agent::AutoFlow::Rpc::CloudEventResponse: >
  • You should see the workflows in the Temporal UI (most likely at http://localhost:8233)
  • You should see AutoFlow logs in the KAS logs, including the print from the AutoFlow script.

Refs gitlab-org/cluster-integration/gitlab-agent#607 (closed)

Edited by Timo Furrer

Merge request reports

Loading