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

Webhook stage, integrate against anything #1512

Closed
amanya opened this issue Mar 27, 2017 · 13 comments
Closed

Webhook stage, integrate against anything #1512

amanya opened this issue Mar 27, 2017 · 13 comments

Comments

@amanya
Copy link

amanya commented Mar 27, 2017

Create a new stage for calling an external webhook / service, that will be useful for having a flexible way of interacting with technologies that have not yet been integrated with Spinnaker, for example running AWS lambdas or running Marathon deployments.

Description

We'll add a new pipeline stage type that will call a user-defined endpoint, passing to it a json document with fields customized in the stage's ui using pipeline expressions.

When configuring the stage, we will have a checkbox to "wait for results". If it is not checked, the stage will be succeeded if the webhook's status code is 2xx or failed otherwise.

If "wait for results" is checked, Spinnaker will expect a 2xx return code along with a callback url that can be returned in the "Location" header or in the body of the response. This url will be used to get the status of the task we triggered, it will return a JSON like:

{
    "status": "[NOT_STARTED|RUNNING|SUCCEEDED|TERMINAL|...]",
    "info": "Some information about the process"
}

This information will be used to update the status of the execution and give feedback to the user.

To give this the maximum flexibility, there will be a configurable (JSONPath notation perhaps) way of specifying what response element to look at, and what values map to success/failure.

As a next step, it will be nice to have config-driven definitions of external services that would then be presented as choices when using this new stage.

Implementation details

We decided that the best fit for putting this is Orca, because it has similar tasks as the one we want to implement, for example in the bake stage it triggers a task with parameters, waits for it to complete and update the execution accordingly. Also the jenkins and run script stages are good examples of this.

There has been some discussion about this feature before opening this issue in this google document.

@amanya
Copy link
Author

amanya commented Mar 27, 2017

This is a screenshot of the inital works in the stage's configuration view:

image

@robzienert
Copy link
Member

robzienert commented Mar 28, 2017

Looks like great progress; I know it's still in the works, but would like to see the textbox for "Status URL path" to be hidden, and slotted below its label when visible.

jervi pushed a commit to jervi/orca that referenced this issue Mar 30, 2017
jervi pushed a commit to jervi/orca that referenced this issue Mar 30, 2017
jervi pushed a commit to jervi/orca that referenced this issue Mar 30, 2017
jervi pushed a commit to jervi/orca that referenced this issue Mar 30, 2017
@amanya
Copy link
Author

amanya commented Mar 31, 2017

TODO list for next iterations:

  • Define new custom stages based on the webhook stage by configuring them in orca.yml. Those will be selectable in the ui as if they were regular stages.
  • "try it out" button that will show the results of the webhook call next to it so that the json path values could be tested. Similar to to how expresssions evaluate to results.
  • Beautify the payload in the execution view. Limit the number of lines to be shown with an option to show the rest (clamp)
  • Store a log of all calls to the status endpoint and show a link to view it in the same way as the bake log.
  • Pass custom headers to the webhook call

jervi pushed a commit to jervi/orca that referenced this issue Mar 31, 2017
jervi pushed a commit to jervi/orca that referenced this issue Mar 31, 2017
amanya pushed a commit to amanya/deck that referenced this issue Mar 31, 2017
Create a new stage for calling an external webhook / service, that will
be useful for having a flexible way of interacting with technologies
that have not yet been integrated with Spinnaker, for example running
AWS lambdas or running Marathon deployments.
amanya pushed a commit to amanya/deck that referenced this issue Mar 31, 2017
Create a new stage for calling an external webhook / service, that will
be useful for having a flexible way of interacting with technologies
that have not yet been integrated with Spinnaker, for example running
AWS lambdas or running Marathon deployments.
amanya pushed a commit to amanya/deck that referenced this issue Mar 31, 2017
Create a new stage for calling an external webhook / service, that will
be useful for having a flexible way of interacting with technologies
that have not yet been integrated with Spinnaker, for example running
AWS lambdas or running Marathon deployments.
amanya pushed a commit to amanya/deck that referenced this issue Mar 31, 2017
Create a new stage for calling an external webhook / service, that will
be useful for having a flexible way of interacting with technologies
that have not yet been integrated with Spinnaker, for example running
AWS lambdas or running Marathon deployments.
jervi pushed a commit to jervi/orca that referenced this issue Mar 31, 2017
This PR is first implementation of the webhook stage discussed in issue spinnaker/spinnaker#1512.
Corresponds with Deck PR spinnaker/deck#3447
@robzienert
Copy link
Member

robzienert commented Apr 1, 2017 via email

