You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/09/09 06:12:47 UTC

[GitHub] [openwhisk] jiangpengcheng opened a new issue #4615: key 'kind' does not exist

jiangpengcheng opened a new issue #4615: key 'kind' does not exist
URL: https://github.com/apache/openwhisk/issues/4615
 
 
   There will be a `key 'kind' does not exist` error while a `generateFallbackActivation` is used as the `generateFallbackActivation` won't add the `kind` annotation to `WhiskActivation`:
   
   ```scala
     private def generateFallbackActivation(msg: ActivationMessage, response: ActivationResponse): WhiskActivation = {
       val now = Instant.now
       val causedBy = if (msg.causedBySequence) {
         Some(Parameters(WhiskActivation.causedByAnnotation, JsString(Exec.SEQUENCE)))
       } else None
   
       WhiskActivation(
         activationId = msg.activationId,
         namespace = msg.user.namespace.name.toPath,
         subject = msg.user.subject,
         cause = msg.cause,
         name = msg.action.name,
         version = msg.action.version.getOrElse(SemVer()),
         start = now,
         end = now,
         duration = Some(0),
         response = response,
         annotations = {
           Parameters(WhiskActivation.pathAnnotation, JsString(msg.action.asString)) ++ causedBy
         })
     }
   ```
   
   but while send UserEvent, the `ActivationMessage.from` require the `kind` annotation:
   
   ```scala
     /** Constructs an "Activation" event from a WhiskActivation */
     def from(a: WhiskActivation): Try[Activation] = {
       for {
         // There are no sensible defaults for these fields, so they are required. They should always be there but there is
         // no static analysis to proof that so we're defensive here.
         fqn <- a.annotations.getAs[String](WhiskActivation.pathAnnotation)
         kind <- a.annotations.getAs[String](WhiskActivation.kindAnnotation)
       } yield {
         Activation(
           fqn,
           a.response.statusCode,
           a.duration.getOrElse(0),
           a.annotations.getAs[Long](WhiskActivation.waitTimeAnnotation).getOrElse(0),
           a.annotations.getAs[Long](WhiskActivation.initTimeAnnotation).getOrElse(0),
           kind,
           a.annotations.getAs[Boolean](WhiskActivation.conductorAnnotation).getOrElse(false),
           a.annotations
             .getAs[ActionLimits](WhiskActivation.limitsAnnotation)
             .map(_.memory.megabytes)
             .getOrElse(0),
           a.annotations.getAs[String](WhiskActivation.causedByAnnotation).toOption)
       }
     }
   ```
   
   since the `kind` data is not easy to get when generate fallback activation, is it ok to make it optional?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services