Skip to content

Commit a7a797b

Browse files
authored
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
1 parent 9134a03 commit a7a797b

7 files changed

Lines changed: 17 additions & 3 deletions

File tree

ansible/group_vars/all

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ whisk:
5050
date: "{{ansible_date_time.iso8601}}"
5151
feature_flags:
5252
require_api_key_annotation: "{{ require_api_key_annotation | default(true) | lower }}"
53+
require_response_payload: "{{ require_response_payload | default(true) | lower }}"
5354

5455
##
5556
# configuration parameters related to support runtimes (see org.apache.openwhisk.core.entity.ExecManifest for schema of the manifest).

ansible/roles/controller/tasks/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
"CONFIG_whisk_concurrencyLimit_std": "{{ limit_action_concurrency_std | default() }}"
222222

223223
"CONFIG_whisk_featureFlags_requireApiKeyAnnotation": "{{ whisk.feature_flags.require_api_key_annotation | default(true) | lower }}"
224+
"CONFIG_whisk_featureFlags_requireResponsePayload": "{{ whisk.feature_flags.require_response_payload | default(true) | lower }}"
224225

225226
"CONFIG_whisk_activation_payload_max":
226227
"{{ limit_activation_payload | default() }}"

ansible/templates/whisk.properties.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ whisk.api.vanity.subdomain.parts=1
3333

3434
whisk.action.concurrency={{ runtimes_enable_concurrency | default(false) }}
3535
whisk.feature.requireApiKeyAnnotation={{ whisk.feature_flags.require_api_key_annotation | default(true) }}
36+
whisk.feature.requireResponsePayload={{ whisk.feature_flags.require_response_payload | default(true) }}
3637

3738
runtimes.manifest={{ runtimesManifest | to_json }}
3839

common/scala/src/main/resources/application.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,11 @@ whisk {
549549
# See https://github.com/apache/openwhisk/pull/4284
550550
# for details
551551
require-api-key-annotation = true
552+
553+
# Enables the support to receive the response payload
554+
# for POST and DELETE APIs
555+
# See: https://github.com/apache/openwhisk/issues/3274
556+
require-response-payload = true
552557
}
553558

554559
apache-client {

common/scala/src/main/scala/org/apache/openwhisk/core/FeatureFlags.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import pureconfig._
2020
import pureconfig.generic.auto._
2121

2222
object FeatureFlags {
23-
private case class FeatureFlagConfig(requireApiKeyAnnotation: Boolean)
23+
private case class FeatureFlagConfig(requireApiKeyAnnotation: Boolean, requireResponsePayload: Boolean)
2424
private val config = loadConfigOrThrow[FeatureFlagConfig](ConfigKeys.featureFlags)
2525

2626
val requireApiKeyAnnotation: Boolean = config.requireApiKeyAnnotation
27+
val requireResponsePayload: Boolean = config.requireResponsePayload
2728
}

core/controller/src/main/scala/org/apache/openwhisk/core/controller/ApiUtils.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ import akka.http.scaladsl.model.StatusCodes.Conflict
2929
import akka.http.scaladsl.model.StatusCodes.InternalServerError
3030
import akka.http.scaladsl.model.StatusCodes.NotFound
3131
import akka.http.scaladsl.model.StatusCodes.OK
32+
import akka.http.scaladsl.model.StatusCodes.NoContent
3233
import akka.http.scaladsl.server.{Directives, RequestContext, RouteResult}
3334
import spray.json.DefaultJsonProtocol._
3435
import spray.json.{JsObject, JsValue, RootJsonFormat}
3536
import org.apache.openwhisk.common.Logging
3637
import org.apache.openwhisk.common.TransactionId
38+
import org.apache.openwhisk.core.FeatureFlags
3739
import org.apache.openwhisk.core.controller.PostProcess.PostProcessEntity
3840
import org.apache.openwhisk.core.database._
3941
import org.apache.openwhisk.core.entity.{ActivationId, ActivationLogs, DocId, WhiskActivation, WhiskDocument}
@@ -341,7 +343,8 @@ trait WriteOps extends Directives {
341343
}) {
342344
case Success(entity) =>
343345
logging.debug(this, s"[PUT] entity success")
344-
postProcess map { _(entity) } getOrElse complete(OK, entity)
346+
if (FeatureFlags.requireResponsePayload) postProcess map { _(entity) } getOrElse complete(OK, entity)
347+
else postProcess map { _(entity) } getOrElse complete(OK)
345348
case Failure(IdentityPut(a)) =>
346349
logging.debug(this, s"[PUT] entity exists, not overwritten")
347350
complete(OK, a)
@@ -399,7 +402,8 @@ trait WriteOps extends Directives {
399402
}) {
400403
case Success(entity) =>
401404
logging.debug(this, s"[DEL] entity success")
402-
postProcess map { _(entity) } getOrElse complete(OK, entity)
405+
if (FeatureFlags.requireResponsePayload) postProcess map { _(entity) } getOrElse complete(OK, entity)
406+
else postProcess map { _(entity) } getOrElse complete(NoContent)
403407
case Failure(t: NoDocumentException) =>
404408
logging.debug(this, s"[DEL] entity does not exist")
405409
terminate(NotFound)

tests/src/test/resources/application.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ akka.jvm-exit-on-fatal-error = off
1818
whisk {
1919
feature-flags {
2020
require-api-key-annotation = {{ whisk.feature_flags.require_api_key_annotation | default(true) }}
21+
require-response-payload = {{ whisk.feature_flags.require_response_payload | default(true) }}
2122
}
2223
# kafka related configuration
2324
kafka {

0 commit comments

Comments
 (0)