-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
3d632f3
to
5d6d2ef
Compare
originPath
annotation to record an action path not resolved
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
I wonder if instead of modifying the Action type, we can add an alias to I would use This is a suggestion for discussion. |
As you mentioned, it would be better to add an alias to |
2a748b2
to
ba5bcc8
Compare
@rabbah this {
"activationId": "f4250bb2721d4e4ca50bb2721d2e4cdd",
"annotations": [
{
"key": "binding",
"value": "whisk.system/p2"
},
{
"key": "path",
"value": "guest/p1/hello"
},
]
} |
originPath
annotation to record an action path not resolvedbinding
annotation to record an action path not resolved
@rabbah |
Thanks for the nudge. Will get on it. |
ba5bcc8
to
e8c06a2
Compare
conflict has been resolved 😃 |
There was a problem hiding this 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 = |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 thewhisk.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"
},
...
cba6677
to
848dbea
Compare
Any update on this PR? |
Sorry. I should resolve a conflict. I can handle today. |
3044b13
to
2e79409
Compare
* @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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
@rabbah Do you have any comments on this? |
I would merge this in 72 hours if there is no objection based on silent consent. |
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
: pkg1action
: pkg1/action1package
pkg2 bind pkg1package
pkg3 bind pkg1If user invokes the
pkg2/action1
action and thepkg3/action1
action, all path annotations of invoked action in binding packages are saved as namespace/pkg1/action1.Suggestion
So i added an annotation to distinguish between resolved action path and invoked action path and opend this PR.
Related issue and scope
My changes affect the following components
Types of changes
Checklist: