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

Add binding annotation to record an action path not resolved #4211

Merged
merged 9 commits into from
May 13, 2019

Conversation

upgle
Copy link
Member

@upgle upgle commented Jan 9, 2019

Description

If the user invokes an action in a package binding, they can't know a package binding path from which action is invoked. because the current activation structure only records the resolved action path.

for example, suppose we have the following entities:

  • package : pkg1
    • action : pkg1/action1
  • package pkg2 bind pkg1
  • package pkg3 bind pkg1

If user invokes the pkg2/action1 action and the pkg3/action1 action, all path annotations of invoked action in binding packages are saved as namespace/pkg1/action1.

    "annotations": [
        {
            "key": "path",
            "value": "namespace/pkg1/action1"
        },
     ]

Suggestion

So i added an annotation to distinguish between resolved action path and invoked action path and opend this PR.

{
    "activationId": "f4250bb2721d4e4ca50bb2721d2e4cdd",
    "annotations": [
        {
            "key": "path",
            "value": "namespace/pkg1/action1"
        },
        {
            "key": "originPath",
            "value": "namespace/pkg2/action1"
        }
    ]
}

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.

@upgle upgle changed the title Add originPath annotation to record the not resolved action path Add originPath annotation to record an action path not resolved Jan 9, 2019
@codecov-io
Copy link

codecov-io commented Jan 9, 2019

Codecov Report

Merging #4211 into master will decrease coverage by 4.17%.
The diff coverage is 91.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4211      +/-   ##
==========================================
- Coverage   85.56%   81.39%   -4.18%     
==========================================
  Files         169      169              
  Lines        7833     7840       +7     
  Branches      536      525      -11     
==========================================
- Hits         6702     6381     -321     
- Misses       1131     1459     +328
Impacted Files Coverage Δ
.../apache/openwhisk/core/controller/WebActions.scala 92.33% <ø> (ø) ⬆️
...enwhisk/core/entity/FullyQualifiedEntityName.scala 91.42% <100%> (ø) ⬆️
...apache/openwhisk/core/entity/WhiskActivation.scala 92.06% <100%> (+0.12%) ⬆️
...org/apache/openwhisk/core/controller/Actions.scala 93.03% <100%> (-0.34%) ⬇️
.../openwhisk/core/containerpool/ContainerProxy.scala 91.79% <100%> (+0.03%) ⬆️
...hisk/core/controller/actions/SequenceActions.scala 92.3% <100%> (+0.2%) ⬆️
...isk/core/controller/actions/PrimitiveActions.scala 87.16% <100%> (+0.08%) ⬆️
...org/apache/openwhisk/core/entity/WhiskAction.scala 91.06% <78.57%> (+4.15%) ⬆️
...core/database/cosmosdb/RxObservableImplicits.scala 0% <0%> (-100%) ⬇️
...core/database/cosmosdb/CosmosDBArtifactStore.scala 0% <0%> (-95.24%) ⬇️
... and 10 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 58e3ddd...3044b13. Read the comment docs.

@rabbah
Copy link
Member

rabbah commented Jan 9, 2019

I wonder if instead of modifying the Action type, we can add an alias to FullyQualifiedName. This would mean - if it works out - that you don't have to change the activation message and the name of the action and its alias (i.e., package and binding) are coupled more tightly.

I would use binding in the annotation and leave the annotation as is otherwise (shows the package name).

This is a suggestion for discussion.

@rabbah rabbah self-requested a review January 9, 2019 19:13
@rabbah rabbah self-assigned this Jan 9, 2019
@rabbah rabbah added enhancement controller awaits-contributor The contributor needs to respond to comments from reviewer. labels Jan 9, 2019
@upgle
Copy link
Member Author

upgle commented Jan 10, 2019

As you mentioned, it would be better to add an alias to FullyQualifiedName.
I'll make a commit soon. 👍

@upgle upgle force-pushed the feature/add-origin-path branch 2 times, most recently from 2a748b2 to ba5bcc8 Compare January 15, 2019 04:50
@upgle
Copy link
Member Author

upgle commented Jan 15, 2019

@rabbah
I added binding field to FullyQualifiedName to not change the activation message, and renamed annotation key from originPath to binding.

this binding annotation contains only entityPath of a package binding.

{
    "activationId": "f4250bb2721d4e4ca50bb2721d2e4cdd",
    "annotations": [
        {
            "key": "binding",
            "value": "whisk.system/p2"
        },
        {
            "key": "path",
            "value": "guest/p1/hello"
        },
    ]
}

@upgle upgle changed the title Add originPath annotation to record an action path not resolved Add binding annotation to record an action path not resolved Jan 15, 2019
@style95
Copy link
Member

style95 commented Feb 28, 2019

@rabbah
Is it possible to include this change? or any other direction is being considered?
In any case, I hope this issue is addressed so that we can resolve many binding related issues.

@rabbah
Copy link
Member

rabbah commented Feb 28, 2019

Thanks for the nudge. Will get on it.

@upgle
Copy link
Member Author

upgle commented Feb 28, 2019

conflict has been resolved 😃

@rabbah rabbah added review Review for this PR has been requested and yet needs to be done. and removed awaits-contributor The contributor needs to respond to comments from reviewer. labels Feb 28, 2019
Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

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

this looks good generally but i think can be simplified further. You cleverly use toExecutableWhiskAction to add the binding and I suspect that you can do the same with the same method in the WhiskActionMetaData class --- this might end up removing some of the threading of binding throughout.

So that I'm not sending down the rabbit hole, I can dig into that a bit if you like.