jervi pushed a commit to jervi/orca that referenced this issue Apr 4, 2017
This PR is first implementation of the webhook stage discussed in issue spinnaker/spinnaker#1512.
Corresponds with Deck PR spinnaker/deck#3447
jervi pushed a commit to jervi/orca that referenced this issue Apr 5, 2017
This PR is first implementation of the webhook stage discussed in issue spinnaker/spinnaker#1512.
Corresponds with Deck PR spinnaker/deck#3447
jervi pushed a commit to jervi/orca that referenced this issue Apr 6, 2017
This PR is first implementation of the webhook stage discussed in issue spinnaker/spinnaker#1512.
Corresponds with Deck PR spinnaker/deck#3447
robzienert pushed a commit to spinnaker/orca that referenced this issue Apr 6, 2017
This PR is first implementation of the webhook stage discussed in issue spinnaker/spinnaker#1512.
Corresponds with Deck PR spinnaker/deck#3447
amanya pushed a commit to amanya/deck that referenced this issue Apr 7, 2017
Create a new stage for calling an external webhook / service, that will
be useful for having a flexible way of interacting with technologies
that have not yet been integrated with Spinnaker, for example running
AWS lambdas or running Marathon deployments.
amanya pushed a commit to amanya/deck that referenced this issue Apr 7, 2017
Create a new stage for calling an external webhook / service, that will
be useful for having a flexible way of interacting with technologies
that have not yet been integrated with Spinnaker, for example running
AWS lambdas or running Marathon deployments.
@Nagarajj
Copy link

This would be helpful, would there be a way to pass headers to the web service url. It seems to assume no headers to be present.

@service
class WebhookService {

@Autowired
RestTemplate restTemplate

ResponseEntity exchange(HttpMethod httpMethod, String url, Object payload) {
HttpEntity payloadEntity = new HttpEntity<>(payload)
return restTemplate.exchange(url, httpMethod, payloadEntity, Object)
}

ResponseEntity getStatus(String url) {
return restTemplate.getForEntity(url, Object)
}
}

@amanya
Copy link
Author

amanya commented Apr 13, 2017

@Nagarajj this is a feature other people requested, we'll probably implement it soon :)

nzthiago pushed a commit to microsoft/deck that referenced this issue Apr 17, 2017
Create a new stage for calling an external webhook / service, that will
be useful for having a flexible way of interacting with technologies
that have not yet been integrated with Spinnaker, for example running
AWS lambdas or running Marathon deployments.
Nagarajj pushed a commit to Nagarajj/deck that referenced this issue Apr 27, 2017
…r#1512

Add headers to webservice calls made as part of web hook stage
Also fix issue with "statusUrlResolution" not being initialized by default
Nagarajj pushed a commit to Nagarajj/orca that referenced this issue Apr 27, 2017
…pinnaker#1512

Adds headers support to the web hook stage core
Also, adds support for collection with single element resulting from jsonPath expression returning list in response.
Corresponds to deck PR spinnaker/deck#3596
@Nagarajj
Copy link

Nagarajj commented Apr 27, 2017

@amanya I have made changes to addHeaders to WebService requests. Have submitted a PR, please see if that makes sense.

  1. Headers are added to both the webService calls. Headers could be things such as "Authorization" headers for authentication (required by both "execute" and "getStatus" requests).
  2. Added support for JSONPath returning list response such as selecting last element in array "$.[-1:].status" or find running element in response "$.[?(@.status == "RUNNING")].status"
  3. Fixed a minor existing UI bug where default "statusUrlResolution" of "getMethod" was not set as it was not initialized.

Below is the screenshot of change
webhook-headers

@amanya
Copy link
Author

amanya commented Apr 27, 2017

@Nagarajj Ups, we already did something very similar: spinnaker/deck#3590

Would you wait for our PR to be merged and then add your changes in a new one? Or do you think it's worth updating ours? Your code seems much simpler but I can't look at in in depth right now.

@Nagarajj
Copy link

@amanya sure, will wait for your PR to be merged. One Q ? will the headers support both "execute" and "getStatus" webservice calls. Would be helpful if it supports both. Rest of the issues are simpler and will raise a seperate PR for those. Thanks.

@amanya
Copy link
Author

amanya commented Apr 28, 2017

@Nagarajj No, we only implemented for the execute call, feel free to add it for the getStatus as well, good idea!

@Nagarajj
Copy link

@amanya, should we share the headers across both the calls or provide ability to define separate headers for the getStatus call.

The use case we are trying to solve for, ability to define "Authorization" header which is required for both execute and getStatus call. Not sure of an use case where a separate set of headers would be required across execute and getStatus.

Let know your thoughts and i will get going on thins.

@erran
Copy link

erran commented Jul 18, 2017

Is this issue still on going after the Webhook stage and predefined webhook stages after spinnaker/orca#1329?

@amanya
Copy link
Author

amanya commented Jul 21, 2017

@erran no, I think we can close it, thanks for the heads up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants