You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by st...@apache.org on 2020/10/13 13:09:15 UTC
[openwhisk] branch master updated: Controller should not return a
payload for created and deleted entities (#4968)
This is an automated email from the ASF dual-hosted git repository.
style95 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new a7a797b Controller should not return a payload for created and deleted entities (#4968)
a7a797b is described below
commit a7a797b8369972b1e38e70f6ddf6089ba215e8d2
Author: Nitika Agarwal <54...@users.noreply.github.com>
AuthorDate: Tue Oct 13 18:25:25 2020 +0530
Controller should not return a payload for created and deleted entities (#4968)
* Controller should not return a payload for created and deleted entities
* Add Feature Flag support
* Revert test cases changes
* Introduce feature flag at all relevant places
---
ansible/group_vars/all | 1 +
ansible/roles/controller/tasks/deploy.yml | 1 +
ansible/templates/whisk.properties.j2 | 1 +
common/scala/src/main/resources/application.conf | 5 +++++
.../src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala | 3 ++-
.../scala/org/apache/openwhisk/core/controller/ApiUtils.scala | 8 ++++++--
tests/src/test/resources/application.conf.j2 | 1 +
7 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index 0850506..0c54c92 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -50,6 +50,7 @@ whisk:
date: "{{ansible_date_time.iso8601}}"
feature_flags:
require_api_key_annotation: "{{ require_api_key_annotation | default(true) | lower }}"
+ require_response_payload: "{{ require_response_payload | default(true) | lower }}"
##
# configuration parameters related to support runtimes (see org.apache.openwhisk.core.entity.ExecManifest for schema of the manifest).
diff --git a/ansible/roles/controller/tasks/deploy.yml b/ansible/roles/controller/tasks/deploy.yml
index 11d3a9d..64724c4 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -221,6 +221,7 @@
"CONFIG_whisk_concurrencyLimit_std": "{{ limit_action_concurrency_std | default() }}"
"CONFIG_whisk_featureFlags_requireApiKeyAnnotation": "{{ whisk.feature_flags.require_api_key_annotation | default(true) | lower }}"
+ "CONFIG_whisk_featureFlags_requireResponsePayload": "{{ whisk.feature_flags.require_response_payload | default(true) | lower }}"
"CONFIG_whisk_activation_payload_max":
"{{ limit_activation_payload | default() }}"
diff --git a/ansible/templates/whisk.properties.j2 b/ansible/templates/whisk.properties.j2
index 5951788..03ade2b 100644
--- a/ansible/templates/whisk.properties.j2
+++ b/ansible/templates/whisk.properties.j2
@@ -33,6 +33,7 @@ whisk.api.vanity.subdomain.parts=1
whisk.action.concurrency={{ runtimes_enable_concurrency | default(false) }}
whisk.feature.requireApiKeyAnnotation={{ whisk.feature_flags.require_api_key_annotation | default(true) }}
+whisk.feature.requireResponsePayload={{ whisk.feature_flags.require_response_payload | default(true) }}
runtimes.manifest={{ runtimesManifest | to_json }}
diff --git a/common/scala/src/main/resources/application.conf b/common/scala/src/main/resources/application.conf
index 22a9b57..50a748a 100644
--- a/common/scala/src/main/resources/application.conf
+++ b/common/scala/src/main/resources/application.conf
@@ -549,6 +549,11 @@ whisk {
# See https://github.com/apache/openwhisk/pull/4284
# for details
require-api-key-annotation = true
+
+ # Enables the support to receive the response payload
+ # for POST and DELETE APIs
+ # See: https://github.com/apache/openwhisk/issues/3274
+ require-response-payload = true
}
apache-client {
diff --git a/common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala b/common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala
index 4e46331..c796b4e 100644
--- a/common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala
+++ b/common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala
@@ -20,8 +20,9 @@ import pureconfig._
import pureconfig.generic.auto._
object FeatureFlags {
- private case class FeatureFlagConfig(requireApiKeyAnnotation: Boolean)
+ private case class FeatureFlagConfig(requireApiKeyAnnotation: Boolean, requireResponsePayload: Boolean)
private val config = loadConfigOrThrow[FeatureFlagConfig](ConfigKeys.featureFlags)
val requireApiKeyAnnotation: Boolean = config.requireApiKeyAnnotation
+ val requireResponsePayload: Boolean = config.requireResponsePayload
}
diff --git a/core/controller/src/main/scala/org/apache/openwhisk/core/controller/ApiUtils.scala b/core/controller/src/main/scala/org/apache/openwhisk/core/controller/ApiUtils.scala
index 42b39cd..ef2dc51 100644
--- a/core/controller/src/main/scala/org/apache/openwhisk/core/controller/ApiUtils.scala
+++ b/core/controller/src/main/scala/org/apache/openwhisk/core/controller/ApiUtils.scala
@@ -29,11 +29,13 @@ import akka.http.scaladsl.model.StatusCodes.Conflict
import akka.http.scaladsl.model.StatusCodes.InternalServerError
import akka.http.scaladsl.model.StatusCodes.NotFound
import akka.http.scaladsl.model.StatusCodes.OK
+import akka.http.scaladsl.model.StatusCodes.NoContent
import akka.http.scaladsl.server.{Directives, RequestContext, RouteResult}
import spray.json.DefaultJsonProtocol._
import spray.json.{JsObject, JsValue, RootJsonFormat}
import org.apache.openwhisk.common.Logging
import org.apache.openwhisk.common.TransactionId
+import org.apache.openwhisk.core.FeatureFlags
import org.apache.openwhisk.core.controller.PostProcess.PostProcessEntity
import org.apache.openwhisk.core.database._
import org.apache.openwhisk.core.entity.{ActivationId, ActivationLogs, DocId, WhiskActivation, WhiskDocument}
@@ -341,7 +343,8 @@ trait WriteOps extends Directives {
}) {
case Success(entity) =>
logging.debug(this, s"[PUT] entity success")
- postProcess map { _(entity) } getOrElse complete(OK, entity)
+ if (FeatureFlags.requireResponsePayload) postProcess map { _(entity) } getOrElse complete(OK, entity)
+ else postProcess map { _(entity) } getOrElse complete(OK)
case Failure(IdentityPut(a)) =>
logging.debug(this, s"[PUT] entity exists, not overwritten")
complete(OK, a)
@@ -399,7 +402,8 @@ trait WriteOps extends Directives {
}) {
case Success(entity) =>
logging.debug(this, s"[DEL] entity success")
- postProcess map { _(entity) } getOrElse complete(OK, entity)
+ if (FeatureFlags.requireResponsePayload) postProcess map { _(entity) } getOrElse complete(OK, entity)
+ else postProcess map { _(entity) } getOrElse complete(NoContent)
case Failure(t: NoDocumentException) =>
logging.debug(this, s"[DEL] entity does not exist")
terminate(NotFound)
diff --git a/tests/src/test/resources/application.conf.j2 b/tests/src/test/resources/application.conf.j2
index 82c8cc3..5f61695 100644
--- a/tests/src/test/resources/application.conf.j2
+++ b/tests/src/test/resources/application.conf.j2
@@ -18,6 +18,7 @@ akka.jvm-exit-on-fatal-error = off
whisk {
feature-flags {
require-api-key-annotation = {{ whisk.feature_flags.require_api_key_annotation | default(true) }}
+ require-response-payload = {{ whisk.feature_flags.require_response_payload | default(true) }}
}
# kafka related configuration
kafka {