Skip to content

Commit 7bbac30

Browse files
author
Brendan Doyle
committed
feedback
1 parent 823e3e9 commit 7bbac30

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

common/scala/src/main/scala/org/apache/openwhisk/core/database/ActivationStore.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ case class UserContext(user: Identity, request: HttpRequest = HttpRequest())
3434
trait ActivationStore {
3535
/* DEPRECATED: disableStoreResult config is now deprecated replaced with blocking activation store level */
3636
protected val disableStoreResultConfig = loadConfigOrThrow[Boolean](ConfigKeys.disableStoreResult)
37-
protected val storeBlockingResultLevelConfig =
38-
if (disableStoreResultConfig) ActivationStoreLevel.STORE_FAILURES
39-
else ActivationStoreLevel.valueOf(loadConfigOrThrow[String](ConfigKeys.storeBlockingResultLevel))
37+
protected val storeBlockingResultLevelConfig = {
38+
val configValue = ActivationStoreLevel.valueOf(loadConfigOrThrow[String](ConfigKeys.storeBlockingResultLevel))
39+
if (disableStoreResultConfig && configValue == ActivationStoreLevel.STORE_ALWAYS) ActivationStoreLevel.STORE_FAILURES
40+
else configValue
41+
}
4042
protected val storeNonBlockingResultLevelConfig =
4143
ActivationStoreLevel.valueOf(loadConfigOrThrow[String](ConfigKeys.storeNonBlockingResultLevel))
4244
protected val unstoredLogsEnabledConfig = loadConfigOrThrow[Boolean](ConfigKeys.unstoredLogsEnabled)
@@ -46,7 +48,7 @@ trait ActivationStore {
4648
*
4749
* @param activation activation to store
4850
* @param isBlockingActivation is activation blocking
49-
* @param disableBlockingStore do not store activation if successful and blocking
51+
* @param blockingStoreLevel do not store activation if successful and blocking
5052
* @param nonBlockingStoreLevel do not store activation if successful and non-blocking
5153
* @param context user and request context
5254
* @param transid transaction ID for request
@@ -62,7 +64,7 @@ trait ActivationStore {
6264
logging: Logging): Future[DocInfo] = {
6365
if (context.user.limits.storeActivations.getOrElse(true) &&
6466
shouldStoreActivation(
65-
activation,
67+
activation.response,
6668
isBlockingActivation,
6769
transid.meta.extraLogging,
6870
blockingStoreLevel.getOrElse(storeBlockingResultLevelConfig),
@@ -191,24 +193,24 @@ trait ActivationStore {
191193
* - an activation in debug mode
192194
* - activation stores is not disabled via a configuration parameter
193195
*
194-
* @param activation to check
196+
* @param activationResponse to check
195197
* @param isBlocking is blocking activation
196198
* @param debugMode is logging header set to "on" for the invocation
197199
* @param blockingStoreLevel level of activation status to store for blocking invocations
198200
* @param nonBlockingStoreLevel level of activation status to store for blocking invocations
199201
* @return Should the activation be stored to the database
200202
*/
201-
private def shouldStoreActivation(activation: WhiskActivation,
203+
private def shouldStoreActivation(activationResponse: ActivationResponse,
202204
isBlocking: Boolean,
203205
debugMode: Boolean,
204206
blockingStoreLevel: ActivationStoreLevel.Value,
205207
nonBlockingStoreLevel: ActivationStoreLevel.Value): Boolean = {
206208
def shouldStoreOnLevel(storageLevel: ActivationStoreLevel.Value): Boolean = {
207209
storageLevel match {
208210
case ActivationStoreLevel.STORE_ALWAYS => true
209-
case ActivationStoreLevel.STORE_FAILURES => !activation.response.isSuccess
211+
case ActivationStoreLevel.STORE_FAILURES => !activationResponse.isSuccess
210212
case ActivationStoreLevel.STORE_FAILURES_NOT_APPLICATION_ERRORS =>
211-
!activation.response.isSuccess && !activation.response.isApplicationError
213+
activationResponse.isContainerError || activationResponse.isWhiskError
212214
}
213215
}
214216

0 commit comments

Comments
 (0)