markusthoemmes closed pull request #3617: Move version information to
pureconfig and remove `whisk_version_name`.
URL: https://github.com/apache/incubator-openwhisk/pull/3617
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ansible/environments/distributed/group_vars/all
b/ansible/environments/distributed/group_vars/all
index 99e4441248..2056dec7dc 100755
--- a/ansible/environments/distributed/group_vars/all
+++ b/ansible/environments/distributed/group_vars/all
@@ -2,6 +2,9 @@
# license agreements; and to You under the Apache License, Version 2.0.
---
+
+environment_type: "distributed"
+
db_provider: CouchDB
db_port: 5984
db_protocol: http
@@ -10,7 +13,6 @@ db_password: couch_password
db_host: "{{ groups['db'] | first }}"
db_prefix: whisk_distributed_
-whisk_version_name: distributed
config_root_dir: /tmp/wskconf
whisk_logs_dir: /tmp/wsklogs
registry_storage_dir: "/"
diff --git a/ansible/environments/docker-machine/group_vars/all
b/ansible/environments/docker-machine/group_vars/all
index e3193adcf0..91471c8d2c 100644
--- a/ansible/environments/docker-machine/group_vars/all
+++ b/ansible/environments/docker-machine/group_vars/all
@@ -1,13 +1,14 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
contributor
# license agreements; and to You under the Apache License, Version 2.0.
-whisk_version_name: mac
config_root_dir: /Users/Shared/wskconf
whisk_logs_dir: /Users/Shared/wsklogs
docker_registry: ""
docker_dns: ""
runtimes_bypass_pull_for_local_images: true
+environment_type: "docker-machine"
+
env_hosts_dir: "{{ playbook_dir }}/environments/docker-machine"
# The whisk_api_localhost_name is used to configure nginx to permit vanity
URLs for web actions.
diff --git a/ansible/environments/local/group_vars/all
b/ansible/environments/local/group_vars/all
index d1bad6b5f6..338e10aae6 100755
--- a/ansible/environments/local/group_vars/all
+++ b/ansible/environments/local/group_vars/all
@@ -1,7 +1,6 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
contributor
# license agreements; and to You under the Apache License, Version 2.0.
-whisk_version_name: local
openwhisk_tmp_dir: "{{ lookup('env', 'OPENWHISK_TMP_DIR')|default('/tmp',
true) }}"
config_root_dir: "{{ openwhisk_tmp_dir }}/wskconf"
whisk_logs_dir: "{{ openwhisk_tmp_dir }}/wsklogs"
diff --git a/ansible/environments/vagrant/group_vars/all
b/ansible/environments/vagrant/group_vars/all
index a5da10dac3..614e0e22a1 100755
--- a/ansible/environments/vagrant/group_vars/all
+++ b/ansible/environments/vagrant/group_vars/all
@@ -1,7 +1,6 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
contributor
# license agreements; and to You under the Apache License, Version 2.0.
-whisk_version_name: local
openwhisk_tmp_dir: "{{ lookup('env', 'OPENWHISK_TMP_DIR')|default('/tmp',
true) }}"
config_root_dir: "{{ openwhisk_tmp_dir }}/wskconf"
whisk_logs_dir: "{{ openwhisk_tmp_dir }}/wsklogs"
diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index f4ceacb00b..b59aa3b3fe 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -22,7 +22,14 @@ exclude_logs_from: []
# whisk_api_localhost_name_default (last)
whisk_api_localhost_name_default: "localhost"
-hosts_dir: "{{ inventory_dir | default(env_hosts_dir) }}"
+# Type of your environment.
+# If you want to deploy everything on your local machine use 'local'.
+# If you use a docker-machine on a mac use 'docker-machine'
+# If you want to deploy Openwhisk to other machines use 'distributed'
+environmentInformation:
+ type: "{{ environment_type | default('local') }}"
+
+hosts_dir: "{{ inventory_dir | default(env_hosts_dir) }}"
whisk:
version:
diff --git a/ansible/logs.yml b/ansible/logs.yml
index 385843832f..73a84fae78 100644
--- a/ansible/logs.yml
+++ b/ansible/logs.yml
@@ -44,7 +44,7 @@
- name: set host flag when using docker remote API
set_fact:
docker_host_flag: "--host tcp://{{ ansible_host }}:{{ docker.port }}"
- when: whisk_version_name != "local"
+ when: environmentInformation.type != "local"
- name: get all docker containers
local_action: shell docker {{ docker_host_flag }} ps -a --format="{% raw
%}{{.Names}}{% endraw %}"
register: container_names
diff --git a/ansible/roles/controller/tasks/deploy.yml
b/ansible/roles/controller/tasks/deploy.yml
index 29dcc1b96a..2d48c4f8ac 100644
--- a/ansible/roles/controller/tasks/deploy.yml
+++ b/ansible/roles/controller/tasks/deploy.yml
@@ -124,9 +124,8 @@
"COMPONENT_NAME": "{{ controller_name }}"
"PORT": 8080
- "WHISK_VERSION_NAME": "{{ whisk_version_name }}"
- "WHISK_VERSION_DATE": "{{ whisk.version.date }}"
- "WHISK_VERSION_BUILDNO": "{{ docker.image.tag }}"
+ "CONFIG_whisk_info_date": "{{ whisk.version.date }}"
+ "CONFIG_whisk_info_buildNo": "{{ docker.image.tag }}"
"KAFKA_HOSTS": "{{ kafka_connect_string }}"
"CONFIG_whisk_kafka_replicationFactor":
diff --git a/ansible/roles/invoker/tasks/deploy.yml
b/ansible/roles/invoker/tasks/deploy.yml
index 98af399dee..2444bc5629 100644
--- a/ansible/roles/invoker/tasks/deploy.yml
+++ b/ansible/roles/invoker/tasks/deploy.yml
@@ -41,22 +41,22 @@
- name: "determine docker root dir on docker-machine"
uri: url="http://{{ ansible_host }}:{{ docker.port }}/info"
return_content=yes
register: dockerInfo_output
- when: whisk_version_name == "mac"
+ when: environmentInformation.type == 'docker-machine'
- set_fact:
dockerInfo: "{{ dockerInfo_output['json'] }}"
- when: whisk_version_name == "mac"
+ when: environmentInformation.type == "docker-machine"
- name: "determine docker root dir"
shell: echo -e "GET http:/v1.24/info HTTP/1.0\r\n" | nc -U
/var/run/docker.sock | grep "{"
args:
executable: /bin/bash
register: dockerInfo_output
- when: whisk_version_name != "mac"
+ when: environmentInformation.type != "docker-machine"
- set_fact:
dockerInfo: "{{ dockerInfo_output.stdout|from_json }}"
- when: whisk_version_name != "mac"
+ when: environmentInformation.type != "docker-machine"
- name: ensure invoker log directory is created with permissions
file:
@@ -89,11 +89,11 @@
- name: get running invoker information
uri: url="http://{{ ansible_host }}:{{ docker.port
}}/containers/json?filters={{ '{"name":[ "invoker" ],"ancestor":[ "invoker" ]}'
| urlencode }}" return_content=yes
register: invokerInfo_output
- when: whisk_version_name == "mac"
+ when: environmentInformation.type == "docker-machine"
- set_fact:
invokerInfo: "{{ invokerInfo_output['json'] }}"
- when: whisk_version_name == "mac"
+ when: environmentInformation.type == "docker-machine"
- name: "get invoker info"
shell: |
@@ -106,11 +106,11 @@
args:
executable: /bin/bash
register: invokerInfo_output
- when: whisk_version_name != "mac"
+ when: environmentInformation.type != "docker-machine"
- set_fact:
invokerInfo: "{{ invokerInfo_output.stdout|from_json }}"
- when: whisk_version_name != "mac"
+ when: environmentInformation.type != "docker-machine"
- name: determine if more than one invoker is running
fail:
diff --git a/ansible/templates/whisk.properties.j2
b/ansible/templates/whisk.properties.j2
index bc7ff36db8..f367bf0e38 100644
--- a/ansible/templates/whisk.properties.j2
+++ b/ansible/templates/whisk.properties.j2
@@ -7,9 +7,7 @@ testing.auth={{ openwhisk_home }}/ansible/files/auth.guest
vcap.services.file=
whisk.logs.dir={{ whisk_logs_dir }}
-whisk.version.name={{ whisk_version_name }}
-whisk.version.date={{ whisk.version.date }}
-whisk.version.buildno={{ docker.image.tag }}
+environment.type={{ environmentInformation.type }}
whisk.ssl.client.verification={{ nginx.ssl.verify_client }}
whisk.ssl.cert={{ nginx.ssl.path }}/{{ nginx.ssl.cert }}
whisk.ssl.key={{ nginx.ssl.path }}/{{ nginx.ssl.key }}
diff --git a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
index a239aa7818..fb20fda65b 100644
--- a/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
+++ b/common/scala/src/main/scala/whisk/core/WhiskConfig.scala
@@ -154,10 +154,6 @@ object WhiskConfig {
// in the invoker (they are part of the environment
// passed to the user container)
val edgeHostName = "edge.host"
- val whiskVersionDate = "whisk.version.date"
- val whiskVersionBuildno = "whisk.version.buildno"
-
- val whiskVersion = Map(whiskVersionDate -> null, whiskVersionBuildno -> null)
val invokerName = "invoker.name"
@@ -201,6 +197,7 @@ object WhiskConfig {
object ConfigKeys {
val cluster = "whisk.cluster"
val loadbalancer = "whisk.loadbalancer"
+ val buildInformation = "whisk.info"
val couchdb = "whisk.couchdb"
val kafka = "whisk.kafka"
diff --git
a/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
b/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
index 9791fa8bb8..e524060877 100644
--- a/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/RestAPIs.scala
@@ -17,38 +17,30 @@
package whisk.core.controller
-import scala.concurrent.ExecutionContext
-
-import scala.util.Failure
-import scala.util.Success
-import scala.util.Try
-
import akka.actor.ActorSystem
+import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.model.Uri
-import akka.http.scaladsl.server.Directives
-import akka.http.scaladsl.server.Route
import akka.http.scaladsl.model.headers._
-import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
+import akka.http.scaladsl.server.{Directives, Route}
import akka.stream.ActorMaterializer
-
-import spray.json._
+import pureconfig.loadConfigOrThrow
import spray.json.DefaultJsonProtocol._
-import whisk.core.database.CacheChangeNotification
-import whisk.core.WhiskConfig
-import whisk.core.WhiskConfig.whiskVersionBuildno
-import whisk.core.WhiskConfig.whiskVersionDate
-import whisk.common.Logging
-import whisk.common.TransactionId
+import spray.json._
+import whisk.common.{Logging, TransactionId}
import whisk.core.containerpool.logging.LogStore
+import whisk.core.database.CacheChangeNotification
import whisk.core.entitlement._
-import whisk.core.entity._
import whisk.core.entity.ActivationId.ActivationIdGenerator
-import whisk.core.entity.WhiskAuthStore
+import whisk.core.entity._
import whisk.core.entity.types._
import whisk.core.loadBalancer.LoadBalancer
+import whisk.core.{ConfigKeys, WhiskConfig}
import whisk.http.Messages
+import scala.concurrent.ExecutionContext
+import scala.util.{Failure, Success, Try}
+
/**
* Abstract class which provides basic Directives which are used to construct
route structures
* which are common to all versions of the Rest API.
@@ -86,14 +78,12 @@ protected[controller] class SwaggerDocs(apipath: Uri.Path,
doc: String)(implicit
protected[controller] object RestApiCommons {
def requiredProperties =
Map(WhiskConfig.servicePort -> 8080.toString) ++
- WhiskConfig.whiskVersion ++
EntitlementProvider.requiredProperties ++
WhiskActionsApi.requiredProperties
import akka.http.scaladsl.model.HttpCharsets
import akka.http.scaladsl.model.MediaTypes.`application/json`
- import akka.http.scaladsl.unmarshalling.FromEntityUnmarshaller
- import akka.http.scaladsl.unmarshalling.Unmarshaller
+ import akka.http.scaladsl.unmarshalling.{FromEntityUnmarshaller,
Unmarshaller}
/**
* Extract an empty entity into a JSON object. This is useful for the
@@ -162,6 +152,8 @@ protected[controller] trait RespondWithHeaders extends
Directives {
val sendCorsHeaders = respondWithHeaders(allowOrigin, allowHeaders)
}
+case class WhiskInformation(buildNo: String, date: String)
+
class RestAPIVersion(config: WhiskConfig, apiPath: String, apiVersion: String)(
implicit val activeAckTopicIndex: InstanceId,
implicit val actorSystem: ActorSystem,
@@ -181,6 +173,7 @@ class RestAPIVersion(config: WhiskConfig, apiPath: String,
apiVersion: String)(
with RespondWithHeaders {
implicit val executionContext = actorSystem.dispatcher
implicit val authStore = WhiskAuthStore.datastore()
+ val whiskInfo =
loadConfigOrThrow[WhiskInformation](ConfigKeys.buildInformation)
def prefix = pathPrefix(apiPath / apiVersion)
@@ -193,8 +186,8 @@ class RestAPIVersion(config: WhiskConfig, apiPath: String,
apiVersion: String)(
"description" -> "OpenWhisk API".toJson,
"api_version" -> SemVer(1, 0, 0).toJson,
"api_version_path" -> apiVersion.toJson,
- "build" -> whiskConfig(whiskVersionDate).toJson,
- "buildno" -> whiskConfig(whiskVersionBuildno).toJson,
+ "build" -> whiskInfo.date.toJson,
+ "buildno" -> whiskInfo.buildNo.toJson,
"swagger_paths" -> JsObject("ui" -> s"/$swaggeruipath".toJson,
"api-docs" -> s"/$swaggerdocpath".toJson)))
}
diff --git a/tests/src/test/scala/actionContainers/ActionContainer.scala
b/tests/src/test/scala/actionContainers/ActionContainer.scala
index e0a2cafada..b9398cda8a 100644
--- a/tests/src/test/scala/actionContainers/ActionContainer.scala
+++ b/tests/src/test/scala/actionContainers/ActionContainer.scala
@@ -117,7 +117,7 @@ object ActionContainer {
.orElse(sys.env.get("DOCKER_HOST"))
.orElse {
// Check if we are running on docker-machine env.
-
Option(WhiskProperties.getProperty("whisk.version.name")).filter(_.toLowerCase.contains("mac")).map
{
+
Option(WhiskProperties.getProperty("environment.type")).filter(_.toLowerCase.contains("docker-machine")).map
{
case _ => s"tcp://${WhiskProperties.getMainDockerEndpoint}"
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services