Whisk Deploy — How to Sync OpenWhisk Projects between Client and Server?

Priti Desai
Dec 12, 2017 · 3 min read

The answer is running Whisk Deploy in managed deployment mode.

Whisk Deploy in managed deployment mode, deploys all Apache OpenWhisk entities from the manifest file and attaches a hidden annotation called managed to all entities from that manifest file. managed annotation contains following keys:

managed:
__OW_PROJECT_NAME: MyProjectName
__OW_PROJECT_HASH: SHA1("OpenWhisk " + <size_of_manifest_file> + "\0" + <contents_of_manifest_file>)
__OW_FILE: Absolute path of manifest file on file system

Where the text “OpenWhisk” is a constant prefix and “\0” is the NULL character. The <size_of_manifest_file> and <contents_of_manifest_file> vary depending on the file.

Now, subsequent deployments of the same project in managed deployment mode, calculates a new __OW_PROJECT_HASH on client and compares it with the __OW_PROJECT_HASHof each entity on the OpenWhisk server in that project.

Scenario 1: If __OW_PROJECT_HASH on client is same as __OW_PROJECT_HASH on the server i.e. there were no changes in the project on the client side, the project on server side is left as is except wskdeploy redeploys all the entities from manifest file to capture any changes in deployment file.

Scenario 2: If __OW_PROJECT_HASH on client is different from__OW_PROJECT_HASH on the server i.e. there were some changes in the project on the client side, wskdeploy redeploys all the entities from the manifest file on the client and updates their __OW_PROJECT_HASHon the server. wskdeploy also searches all the entities including actions, sequences, and triggers which has the same __OW_PROJECT_NAME i.e. it belonged to the same project but has different__OW_PROJECT_HASH i.e. its been deleted from the manifest file on the client.

Project name in the manifest file is mandatory to sync that project between the client and the server:

project:
name: MyProjectName
packages:
package1:
....

OpenWhisk entities which are deployed using some other tool or automation and were part of the same project but has been deleted from that project now, are left unmodified. These kind of entities are classified as external entities and are not overwritten.

Undeployment of such project can be driven by wskdeploy with the manifest file having only project name.

project:
name: MyProjectName

Lets look at a sample project to understand managed deployment. Whisk Deploy GitHub repo has a sample project with many different manifest files to demonstrate managed deployment.

Step 1: Deploy MyFirstManagedProject using managed deployment:

$wskdeploy -m tests/src/integration/managed-deployment/manifest.yaml --managedDeployment completed successfully.

Here is a list of entities deployed on OpenWhisk Server:

List of OpenWhisk entities in MyFirstManagedProject
Managed Annotation

Step 2: Sync Client and Server — Deleting ManagedPackage-2

./wskdeploy -m tests/src/integration/managed-deployment/00-manifest-minus-second-package.yaml --managedDeployment completed successfully.

Here is a list of entities deployed on OpenWhisk Server:

List of OpenWhisk entities in MyFirstManagedProject

Step 3: Sync Client and Server — Deleting Sequence ManagedSequence-2

./wskdeploy -m tests/src/integration/managed-deployment/01-manifest-minus-sequence-2.yaml --managedDeployment completed successfully.

Here is a list of entities deployed on OpenWhisk Server:

List of OpenWhisk entities in MyFirstManagedProject

Step 4: Sync Client and Server — Deleting Action Helloworld-3

./wskdeploy -m tests/src/integration/managed-deployment/02-manifest-minus-action-3.yaml --managedDeployment completed successfully.

Here is a list of entities deployed on OpenWhisk Server:

List of OpenWhisk entities in MyFirstManagedProject

Step 5: Sync Client and Server — Deleting ManagedPackage-1

./wskdeploy -m tests/src/integration/managed-deployment/04-manifest-minus-package.yaml --managedDeployment completed successfully.

Here is a list of entities deployed on OpenWhisk Server:

List of OpenWhisk entities in MyFirstManagedProject

Enjoy!

Apache OpenWhisk

Apache OpenWhisk is a serverless cloud platform that…

Priti Desai

Written by

Developer Advocate @IBM. Implements #serverless with @openwhisk, @knative, & @tekton.

Apache OpenWhisk

Apache OpenWhisk is a serverless cloud platform that executes code in response to events

Priti Desai

Written by

Developer Advocate @IBM. Implements #serverless with @openwhisk, @knative, & @tekton.

Apache OpenWhisk

Apache OpenWhisk is a serverless cloud platform that executes code in response to events

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store