argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
15.13k stars 3.21k forks source link

Plugins #5025

Closed alexec closed 3 years ago

alexec commented 3 years ago

It would be good to have a system of plugins that do the following:

Additionally, the ability for users to create plugis would allow us to grow the ecosystem.

Golang Plugin

Golang provides a plugin system, but it very constrained as to how you build and package them:

This means effectively plugins must be built in the same source code repo.

However, if we provide a way to package your plugin, they are obviously the fastest and most powerful to write plugins.

HashiCorp Go Plugins

Golang provides an RPC library. HashCorp has formalized this into a way to write bi-directional plugins.

References

Tekton Custom Job:

Problems with Golang plugins:

https://www.reddit.com/r/golang/comments/b6h8qq/is_anyone_actually_using_go_plugins/

Bobgy commented 3 years ago

I'd hope plugins can evolve as independently as possible.

Did you ever consider REST/gRPC plugins? It might share some of the issues you mentioned with http templates, but now it's clear they will talk to a single configured trusted server, so some problems like auth and user permissions no longer apply.

alexec commented 3 years ago

Do you mean this?

https://github.com/hashicorp/go-plugin

Bobgy commented 3 years ago

I was only thinking about the problem architecturally and I didn't know hashicorp/go-plugin before. But, that sounds like a great match!

Any packages (including transitive dependencies) outside of the standard library that are used by both the plugin and the program must have their versions match exactly.

(referenced from the reddit link)

The limitation on golang plugin seems unacceptable as a plugin purpose.

EDIT: note, please keep in mind I have limited experience on microservice systems with my own experience. Just talking about my current thoughts and they can be wrong.

alexec commented 3 years ago

More reading material:

alexec commented 3 years ago

Golang Plugin (GP) vs HashiCorp Plugin (HP)

Aside: I think we should consider supporting both.

Build

HP wins by a huge margin.

Performance

GP wins.

Language

I believe that HP can be written in non-go.

HP wins.

Boilerplate

GP wins.

Callback

Callbacks are trivial in GP. Not sure about HP.

GP wins.

Bobgy commented 3 years ago

So, talking about use-cases, it seems GP can be a good fit for first party maintained optional plugins.

alexec commented 3 years ago

I think we can and should build an RPC (or JSON RPC) plugin as a Go plugins.

alexec commented 3 years ago

I'm really happy with my PoC. You can build your plugins as a Golang plugin. One of the Golang plugins will proxy requests via JSON-RPC. You can add a sidecar to the workflow-controller that services the RPC requests, so the deployment of the plugin is trivial.

I think JSON-RPC will work for most use cases, but you can always write a Golang plugin if you want.

alexec commented 3 years ago

https://velero.io/docs/v1.5/overview-plugins/

therealnb commented 3 years ago

Use case: We have X tasks to perform on Y endpoints in Z servers. We would like to use a step for each to take advantage of retry policy, alerting and other workflow goodies. XYZ can be 100s in a big system. Each step is a rest operation and completes quickly.

Problem: If there are no failures most of the time is taken in creating the containers. This can take many minutes to do 100 posts. Further more, the first steps are a pause and the last resume, so the workflow duration is down time for this maintenance task.

Solution: We can combine steps, but we lost the 'workflow goodies'. It would be better if we had a way for quick execution. One of

Ability for a step to run a small python script in another context (workflow-manager, or dedicated). An exec step which runs on a previously created daemon. The main reason not to share containers is collisions in file names. This isn't a problem if we aren't creating temporary files and if we are we can use the pod name to name the files.

Bobgy commented 3 years ago

@therealnb do you think https://github.com/argoproj/argo-workflows/issues/795 work for your use-case?

You can configure steps that send a request to your own server, and your server will be able to do whatever things you want.

A limitation could be that this is not suitable for steps that take some time to execute.

alexec commented 3 years ago

I'm closing this issue in favor for #5201 and #4355 which are more narrowly defined (but would have closely relati impl)

therealnb commented 3 years ago

That's fine. #795 would help in our case.