Skip to content
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

Allow for activation store to accept user and request information #3798

Merged
merged 4 commits into from
Aug 20, 2018

Conversation

dubee
Copy link
Member

@dubee dubee commented Jun 21, 2018

Other ActivationStore implementations, Elasticsearch for instance, will need user and request information.

Description

Related issue and scope

  • I opened an issue to propose and discuss this change (#????)

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

@dubee dubee force-pushed the activation-store-user-request branch from 4e8a766 to 0140629 Compare June 21, 2018 18:29
@dubee dubee added the review Review for this PR has been requested and yet needs to be done. label Jun 21, 2018
@dubee
Copy link
Member Author

dubee commented Jun 21, 2018

PG4 1863 🔵

@codecov-io
Copy link

codecov-io commented Jun 21, 2018

Codecov Report

Merging #3798 into master will decrease coverage by 6.59%.
The diff coverage is 90.32%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #3798     +/-   ##
========================================
- Coverage   85.29%   78.7%   -6.6%     
========================================
  Files         146     147      +1     
  Lines        7057    7418    +361     
  Branches      413     464     +51     
========================================
- Hits         6019    5838    -181     
- Misses       1038    1580    +542
Impacted Files Coverage Δ
...sk/core/containerpool/logging/SplunkLogStore.scala 86.95% <ø> (ø) ⬆️
...ainerpool/logging/DockerToActivationLogStore.scala 100% <ø> (ø) ⬆️
...core/containerpool/logging/LogDriverLogStore.scala 25% <ø> (ø) ⬆️
.../whisk/core/database/ArtifactActivationStore.scala 92.85% <ø> (ø) ⬆️
.../containerpool/logging/ElasticSearchLogStore.scala 96.15% <100%> (ø) ⬆️
...cala/whisk/core/containerpool/ContainerProxy.scala 93.82% <100%> (+0.07%) ⬆️
...hisk/core/controller/actions/SequenceActions.scala 94.49% <100%> (+0.05%) ⬆️
...ain/scala/whisk/core/invoker/InvokerReactive.scala 58.33% <33.33%> (-0.5%) ⬇️
...isk/core/controller/actions/PrimitiveActions.scala 89.31% <85.71%> (+0.16%) ⬆️
...main/scala/whisk/core/controller/Activations.scala 96.66% <87.5%> (+0.05%) ⬆️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f365d1c...1044792. Read the comment docs.

@@ -48,7 +49,8 @@ trait ActivationStore {
* @param transid transaction ID for request
* @return Future containing the retrieved WhiskActivation
*/
def get(activationId: ActivationId)(implicit transid: TransactionId): Future[WhiskActivation]
def get(activationId: ActivationId, user: Option[Identity] = None, request: Option[HttpRequest] = None)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make user and request an Option? When would you not pass these values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markusthoemmes, since there exists situations were the user and request information may not be know, DB polling for blocking invocations, do you think we should leave those parameters as optional?

Copy link
Member Author

@dubee dubee Jul 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markusthoemmes, certain activation stores may need to maintain a separate DB to track activations for blocking invocations given the DB polling behavior. When user or request is not provided to the activation store, this could signal that a blocking invocation is taking place.

@dubee
Copy link
Member Author

dubee commented Jun 22, 2018

@markusthoemmes
Copy link
Contributor

@dubee concerned in which way? I believe this is the database fallback polling in case an active ack goes missing.

@chetanmeh
Copy link
Member

@dubee Can you share some more details on how Elasticsearch implementation would make use of user and request data. Would it like to use any aspect of request or we can extract explicit parts from request and pass it on.

For now it appears that passing request param is making SPI usage more coupled to web requests

@dubee
Copy link
Member Author

dubee commented Jul 6, 2018

@chetanmeh, certain Elasticsearch deployments require additional authentication which can be passed through the controller via HTTP headers. This allows the controller to communicate to Elasitcsearch for users making requests. Currently our Elasticsearch log store works in the same way. When required headers are specified via the OpenWhisk Ansible configuration for the log store, the log store will pass those headers from the client to Elasticsearch to perform a query.

See the log store for example:
https://github.com/apache/incubator-openwhisk/blob/92a64c291156a2cd3d6b304babc2a193a46d0699/common/scala/src/main/scala/whisk/core/containerpool/logging/ElasticSearchLogStore.scala#L103

@chetanmeh
Copy link
Member

@dubee Now its more clear. So we pass on some sort of "user context" to ES. May be we make that notion explicit via having a UserContext as parameter type

case class UserContext(user:Option[Identity], request: Option[HttpRequest])
-  def get(activationId: ActivationId, user: Option[Identity] = None, request: Option[HttpRequest] = None)(
-  def get(activationId: ActivationId, userContext: Option[UserContext] = None)(

@dubee dubee force-pushed the activation-store-user-request branch from 0140629 to 0a1dfd0 Compare August 7, 2018 16:22
@dubee
Copy link
Member Author

dubee commented Aug 7, 2018

PG2 3475 🔵

@dubee
Copy link
Member Author

dubee commented Aug 7, 2018

@markusthoemmes, anything else on this one?

@dubee dubee added the awaits-reviewer The reviewer needs to respond to comments from contributer. label Aug 7, 2018
@dubee
Copy link
Member Author

dubee commented Aug 8, 2018

@chetanmeh, where do you think the UserContext case class should live?

@dubee dubee force-pushed the activation-store-user-request branch 2 times, most recently from 0d7d0b4 to dd33c35 Compare August 8, 2018 17:29
@dubee
Copy link
Member Author

dubee commented Aug 8, 2018

Added UserContext in the third commit. The case class definition should probably be moved elsewhere though.

@dubee
Copy link
Member Author

dubee commented Aug 8, 2018

PG4 2057 🔵

@chetanmeh
Copy link
Member

where do you think the UserContext case class should live

Adding it to ActivationStore looks fine

@dubee
Copy link
Member Author

dubee commented Aug 14, 2018

@markusthoemmes, any other comments on this one?

@dubee
Copy link
Member Author

dubee commented Aug 15, 2018

@mdeuser, can you review this one?

@@ -29,6 +28,7 @@ import whisk.common.TransactionId
import whisk.core.containerpool.Container
import whisk.core.entity.{ActivationLogs, ExecutableWhiskAction, Identity, WhiskActivation}
import whisk.http.Messages
import whisk.core.database.UserContext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this class tightly coupled with the database package? on the surface, it seems like it could go into some place else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdeuser, the ActivationStore was moved to the database package recently. Where do you think UserContext should live?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not entirely sure, but it seems like it is not tightly coupled with the database.. whisk.core.entity ?

@@ -38,8 +41,9 @@ trait ActivationStore {
* @param notifier cache change notifier
* @return Future containing DocInfo related to stored activation
*/
def store(activation: WhiskActivation)(implicit transid: TransactionId,
notifier: Option[CacheChangeNotification]): Future[DocInfo]
def store(activation: WhiskActivation, context: UserContext)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update api comment with new param

@@ -48,7 +52,7 @@ trait ActivationStore {
* @param transid transaction ID for request
* @return Future containing the retrieved WhiskActivation
*/
def get(activationId: ActivationId)(implicit transid: TransactionId): Future[WhiskActivation]
def get(activationId: ActivationId, context: UserContext)(implicit transid: TransactionId): Future[WhiskActivation]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update api comment with new param

@@ -58,8 +62,9 @@ trait ActivationStore {
* @param notifier cache change notifier
* @return Future containing a Boolean value indication whether the activation was deleted
*/
def delete(activationId: ActivationId)(implicit transid: TransactionId,
notifier: Option[CacheChangeNotification]): Future[Boolean]
def delete(activationId: ActivationId, context: UserContext)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update api comment with new param

@@ -76,7 +81,8 @@ trait ActivationStore {
name: Option[EntityPath] = None,
skip: Int,
since: Option[Instant] = None,
upto: Option[Instant] = None)(implicit transid: TransactionId): Future[JsObject]
upto: Option[Instant] = None,
context: UserContext)(implicit transid: TransactionId): Future[JsObject]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update api comment with new param

includeDocs: Boolean = false,
since: Option[Instant] = None,
upto: Option[Instant] = None,
context: UserContext)(implicit transid: TransactionId): Future[Either[List[JsObject], List[WhiskActivation]]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update api comment with new param

@@ -517,6 +518,8 @@ protected[actions] trait PrimitiveActions {
private def completeActivation(user: Identity, session: Session, response: ActivationResponse)(
implicit transid: TransactionId): WhiskActivation = {

val context = UserContext(user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the original request context needed here?

Copy link
Member Author

@dubee dubee Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the user information needs to be passed to the ActivationStore store() method. This allows ActivationStore SPIs to extract user information if need be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what about the original request context (i.e. request headers, payload, etc).. since there's is a write to the activation store (like in other places) i was thinking the request context would also be needed (like in other places)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a use case for passing the request to the activation store here. Would rather keep the invocation path lean unless we really need the HTTP header in the store method.

@dubee dubee force-pushed the activation-store-user-request branch from dd33c35 to 1044792 Compare August 16, 2018 17:28
Copy link
Contributor

@mdeuser mdeuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dubee dubee merged commit 8327cd0 into apache:master Aug 20, 2018
BillZong pushed a commit to BillZong/openwhisk that referenced this pull request Nov 18, 2019
…ache#3798)

* Allow for activation store to accept user and request information

* Make user and request non-optional parameters

* Introduce UserContext to activation store

* Update doc for new parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaits-reviewer The reviewer needs to respond to comments from contributer. review Review for this PR has been requested and yet needs to be done.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants