Introduce AutoFlow client to send arbitrary events
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
-
Finish, merge and release Introduce AutoFlow behind FF (gitlab-org/cluster-integration/gitlab-agent!1637 - merged) (including kas-grpc
Ruby gem) -
Upgrade kas-grpc
dependency in this repository (maybe in a separate MR)
How to test locally
- Setup local temporal server (https://learn.temporal.io/getting_started/typescript/dev_environment/), it's just about starting a binary, don't worry
- Configure KAS in GDK to point to that Temporal server. Add this to your
$GDK_ROOT/gitlab-k8s-agent-config.yml
file:
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)
wherep
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