@@ -303,6 +327,10 @@ case class ExecutableWhiskActionMetaData(namespace: EntityPath,
def toWhiskAction =
WhiskActionMetaData(namespace, name, exec, parameters, limits, version, publish, annotations)
.revision[WhiskActionMetaData](rev)

def bindingFullyQualifiedName =
Copy link
Member

Choose a reason for hiding this comment

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

i suggest adding a type decorator on the method for the return value and a comment, explaining that the result is Some fully qualified name only if there's a binding, else None.

@@ -254,7 +274,8 @@ case class WhiskActionMetaData(namespace: EntityPath,
* @param limits the limits to impose on the action
* @param version the semantic version
* @param publish true to share the action or false otherwise
* @param annotation the set of annotations to attribute to the action
* @param annotations the set of annotations to attribute to the action
* @param binding the path of the package binding
Copy link
Member

Choose a reason for hiding this comment

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

-> @param binding the path of the package binding if any

@@ -137,6 +137,7 @@ object WhiskActivation

/** Some field names for annotations */
val pathAnnotation = "path"
val bindingAnnotation = "binding"
Copy link
Member

Choose a reason for hiding this comment

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

will check down below but this raises the opportunity to have the name in the activation be that of the binding, and the annotation is that of the package.

Copy link
Member Author

@upgle upgle Mar 18, 2019

Choose a reason for hiding this comment

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

I'm sorry, I don't understand this.

In the example below, I think the name triple in the activation can not be the name of the binding whisk.system/p2

  • there is an action whisk.system/pkg1/triple
  • and the whisk.system/p2 is binding the whisk.system/pkg1
  • and i invoke an action whisk.system/p2/triple
{
    "namespace": "whisk.system",
    "name": "triple",
    "version": "0.0.1",
    "subject": "whisk.system",
    "activationId": "b86606b16b8a4371a606b16b8a437182",
    "start": 1552900408086,
    "end": 1552900408090,
    "duration": 4,
    "annotations": [
        {
            "key": "binding",
            "value": "whisk.system/p2"
        },
        {
            "key": "path",
            "value": "whisk.system/pkg1/triple"
        },
...

@style95
Copy link
Member

style95 commented Apr 3, 2019

Any update on this PR?

@upgle
Copy link
Member Author

upgle commented Apr 8, 2019

Sorry. I should resolve a conflict. I can handle today.

@upgle
Copy link
Member Author

upgle commented Apr 8, 2019

@rabbah A conflict is resolved. could you please review again?

c.c. @style95

* @param accounting the state of the sequence activation, contains the dynamic activation count, logs and payload for the next action
* @param cause the activation id of the first sequence containing this activations
* @return a future which resolves with updated accounting for a sequence, including the last result, duration, and activation ids
*/
private def invokeNextAction(
user: Identity,
futureAction: Future[WhiskActionMetaData],
originAction: FullyQualifiedEntityName,
Copy link
Member

Choose a reason for hiding this comment

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

Is this being used in the call tree?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems not using in the call tree. I'll fix it.

* Once the package is resolved, the operation is dispatched to the action in the package
* namespace.
*/
private def mergeActionWithPackageAndDispatch(method: HttpMethod,
Copy link
Member

Choose a reason for hiding this comment

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

@upgle Could you elaborate the reason to remove this method a little bit?
It would help people who are not familiar with this change like me to get the intention more easily.

Copy link
Member Author

Choose a reason for hiding this comment

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

If an action is resolved before it's dispatched, there is no way to know its original name in the activate method because it's already resolved.
So, I modified it to resolve inside the activate method after it has been dispatched.

override def activate(user: Identity, entityName: FullyQualifiedEntityName, env: Option[Parameters])(
    implicit transid: TransactionId) = {	    implicit transid: TransactionId)

@@ -253,7 +247,7 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with
'result ? false,
'timeout.as[FiniteDuration] ? WhiskActionsApi.maxWaitForBlockingActivation) { (blocking, result, waitOverride) =>
entity(as[Option[JsObject]]) { payload =>
getEntity(WhiskActionMetaData.get(entityStore, entityName.toDocId), Some {
getEntity(WhiskActionMetaData.resolveActionAndMergeParameters(entityStore, entityName), Some {
Copy link
Member Author

Choose a reason for hiding this comment

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

@style95 the action is resolved here after it's dispatched.

Copy link
Member

Choose a reason for hiding this comment

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

ok, this is the similar way which is taken for web action.

@@ -253,7 +247,7 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with
'result ? false,
'timeout.as[FiniteDuration] ? WhiskActionsApi.maxWaitForBlockingActivation) { (blocking, result, waitOverride) =>
entity(as[Option[JsObject]]) { payload =>
getEntity(WhiskActionMetaData.get(entityStore, entityName.toDocId), Some {
getEntity(WhiskActionMetaData.resolveActionAndMergeParameters(entityStore, entityName), Some {
Copy link
Member

Choose a reason for hiding this comment

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

ok, this is the similar way which is taken for web action.

@style95
Copy link
Member

style95 commented Apr 30, 2019

@rabbah Do you have any comments on this?

@style95
Copy link
Member

style95 commented May 7, 2019

I would merge this in 72 hours if there is no objection based on silent consent.

@style95 style95 merged commit 7a304c1 into apache:master May 13, 2019
BillZong pushed a commit to BillZong/openwhisk that referenced this pull request Nov 18, 2019
…e#4211)

* Add origin path

* Update document

* Apply review

* Update annotations and add a type decorator

* Refactor code

* Fix testcase

* Reformat code

* Refactor code

* Remove unused code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controller enhancement 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.

4 participants