Skip to content

πŸš€ OpenWhisk Provider Support πŸš€ - #1700

Closed
jthomas wants to merge 35 commits into
serverless:v1.0from
jthomas:v1.0-openwhisk
Closed

jthomas wants to merge 35 commits into
serverless:v1.0from
jthomas:v1.0-openwhisk

Conversation

@jthomas

@jthomas jthomas commented Jul 28, 2016

Copy link
Copy Markdown
Contributor
Status:

Ready 😎

Description:

This PR provides the provider implementation for the OpenWhisk platform. I've implemented the entire suite of plugins for create, deploy, invoke and remove, with full unit test coverage and documentation. See the lib/plugins/openwhisk directory for the source code.

I have tested this implementation against the OpenWhisk platform deployed on IBM Bluemix.

There are a number of design issues to discuss based on my implementation, due to the differences between the Lambda and OpenWhisk platforms. I'll write up my notes tomorrow and add them to this PR to get feedback from the serverless team.

Enjoy!

James Thomas added 30 commits June 30, 2016 17:30
@pmuens

pmuens commented Jul 28, 2016

Copy link
Copy Markdown
Contributor

Awesome! Thank you very much @jthomas !!! 🎯 πŸŽ‰

@eahefnawy

Copy link
Copy Markdown
Contributor

That's awesome @jthomas!!!! πŸ’₯ πŸ’₯ πŸ’₯

@austencollins

Copy link
Copy Markdown
Member

OOOOOOOOOOOOMG!!! @jthomas you are the man!!!!

@jthomas

jthomas commented Jul 29, 2016

Copy link
Copy Markdown
Contributor Author

Implementing OpenWhisk support for Serverless was mostly painless. Go Serverless!

Documentation for the project was excellent. It was a huge benefit to also have the Azure implementation to review to help me understand how it should work. Working on this part-time, it took me a week to have deploy working, another two weeks to fill out the remaining plugins and another few weeks tidying up. OpenWhisk's NPM module handles all heavy lifting with the API.

There were a few challenges to map the Amazon Lambda programming model to the OpenWhisk platform. Here's a list of the main issues I encountered...

Regions vs Endpoints

Serverless supports deploying to different availability zones through regions identifiers.

OpenWhisk developers control the platform instance they are deploying through by changing the platform endpoint.

Currently, I'm not using the region parameter to control the deployment location. The platform endpoint is pulled from a user configuration file in the user's home directory, also used by the OpenWhisk CLI, or can be set manually using environment variables (OW_API, OW_AUTH).

IBM Bluemix supports multiple regions but OW is only deployed in US-South whilst it is in beta. Developers using Serverless with OpenWhisk may be using IBM Bluemix or to a private instance they have deployed.

When OpenWhisk is rolled out to other regions in IBM's cloud platform, I'm wondering how to support regions without coupling OpenWhisk support in Serverless with IBM Bluemix.

We would like Serverless users to be able to seamlessly use and transition between any OpenWhisk instance.

One option is to support allowing users to define the endpoints for region labels they specify in the configuration.

Events vs Triggers/Rules/Feeds

OpenWhisk has a different event model that Lambda.

Note: Action is the term for function in OpenWhisk.

Users can define Triggers, which are independent to Actions, that are a "named class of events". Using Rules, they bind Actions to these Triggers. Whenever that Trigger is fired, the event will be passed to the Action. Rules can be dynamically created and removed at runtime. Triggers can also be bound to Feeds, which are external event sources. Feeds will invoke the Trigger whenever an external event occurs.

This can be a bit confusing to begin with but this example should help you to understand....

"I want my Action (called myAction) to fire periodically, say every eight seconds"

  • Create a new trigger which is bound to the alarm feed.

$ wsk trigger create periodic --feed /whisk.system/alarms/alarm --param cron '*/8 * * * * *' --param trigger_payload '{"name":"Odin","place":"Asgard"}'

  • Create a rule which binds that Trigger to the Action.

