Add __OW_ACTION_VERSION in action metadata (#4761)
diff --git a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerProxy.scala b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerProxy.scala
index 8010940..924a5f7 100644
--- a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerProxy.scala
+++ b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/ContainerProxy.scala
@@ -562,6 +562,7 @@
val environment = Map(
"namespace" -> job.msg.user.namespace.name.toJson,
"action_name" -> job.msg.action.qualifiedNameWithLeadingSlash.toJson,
+ "action_version" -> job.msg.action.version.toJson,
"activation_id" -> job.msg.activationId.toString.toJson,
"transaction_id" -> job.msg.transid.id.toJson)
diff --git a/core/standalone/README.md b/core/standalone/README.md
index d7d7456..4149508 100644
--- a/core/standalone/README.md
+++ b/core/standalone/README.md
@@ -370,6 +370,7 @@
"PWD": "/nodejsAction",
"YARN_VERSION": "1.13.0",
"__OW_ACTION_NAME": "/guest/hello",
+ "__OW_ACTION_VERSION": "0.0.1",
"__OW_ACTIVATION_ID": "71e48d2d62e142eca48d2d62e192ec2d",
"__OW_API_HOST": "http://host.docker.internal:3233",
"__OW_DEADLINE": "1570223213407",
diff --git a/docs/actions-new.md b/docs/actions-new.md
index 7a72324..918f038 100644
--- a/docs/actions-new.md
+++ b/docs/actions-new.md
@@ -160,6 +160,7 @@
* `__OW_API_KEY` the API key for the subject invoking the action, this key may be a restricted API key. This property is absent unless explicitly [requested](./annotations.md#annotations-for-all-actions).
* `__OW_NAMESPACE` the namespace for the _activation_ (this may not be the same as the namespace for the action).
* `__OW_ACTION_NAME` the fully qualified name of the running action.
+ * `__OW_ACTION_VERSION` the internal version number of the running action.
* `__OW_ACTIVATION_ID` the activation id for this running action instance.
* `__OW_DEADLINE` the approximate time when this initializer will have consumed its entire duration quota (measured in epoch milliseconds).
diff --git a/docs/actions.md b/docs/actions.md
index c887e77..d045139 100644
--- a/docs/actions.md
+++ b/docs/actions.md
@@ -670,5 +670,6 @@
* `__OW_API_KEY` the API key for the subject invoking the action, this key may be a restricted API key. This property is absent unless explicitly [requested](./annotations.md#annotations-for-all-actions).
* `__OW_NAMESPACE` the namespace for the _activation_ (this may not be the same as the namespace for the action).
* `__OW_ACTION_NAME` the fully qualified name of the running action.
+* `__OW_ACTION_VERSION` the internal version number of the running action.
* `__OW_ACTIVATION_ID` the activation id for this running action instance.
* `__OW_DEADLINE` the approximate time when this action will have consumed its entire duration quota (measured in epoch milliseconds).
diff --git a/tests/dat/actions/helloContext.js b/tests/dat/actions/helloContext.js
index ebe1ab9..6e40bc9 100644
--- a/tests/dat/actions/helloContext.js
+++ b/tests/dat/actions/helloContext.js
@@ -21,6 +21,7 @@
"api_key": process.env['__OW_API_KEY'],
"namespace": process.env['__OW_NAMESPACE'],
"action_name": process.env['__OW_ACTION_NAME'],
+ "action_version": process.env['__OW_ACTION_VERSION'],
"activation_id": process.env['__OW_ACTIVATION_ID'],
"deadline": process.env['__OW_DEADLINE']
}
diff --git a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
index 8a120ec..cceae85 100644
--- a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
+++ b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
@@ -102,6 +102,7 @@
* "api_key": process.env__OW_API_KEY,
* "namespace": process.env.__OW_NAMESPACE,
* "action_name": process.env.__OW_ACTION_NAME,
+ * "action_version": process.env.__OW_ACTION_VERSION,
* "activation_id": process.env.__OW_ACTIVATION_ID,
* "deadline": process.env.__OW_DEADLINE
* }
@@ -309,6 +310,7 @@
"api_key" -> "abc",
"namespace" -> "zzz",
"action_name" -> "xxx",
+ "action_version" -> "0.0.1",
"activation_id" -> "iii",
"deadline" -> "123")
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskRestBasicUsageTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskRestBasicUsageTests.scala
index 6fbc421..9b2e61a 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskRestBasicUsageTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskRestBasicUsageTests.scala
@@ -335,6 +335,7 @@
fields.get("api_key") shouldBe empty
fields("namespace") shouldBe namespace
fields("action_name") shouldBe s"/$namespace/$name"
+ fields("action_version") should fullyMatch regex ("""\d+.\d+.\d+""")
fields("activation_id") shouldBe activation.activationId
fields("deadline").toLong should be >= start
}
@@ -360,6 +361,7 @@
fields("api_key") shouldBe wskprops.authKey
fields("namespace") shouldBe namespace
fields("action_name") shouldBe s"/$namespace/$name"
+ fields("action_version") should fullyMatch regex ("""\d+.\d+.\d+""")
fields("activation_id") shouldBe activation.activationId
fields("deadline").toLong should be >= start
}
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala
index f5b6c7c..1172d0a 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/test/ContainerProxyTests.scala
@@ -1428,6 +1428,7 @@
initializeEnv.fields("__OW_NAMESPACE") shouldBe invocationNamespace.name.toJson
initializeEnv.fields("__OW_ACTION_NAME") shouldBe message.action.qualifiedNameWithLeadingSlash.toJson
+ initializeEnv.fields("__OW_ACTION_VERSION") shouldBe message.action.version.toJson
initializeEnv.fields("__OW_ACTIVATION_ID") shouldBe message.activationId.toJson
initializeEnv.fields("__OW_TRANSACTION_ID") shouldBe transid.id.toJson
@@ -1457,6 +1458,7 @@
val runCount = atomicRunCount.incrementAndGet()
environment.fields("namespace") shouldBe invocationNamespace.name.toJson
environment.fields("action_name") shouldBe message.action.qualifiedNameWithLeadingSlash.toJson
+ environment.fields("action_version") shouldBe message.action.version.toJson
environment.fields("activation_id") shouldBe message.activationId.toJson
environment.fields("transaction_id") shouldBe transid.id.toJson
val authEnvironment = environment.fields.filterKeys(message.user.authkey.toEnvironment.fields.contains)