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

Provide environment at init time #4722

Merged
merged 7 commits into from
Nov 19, 2019

Conversation

upgle
Copy link
Member

@upgle upgle commented Nov 11, 2019

Description

As discussed here, it changes the container proxy to provide an environment at init time (/init).

But I couldn't move the entire context from /run to /init to maintain backward compatibility.

1. /init

Put environment variables in the env field. and runtimes can use this value.

{
  "value": {
    "name" : String,
    "main" : String,
    "code" : String,
    "binary": Boolean,
    "env": Map[String, String] = {
       "__OW_NAMESPACE",
       "__OW_ACTION_NAME",
       "__OW_ACTIVATION_ID",
       "__OW_TRANSACTION_ID",
       "__OW_DEADLINE"
    }
  }
}

2. /run

The namespace, action_name, activation_id, transaction_id, and deadline fields are uppercased and prefixed with "__OW_" by runtimes [1].

  • namespace -> __OW_NAMESPACE
  • action_name -> __OW_ACTION_NAME

I think these fields cannot be removed due to backward compatibility.

This is a draft pull request, please let me know if there is a better way.

ref

[1] https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md#what-the-launcher-needs-to-do

Related issue and scope

https://lists.apache.org/thread.html/ef18f833671a3266d4cde3bf4eaff379596d03b3e147a785a9b06941@%3Cdev.openwhisk.apache.org%3E

My changes affect the following components

  • API
  • Invoker
  • Tests
  • Documentation

Types of changes

  • 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.

@codecov-io
Copy link

codecov-io commented Nov 11, 2019

Codecov Report

Merging #4722 into master will decrease coverage by 6.62%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4722      +/-   ##
==========================================
- Coverage      85%   78.37%   -6.63%     
==========================================
  Files         198      198              
  Lines        8841     8846       +5     
  Branches      614      619       +5     
==========================================
- Hits         7515     6933     -582     
- Misses       1326     1913     +587
Impacted Files Coverage Δ
.../openwhisk/core/containerpool/ContainerProxy.scala 93.06% <100%> (+0.1%) ⬆️
...core/database/cosmosdb/RxObservableImplicits.scala 0% <0%> (-100%) ⬇️
...enwhisk/connector/kafka/KamonMetricsReporter.scala 0% <0%> (-100%) ⬇️
...e/database/cosmosdb/cache/ChangeFeedConsumer.scala 0% <0%> (-100%) ⬇️
...ore/database/cosmosdb/cache/CacheInvalidator.scala 0% <0%> (-100%) ⬇️
...core/database/cosmosdb/CosmosDBArtifactStore.scala 0% <0%> (-96.23%) ⬇️
...sk/core/database/cosmosdb/CosmosDBViewMapper.scala 0% <0%> (-93.8%) ⬇️
...tabase/cosmosdb/cache/CacheInvalidatorConfig.scala 0% <0%> (-92.31%) ⬇️
...e/database/cosmosdb/cache/KafkaEventProducer.scala 0% <0%> (-77.78%) ⬇️
...whisk/core/database/cosmosdb/CosmosDBSupport.scala 0% <0%> (-74.08%) ⬇️
... and 14 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 2929893...48d14e5. Read the comment docs.

@rabbah
Copy link
Member

rabbah commented Nov 12, 2019

This LGTM.

@upgle upgle marked this pull request as ready for review November 13, 2019 02:23
Copy link
Member

@style95 style95 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@chetanmeh chetanmeh left a comment

Choose a reason for hiding this comment

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

Thanks @upgle for this 🎉

At times for some web actions I needed the namespace at init time to compute some routing url and then realized that they were only available at run time. With this doing such init time work would be easier

@style95 style95 merged commit d605acf into apache:master Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants