-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add system config options for success / failure levels to write blocking / non-blocking activations to db #5169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
af7cb02
5881bc6
7916d90
5e2b36f
a3db5d3
e43ee00
823e3e9
7bbac30
4a4a083
666b707
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
package org.apache.openwhisk.core.database | ||
|
||
import java.time.Instant | ||
|
||
import akka.actor.ActorSystem | ||
import akka.http.scaladsl.model.HttpRequest | ||
import spray.json.JsObject | ||
|
@@ -33,32 +32,43 @@ import scala.concurrent.Future | |
case class UserContext(user: Identity, request: HttpRequest = HttpRequest()) | ||
|
||
trait ActivationStore { | ||
|
||
/* DEPRECATED: disableStoreResult config is now deprecated replaced with blocking activation store level */ | ||
bdoyle0182 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
protected val disableStoreResultConfig = loadConfigOrThrow[Boolean](ConfigKeys.disableStoreResult) | ||
protected val storeBlockingResultLevelConfig = { | ||
val configValue = ActivationStoreLevel.valueOf(loadConfigOrThrow[String](ConfigKeys.storeBlockingResultLevel)) | ||
if (disableStoreResultConfig && configValue == ActivationStoreLevel.STORE_ALWAYS) ActivationStoreLevel.STORE_FAILURES | ||
else configValue | ||
} | ||
protected val storeNonBlockingResultLevelConfig = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this also be in the try and ignored/set to false if it fails? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can discuss a date to remove it since we're not really following consistent releases and I'll send an email announcing the plan to remove it. I don't think it needs to be moved since the existing behavior is to fail if it doesn't exist which maybe was unnecessary originally and we don't need to keep it long |
||
ActivationStoreLevel.valueOf(loadConfigOrThrow[String](ConfigKeys.storeNonBlockingResultLevel)) | ||
protected val unstoredLogsEnabledConfig = loadConfigOrThrow[Boolean](ConfigKeys.unstoredLogsEnabled) | ||
|
||
/** | ||
* Checks if an activation should be stored in database and stores it. | ||
* | ||
* @param activation activation to store | ||
* @param isBlockingActivation is activation blocking | ||
* @param blockingStoreLevel do not store activation if successful and blocking | ||
* @param nonBlockingStoreLevel do not store activation if successful and non-blocking | ||
* @param context user and request context | ||
* @param transid transaction ID for request | ||
* @param notifier cache change notifier | ||
* @return Future containing DocInfo related to stored activation | ||
*/ | ||
def storeAfterCheck(activation: WhiskActivation, | ||
isBlockingActivation: Boolean, | ||
disableStore: Option[Boolean], | ||
blockingStoreLevel: Option[ActivationStoreLevel.Value], | ||
nonBlockingStoreLevel: Option[ActivationStoreLevel.Value], | ||
context: UserContext)(implicit transid: TransactionId, | ||
notifier: Option[CacheChangeNotification], | ||
logging: Logging): Future[DocInfo] = { | ||
if (context.user.limits.storeActivations.getOrElse(true) && | ||
shouldStoreActivation( | ||
activation.response.isSuccess, | ||
activation.response, | ||
isBlockingActivation, | ||
transid.meta.extraLogging, | ||
disableStore.getOrElse(disableStoreResultConfig))) { | ||
blockingStoreLevel.getOrElse(storeBlockingResultLevelConfig), | ||
nonBlockingStoreLevel.getOrElse(storeNonBlockingResultLevelConfig))) { | ||
|
||
store(activation, context) | ||
} else { | ||
|
@@ -183,17 +193,29 @@ trait ActivationStore { | |
* - an activation in debug mode | ||
* - activation stores is not disabled via a configuration parameter | ||
* | ||
* @param isSuccess is successful activation | ||
* @param activationResponse to check | ||
* @param isBlocking is blocking activation | ||
* @param debugMode is logging header set to "on" for the invocation | ||
* @param disableStore is disable store configured | ||
* @param blockingStoreLevel level of activation status to store for blocking invocations | ||
* @param nonBlockingStoreLevel level of activation status to store for blocking invocations | ||
* @return Should the activation be stored to the database | ||
*/ | ||
private def shouldStoreActivation(isSuccess: Boolean, | ||
private def shouldStoreActivation(activationResponse: ActivationResponse, | ||
isBlocking: Boolean, | ||
debugMode: Boolean, | ||
disableStore: Boolean): Boolean = { | ||
!isSuccess || !isBlocking || debugMode || !disableStore | ||
blockingStoreLevel: ActivationStoreLevel.Value, | ||
nonBlockingStoreLevel: ActivationStoreLevel.Value): Boolean = { | ||
def shouldStoreOnLevel(storageLevel: ActivationStoreLevel.Value): Boolean = { | ||
storageLevel match { | ||
case ActivationStoreLevel.STORE_ALWAYS => true | ||
case ActivationStoreLevel.STORE_FAILURES => !activationResponse.isSuccess | ||
case ActivationStoreLevel.STORE_FAILURES_NOT_APPLICATION_ERRORS => | ||
activationResponse.isContainerError || activationResponse.isWhiskError | ||
} | ||
} | ||
|
||
debugMode || (isBlocking && shouldStoreOnLevel(blockingStoreLevel)) || (!isBlocking && shouldStoreOnLevel( | ||
nonBlockingStoreLevel)) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.openwhisk.core.database | ||
|
||
object ActivationStoreLevel extends Enumeration { | ||
type ActivationStoreLevel = Value | ||
val STORE_ALWAYS, STORE_FAILURES, STORE_FAILURES_NOT_APPLICATION_ERRORS = Value | ||
|
||
def valueOf(value: String): Value = { | ||
values | ||
.find(_.toString == value.toUpperCase()) | ||
.getOrElse(throw new IllegalArgumentException(s"Invalid log level: $value")) | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.