Skip to content

Commit

Permalink
Actions should receive API_HOST not EDGE_HOST.
Browse files Browse the repository at this point in the history
Rename cli.api.host to whisk.api.host (which must include protocol if defined).
Add openwhisk to list of packages available to node actions.
  • Loading branch information
rabbah authored and Justin Berstler committed Dec 20, 2016
1 parent efa40d5 commit 68fccef
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ansible/templates/whisk.properties.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ whisk.version.buildno={{ docker_image_tag }}
whisk.ssl.cert={{ openwhisk_home }}/ansible/roles/nginx/files/openwhisk-cert.pem
whisk.ssl.key={{ openwhisk_home }}/ansible/roles/nginx/files/openwhisk-key.pem
whisk.ssl.challenge=openwhisk
whisk.api.host={{ whisk_api_host | default('https://' + (groups['edge'] | first)) }}

defaultLimits.actions.invokes.perMinute={{ defaultLimits.actions.invokes.perMinute }}
defaultLimits.actions.invokes.concurrent={{ defaultLimits.actions.invokes.concurrent }}
Expand All @@ -36,7 +37,6 @@ entitlement.host={{ groups["entitlement_servers"] | first }}
kafka.host={{ groups["kafka"]|first }}
loadbalancer.host={{ groups["controllers"]|first }}
router.host={{ groups["edge"]|first }}
cli.api.host={{ cli_api_host | default(groups['edge'] | first) }}
zookeeper.host={{ groups["kafka"]|first }}
invoker.hosts={{ groups["invokers"] | join(",") }}