$ wsk rule create --enable myRule periodic myAction

Both Actions, Triggers and Feeds can be called with parameters.

Mapping this model to the current event parameters in the YAML file wasn't obvious.

I decided to use the events parameter for functions to create Rules, mapping Actions to Triggers. Triggers are defined in the Resources section, being independent of Actions.

Here's the alarm example translated into the Serverless YAML definition.

functions:
  myAction:
    handler: handler.main
    events:
      - myRule: periodic
resources:
    triggers:
        periodic:
            feed: /whisk.system/alarms/alarm
            feed_parameters:
                cron: '*/8 * * * * *'

@pmuens

pmuens commented Jul 30, 2016

Copy link
Copy Markdown
Contributor

Hey @jthomas thanks for the really detailed writeup!
This helps enormously to work on our multi provider architecture for Serverless!

Really valuable feedback! πŸ‘ πŸ‘ πŸ‘

@eahefnawy

eahefnawy commented Aug 1, 2016 •

Copy link
Copy Markdown
Contributor

Thanks for the detailed explanation @jthomas ☺️ ... We're going to settle on common naming schemes that should work for all providers. We just wanna abstract as much as possible from all the implementation details and become a cross provider framework Serverless applications.

One question, you mentioned that you're using the resources property for triggers. Does that mean those triggers are handled by an IBM Resource Manager (equivalent to AWS CloudFormation)? Because that's what this resources property was made for. Otherwise I'd try to just abstract all these "inputs" into the events object.

Great work! and thanks a lot for this! πŸ‘

@jthomas

jthomas commented Aug 2, 2016

Copy link
Copy Markdown
Contributor Author

Triggers are deployed through the OpenWhisk API, not through a IBM "Cloud Formation" equivalent. I was using the Resources section mostly out of convenience!
Triggers are independent from Actions, multiple Actions can be bound to the same Trigger. I needed somewhere independent from one Action's "event" parameter to define them but random YAML paramters are not parsed in the service object.

@eahefnawy

Copy link
Copy Markdown
Contributor

@jthomas that's a common use case. That's why we recently turned the provider property in serverless.yml into an object where you can save global configs. I think this is the best fit location for triggers based on my current understanding.

@jthomas

jthomas commented Aug 8, 2016

Copy link
Copy Markdown
Contributor Author

I have a question for the Serverless team on usability and default values....

When we deploy a service function, using the API, the attribute overwrite controls whether it should replace existing functions with the same identifier. This defaults to false in the API. I'm using the default value at the moment.

From a user experience perspective, it would be much better to default to true. Users deploying updates don't have to manually set this value in the manifest. The downside with this approach is that they might overwrite an existing service accidentally.

What's the framework's position on issues like this?

I'd prefer to improve the usability. I've already had a user run into this issue.
If no-one has an issue, I'll make the small change to do this.

@eahefnawy

Copy link
Copy Markdown
Contributor

the attribute overwrite controls whether it should replace existing functions with the same identifier.

So if other functions in other service don't have this same identifier, it won't overwrite an existing service? If so imo we should strive to make unique identifiers for all functions/services to avoid that "accident" while offering the best UX.

@flomotlik @pmuens any further thoughts on this?

@pmuens

pmuens commented Aug 9, 2016

Copy link
Copy Markdown
Contributor

I would vote (and expect) to always replace the function so that the deployment always reflects the current state on the developers machine.

Right now the AWS implementation will also always upload the functions code (even if it's not changed).

@flomotlik flomotlik closed this Aug 12, 2016
@flomotlik

Copy link
Copy Markdown
Contributor

@jthomas could you reopen the PR against master? It was closed because I removed the V1.0 branch

@jthomas

jthomas commented Aug 15, 2016

Copy link
Copy Markdown
Contributor Author

I've made a small change to default the "overwrite" parameter to true for Actions, Triggers and Rules.

#1858 has been opened against master.

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

Successfully merging this pull request may close these issues.

5 participants