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

feat: Template executor plugins. Fixes #5201 #7256

Merged
merged 4 commits into from
Jan 22, 2022
Merged

Conversation

alexec
Copy link
Contributor

@alexec alexec commented Nov 20, 2021

Signed-off-by: Alex Collins alex_collins@intuit.com
Fixes #5201

Don't bother creating a PR until you've done this:

  • Run make pre-commit -B to fix codegen, lint, and commit message problems.

Create your PR as a draft.

  • Your PR needs to pass the required checks before it can be approved. If the check is not required (e.g. E2E tests) it
    does not need to pass.
  • Once required tests have passed, you can make it "Ready for review".
  • Say how how you tested your changes. If you changed the UI, attach screenshots.

Tips:

  • If changes were requested, and you've made them, then dismiss the review to get it looked at again.
  • Add you organization to USERS.md if you like.
  • You can ask for help!

@alexec alexec closed this Nov 22, 2021
@alexec alexec reopened this Nov 24, 2021
docs/plugins.md Outdated Show resolved Hide resolved
@alexec alexec marked this pull request as ready for review December 1, 2021 18:01
@alexec
Copy link
Contributor Author

alexec commented Dec 1, 2021

I have added many reviewers. This is a fundamental change to how we do templates and I want it to get thorough scrutiny.

docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Show resolved Hide resolved
util/errors/errors.go Show resolved Hide resolved
workflow/controller/controller.go Outdated Show resolved Hide resolved
workflow/controller/controller.go Show resolved Hide resolved
workflow/util/plugins/plugin.go Outdated Show resolved Hide resolved
@terrytangyuan
Copy link
Member

terrytangyuan commented Dec 1, 2021

Also added some small comments in https://docs.google.com/document/d/1ul_5iGPGOSo7hkRMyh5YGh2X-WcA5ms3REjmK-TSsqY/edit#. Thought it might be helpful to add the link here for others to chime in as well.