Expand Down
7 changes: 2 additions & 5 deletions common/scala/src/main/scala/whisk/core/WhiskConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class WhiskConfig(
val invokerSerializeDockerOp = this(WhiskConfig.invokerSerializeDockerOp)
val invokerSerializeDockerPull = this(WhiskConfig.invokerSerializeDockerPull)

val wskApiHost = this(WhiskConfig.wskApiHost)
val controllerHost = this(WhiskConfig.controllerHostName) + ":" + this(WhiskConfig.controllerHostPort)
val controllerBlackboxFraction = this.getAsDouble(WhiskConfig.controllerBlackboxFraction, 0.10)

Expand Down Expand Up @@ -103,9 +104,6 @@ class WhiskConfig(
val entitlementHost = this(WhiskConfig.entitlementHostName) + ":" + this(WhiskConfig.entitlementHostPort)
val iamProviderHost = this(WhiskConfig.iamProviderHostName) + ":" + this(WhiskConfig.iamProviderHostPort)

val routerHost = this(WhiskConfig.routerHost)
val cliApiHost = this(WhiskConfig.cliApiHost)

val edgeDockerEndpoint = this(WhiskConfig.edgeDockerEndpoint)
val kafkaDockerEndpoint = this(WhiskConfig.kafkaDockerEndpoint)
val mainDockerEndpoint = this(WhiskConfig.mainDockerEndpoint)
Expand Down Expand Up @@ -233,8 +231,7 @@ object WhiskConfig extends Logging {
val invokerSerializeDockerOp = "invoker.serializeDockerOp"
val invokerSerializeDockerPull = "invoker.serializeDockerPull"

val routerHost = "router.host"
val cliApiHost = "cli.api.host"
val wskApiHost = "whisk.api.host"

val edgeDockerEndpoint = "edge.docker.endpoint"
val kafkaDockerEndpoint = "kafka.docker.endpoint"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ class ContainerPool(
}

private def getContainerEnvironment(): Map[String, String] = {
Map("__OW_API_HOST" -> config.edgeHost)
Map("__OW_API_HOST" -> config.wskApiHost)
}

private val defaultMaxIdle = 10
Expand Down Expand Up @@ -795,7 +795,7 @@ class ContainerPool(
object ContainerPool extends Logging {
def requiredProperties = Map(
selfDockerEndpoint -> "localhost",
edgeHostName -> null,
wskApiHost -> null,
dockerRegistry -> "",
dockerImagePrefix -> "",
dockerImageTag -> "latest",
Expand Down
3 changes: 1 addition & 2 deletions core/invoker/src/main/scala/whisk/core/invoker/Invoker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import whisk.common.ConsulClient
import whisk.common.ConsulKV.InvokerKeys
import whisk.connector.kafka.{ KafkaConsumerConnector, KafkaProducerConnector }
import whisk.core.WhiskConfig
import whisk.core.WhiskConfig.{ consulServer, dockerImagePrefix, dockerRegistry, edgeHost, kafkaHost, logsDir, servicePort, whiskVersion }
import whisk.core.WhiskConfig.{ consulServer, dockerImagePrefix, dockerRegistry, kafkaHost, logsDir, servicePort, whiskVersion }
import whisk.core.connector.{ ActivationMessage, CompletionMessage }
import whisk.core.container.{ BlackBoxContainerError, ContainerPool, Interval, RunResult, WhiskContainer, WhiskContainerError }
import whisk.core.dispatcher.{ Dispatcher, MessageHandler }
Expand Down Expand Up @@ -488,7 +488,6 @@ object Invoker {
WhiskActivationStore.requiredProperties ++
ContainerPool.requiredProperties ++
kafkaHost ++
edgeHost ++
consulServer ++
whiskVersion

Expand Down
2 changes: 1 addition & 1 deletion core/nodejs6Action/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ nano@6.2.0 \
node-uuid@1.4.7 \
nodemailer@2.6.4 \
oauth2-server@2.4.1 \
openwhisk@2.6.0 \
openwhisk@3.0.0 \
pkgcloud@1.4.0 \
process@0.11.9 \
pug@">=2.0.0-beta6 <2.0.1" \
Expand Down
2 changes: 1 addition & 1 deletion core/nodejsAction/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mustache@2.1.3 \
nano@5.10.0 \
node-uuid@1.4.2 \
oauth2-server@2.4.0 \
openwhisk@2.6.0 \
openwhisk@3.0.0 \
process@0.11.0 \
request@2.79.0 \
rimraf@2.5.1 \
Expand Down
2 changes: 1 addition & 1 deletion core/nodejsActionBase/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

var config = {
'port': 8080,
'edgeHost': process.env.__OW_API_HOST
'apiHost': process.env.__OW_API_HOST
};

var bodyParser = require('body-parser');
Expand Down
2 changes: 1 addition & 1 deletion core/nodejsActionBase/src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function NodeActionService(config, logger) {
}

function newWhiskContext(config, logger) {
return new whisk(config.edgeHost, logger);
return new whisk(config.apiHost, logger);
}

NodeActionService.getService = function(config, logger) {
Expand Down
8 changes: 0 additions & 8 deletions core/nodejsActionBase/src/whisk.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ var request = require('request');
*/
function Whisk(apihost, logger) {

// export __OW_API_HOST to environment
{
apihost = apihost || '';
var edgeHostParts = apihost.split(':');
var protocol = (edgeHostParts.length >= 2 && edgeHostParts[1] == '443') ? 'https' : 'http';
apihost = protocol + '://' + apihost;
}

this.apikey = "uninit_apikey";

var asyncSentinel = new function Async(){ async: true; };
Expand Down
2 changes: 2 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ The following packages are available to be used in the Node.js 6.9.1 environment
- node-uuid v1.4.7
- nodemailer v2.6.4
- oauth2-server v2.4.1
- openwhisk v3.0.0
- pkgcloud v1.4.0
- process v0.11.9
- pug v2.0.0-beta6
Expand Down Expand Up @@ -274,6 +275,7 @@ The following packages are available to be used in the Node.js 0.12.17 environme
- nano v5.10.0
- node-uuid v1.4.2
- oauth2-server v2.4.0
- openwhisk v3.0.0
- process v0.11.0
- request v2.79.0
- rimraf v2.5.1
Expand Down
4 changes: 4 additions & 0 deletions tests/src/common/WhiskProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public static String getRouterHost() {
return whiskProperties.getProperty("router.host");
}

public static String getApiHost() {
return whiskProperties.getProperty("whisk.api.host");
}

public static int getEdgeHostApiPort() {
return Integer.parseInt(whiskProperties.getProperty("edge.host.apiport"));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/whisk/core/cli/test/WskBasicUsageTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class WskBasicUsageTests
activation =>
activation.response.status shouldBe "success"
val fields = activation.response.result.get.convertTo[Map[String, String]]
fields("api_host") shouldBe WhiskProperties.getEdgeHost + ":" + WhiskProperties.getEdgeHostApiPort
fields("api_host") shouldBe WhiskProperties.getApiHost
fields("api_key") shouldBe wskprops.authKey
fields("namespace") shouldBe namespace
fields("action_name") shouldBe s"/$namespace/$name"
Expand Down

0 comments on commit 68fccef

Please sign in to comment.