cmd/argo/commands/get.go Outdated Show resolved Hide resolved
cmd/argo/commands/plugin/io.go Outdated Show resolved Hide resolved
cmd/workflow-controller/main.go Outdated Show resolved Hide resolved
docs/executor_plugins.md Outdated Show resolved Hide resolved
docs/executor_plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/workflow_types.go Outdated Show resolved Hide resolved
Kind: cm.Labels[common.LabelKeyConfigMapType],
},
ObjectMeta: metav1.ObjectMeta{
Name: strings.TrimSuffix(cm.Name, "-executor-plugin"),
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to apply any validation to the name?

docs/plugins.md Outdated Show resolved Hide resolved
cmd/argo/commands/plugin/io.go Outdated Show resolved Hide resolved
cmd/argo/commands/plugin/io.go Outdated Show resolved Hide resolved
Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

Quick first-pass. This is incredibly exciting!

docs/executor_plugins.md Show resolved Hide resolved
docs/executor_plugins.md Show resolved Hide resolved
docs/executor_plugins.md Show resolved Hide resolved
plugins/executor/hello/README.md Show resolved Hide resolved
workflow/executor/agent.go Show resolved Hide resolved
@crenshaw-dev
Copy link
Member

@alexec I see some features will be deferred to a v2. Is there anything that should be done in this PR to support versioning? A couple things that come to mind:

  1. adding a version field to the plugin.yaml spec
  2. adding warnings in documentation that this is an early feature and that it might change significantly

I also just realized that minimum-version notes should be added once we know what release this will be in.

@alexec
Copy link
Contributor Author

alexec commented Dec 7, 2021

Ready for review again.

@alexec
Copy link
Contributor Author

alexec commented Dec 7, 2021

adding a version field to the plugin.yaml spec

This would be apiVersion: argoproj.io/v1alpha1.

adding warnings in documentation that this is an early feature and that it might change significantly

I don't expect we'd change the spec. But maybe refine it.

@crenshaw-dev
Copy link
Member

This would be apiVersion: argoproj.io/v1alpha1.

lol of course, I should read files. 😆

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Just a very small number of grammar-type comments.

cmd/argo/commands/plugin/build.go Outdated Show resolved Hide resolved
cmd/argo/commands/plugin/io.go Outdated Show resolved Hide resolved
docs/executor_plugins.md Outdated Show resolved Hide resolved
docs/executor_plugins.md Outdated Show resolved Hide resolved
docs/executor_plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/plugins.md Outdated Show resolved Hide resolved
docs/cli/argo_plugin.md Outdated Show resolved Hide resolved
@alexec
Copy link
Contributor Author

alexec commented Dec 7, 2021

@crenshaw-dev you got me thinking. I'm not sure we should ExecutorPlugin and ControllerPlugin, or if we should have just Plugin, with something in the spec that determines what to run.

@crenshaw-dev
Copy link
Member

@alexec faaaaiirr.... I guess it depends on how much we think the specs might diverge. I guess we could take the strategy of nesting them. e.g.

kind: ArgoWorkflowPlugin # or whatever
spec:
  executor: {}
  controller: {}

Or something like that.

I don't have a strong feeling, besides I do believe that different plugin types should be independently enabled for better security.

@alexec
Copy link
Contributor Author

alexec commented Dec 7, 2021

Some more thoughts:

  • Users cannot install controller plugins. Architecture does not allow it.
  • Some use cases might require both executor and controller parts (thought nothing comes to mind now).

Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

Second pass

cmd/argo/commands/executorplugin/root.go Show resolved Hide resolved
cmd/argoexec/commands/agent.go Show resolved Hide resolved
docs/executor_plugins.md Outdated Show resolved Hide resolved
docs/executor_plugins.md Show resolved Hide resolved
docs/executor_plugins.md Show resolved Hide resolved
docs/executor_plugins.md Show resolved Hide resolved
pkg/apis/workflow/v1alpha1/object_types.go Show resolved Hide resolved
templates:
- name: main
plugin:
hello: { }
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be more powerful to show a plugin with a non-empty schema as an example. Maybe argosay instead of hello-world where you return the input?

plugins/executor/slack/plugin.yaml Show resolved Hide resolved
workflow/executor/agent.go Show resolved Hide resolved
@alexec
Copy link
Contributor Author

alexec commented Dec 14, 2021

@simster7 @crenshaw-dev good enough?

@sarabala1979 sarabala1979 self-assigned this Dec 14, 2021
@alexec alexec enabled auto-merge (squash) December 14, 2021 21:08
@alexec alexec changed the title feat: Executor plugins. feat: Template executor plugins. Dec 14, 2021
@kjagiello
Copy link

kjagiello commented Dec 21, 2021

Update: Nevermind me. I gave it another try and realized that the ouput parameter name provided by the plugin mismatched the parameter name in the workflow. Once it got fixed, I was able to pass the data between plugin invocations.


I'm a bit curious if it is possible to access the output parameters provided by a plugin? Consider a scenario where I'd like to pass some data between invocations of a plugin. In my case I'd like to, using a plugin, create a Slack message at the beginning of a workflow and be able to update the message from subsequent steps (in order to avoid clutter in the Slack channel). I could probably store the Slack message ID in the memory of my plugin instance, but I thought I'd be neat to keep the plugin stateless and be able to control which message(s) one wants to update. See the example workflow below.

Workflow

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: notifications-test-
spec:
  entrypoint: main
  templates:
    - name: main
      steps:
        - - name: pre-notification
            template: notification
            arguments:
              parameters:
                - name: message
                  value: "{{workflow.name}} started"

        # ...

        - - name: post-notification
            template: notification
            arguments:
              parameters:
                - name: thread-id
                  value: "{{workflow.outputs.parameters.slack-thread-id}}"
                - name: message
                  value: "{{workflow.name}} succeeded"

    - name: notification
      inputs:
        parameters:
          - name: thread-id
            value: ""
          - name: message
      plugin:
        slack:
          message: "{{inputs.parameters.message}}"
          thread_id: "{{inputs.parameters.thread-id}}"
      outputs:
        parameters:
          # A placeholder output parameter to keep the workflow validation happy
          - name: thread-id
            globalName: slack-thread-id
            value: ""

@crenshaw-dev gave me an idea that I could populate the output parameters through the response from my plugin, so I tried the following:

Plugin response:

{
    "node": {
        "phase": "Succeeded",
        "message": "Slack message sent",
        "outputs": {
            "parameters": [
                {
                    "name": "thread-id",
                    "globalName": "slack-thread-id",
                    "value": "7331"
                }
            ]
        }
    }
}

The result I'm seeing is however that {{workflow.outputs.parameters.slack-thread-id}}} never gets rendered.

notifications-test-2xwx9 succeeded (thread id: {{workflow.outputs.parameters.slack-thread-id}})

I've tried {{steps.pre-notification.outputs.parameters.thread-id}} as well, but it did not render either.

Reading through the changeset I see that this is not something that seems to be officially supported (i.e. don't see any tests for it), so I wonder if this is a use-case that you might want to support in the future?

@alexec
Copy link
Contributor Author

alexec commented Jan 18, 2022

@kjagiello you should be able to use output parameters. I wonder if your JSON should be this:

{
    "node": {
        "phase": "Succeeded",
        "message": "Slack message sent",
        "outputs": {
            "parameters": [
                {
                    "name": "slack-thread-id",
                    "value": "7331"
                }
            ]
        }
    }
}

Signed-off-by: Alex Collins <alex_collins@intuit.com>
@alexec alexec changed the title feat: Template executor plugins. feat: Template executor plugins. Fixes #5201 Jan 19, 2022
@alexec alexec mentioned this pull request Jan 19, 2022
28 tasks
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
Signed-off-by: Alex Collins <alex_collins@intuit.com>
plugin "github.com/argoproj/argo-workflows/v3/workflow/util/plugins"
)

func NewBuildCommand() *cobra.Command {
Copy link
Member

Choose a reason for hiding this comment

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

will this command work for all languages like java, go, etc?

@alexec
Copy link
Contributor Author

alexec commented Jan 21, 2022

will this command work for all languages like java, go, etc?

Yes. Thought for complied languages, you'll need to build the image with your complied source code.

@sarabala1979
Copy link
Member

sarabala1979 commented Jan 21, 2022

@alexec If have multiple plugins and all are used in the same workflow, how the Agent pod resource will be configured
How the below scenario is handled:

  1. if one of the plugin containers is not ready but the agent container start processing (I believe step fail with 404)
  2. if both plugins configured same port, do we have validation

@alexec
Copy link
Contributor Author

alexec commented Jan 22, 2022

if one of the plugin containers is not ready but the agent container start processing (I believe step fail with 404)

No. It be retried. This is a common case.

if both plugins configured same port, do we have validation

No validation. I'm not sure the pod will schedule. I will test.

Copy link
Member

@sarabala1979 sarabala1979 left a comment

Choose a reason for hiding this comment

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

Most code review was done by others. We need to detailed doc or video to understand plug-in development. you can add it later. Please test all corner cases.

@alexec alexec merged commit 774bf47 into argoproj:master Jan 22, 2022
@alexec alexec deleted the eplug branch May 3, 2022 20:31
@agilgur5 agilgur5 added the area/agent Argo Agent that runs for HTTP and Plugin templates label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/agent Argo Agent that runs for HTTP and Plugin templates area/executor area/plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin Template
8 participants