Addition of a reliable REST service offered directly off the proxy
rather than requiring a server process. Swagger isn't supported yet.
REST services are offered for both http (port 8882) and https (port
8443) both of which are configurable. Also change the network being used
for voltha-net because (in Ciena) the 10.0.0.0 network is problematic
since it's the primary network used internally which was causing IP
address conflicts. Corrected some errors in the swarm-stop file.
Change-Id: Ic5cbee20324e268b0178312741b2700cdf4eb877
diff --git a/envoy/Makefile b/envoy/Makefile
new file mode 100644
index 0000000..b19707c
--- /dev/null
+++ b/envoy/Makefile
@@ -0,0 +1,73 @@
+#
+# Copyright 2017 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Makefile to build all protobuf and gRPC related artifacts
+
+ifeq ($(VOLTHA_BASE)_set,_set)
+ $(error To get started, please source the env.sh file from Voltha top level directory)
+endif
+
+default: build
+
+PROTO_PATH := ../voltha/protos
+PROTO_FILES := $(PROTO_PATH)/*.proto $(PROTO_PATH)/third_party/google/api/*proto
+PROTO_DESC_FILE := proto.pb
+
+PROTOC_PREFIX := /usr/local
+PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib
+
+PROTOC := $(PROTOC_PREFIX)/bin/protoc
+
+PROTOC_VERSION := "3.0.2"
+PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
+PROTOC_DIR := protobuf-$(PROTOC_VERSION)
+PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
+PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL)
+PROTOC_BUILD_TMP_DIR := "/tmp/protobuf-build-$(shell uname -s | tr '[:upper:]' '[:lower:]')"
+
+build: $(PROTOC)
+ LD_LIBRARY_PATH=$(PROTOC_LIBDIR) $(PROTOC) -I $(PROTO_PATH)/third_party/ -I $(PROTO_PATH) --include_imports --include_source_info --descriptor_set_out=$(PROTO_DESC_FILE) $(PROTO_FILES)
+
+
+clean:
+ rm -f $(PROTO_DESC_FILE)
+
+$(PROTOC):
+ @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ @echo "It looks like you don't have protocol buffer tools installed."
+ @echo "To install the protocol buffer toolchain, you can run:"
+ @echo " make install-protoc"
+ @echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+
+install-protoc: $(PROTOC)
+ @echo "Downloading and installing protocol buffer support."
+ @echo "Installation will require sodo priviledges"
+ @echo "This will take a few minutes."
+ mkdir -p $(PROTOC_BUILD_TMP_DIR)
+ @echo "We ask for sudo credentials now so we can install at the end"; \
+ sudo echo "Thanks"; \
+ cd $(PROTOC_BUILD_TMP_DIR); \
+ wget $(PROTOC_DOWNLOAD_URI); \
+ tar xzvf $(PROTOC_TARBALL); \
+ cd $(PROTOC_DIR); \
+ ./configure --prefix=$(PROTOC_PREFIX); \
+ make; \
+ sudo make install
+
+uninstall-protoc:
+ cd $(PROTOC_BUILD_TMP_DIR)/$(PROTOC_DIR); \
+ sudo make uninstall
+
diff --git a/envoy/front-proxy/voltha-grpc-proxy-no-http.template.json b/envoy/front-proxy/voltha-grpc-proxy-no-http.template.json
new file mode 100644
index 0000000..7b7461f
--- /dev/null
+++ b/envoy/front-proxy/voltha-grpc-proxy-no-http.template.json
@@ -0,0 +1,178 @@
+{
+ "listeners": [
+ {
+ "address": "tcp://0.0.0.0:{{- .HttpsPort }}",
+ "ssl_context": {
+ "cert_chain_file": "/envoy/pki/voltha.crt",
+ "private_key_file": "/envoy/pki/voltha.key",
+ "ca_cert_file": "/envoy/pik/voltha-CA.pem"
+ },
+ "filters": [
+ {
+ "type": "read",
+ "name": "http_connection_manager",
+ "config": {
+ "codec_type": "http1",
+ "stat_prefix": "ingress_http1",
+ "access_log": [
+ {
+ "path": "/envoy/voltha_access1_log.log"
+ }
+ ],
+ "route_config": {
+ "virtual_hosts": [
+ {
+ "name": "backend2",
+ "domains": ["*"],
+ "routes": [
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+ "cluster": "voltha-grpc-RR"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/schema.SchemaService",
+ "cluster": "voltha-grpc"
+ }
+ ]
+ }
+ ]
+ },
+ "filters": [
+ {
+ "type": "both",
+ "name": "grpc_json_transcoder",
+ "config": {
+ "proto_descriptor": "/envoy/proto.pb",
+ "services": ["voltha.VolthaGlobalService"],
+ "print_options": {
+ "add_whitespace": false,
+ "always_print_primitive_fields": false,
+ "always_print_enums_as_ints": false,
+ "preserve_proto_field_names": false
+
+ }
+ }
+ },
+ {
+ "type": "both",
+ "name": "grpc_http1_bridge",
+ "config": {}
+ },
+ {
+ "type": "decoder",
+ "name": "router",
+ "config": {}
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "address": "tcp://0.0.0.0:{{- .GrpcPort }}",
+ "filters": [
+ {
+ "type": "read",
+ "name": "http_connection_manager",
+ "config": {
+ "codec_type": "http2",
+ "stat_prefix": "ingress_http2",
+ "access_log": [
+ {
+ "path": "/envoy/voltha_access2_log.log"
+ }
+ ],
+ "route_config": {
+ "virtual_hosts": [
+ {
+ "name": "backend",
+ "domains": ["*"],
+ "routes": [
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+ "cluster": "voltha-grpc-RR"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/schema.SchemaService",
+ "cluster": "voltha-grpc"
+ }
+ ]
+ }
+ ]
+ },
+ "filters": [
+ {
+ "type": "decoder",
+ "name": "router",
+ "config": {}
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ],
+ "admin": {
+ "access_log_path": "/envoy/access.log",
+ "address": "tcp://0.0.0.0:8001"
+ },
+ "cluster_manager": {
+ "clusters": [
+ {
+ "name": "voltha-grpc",
+ "connect_timeout_ms": 250,
+ "type": "static",
+ "lb_type": "round_robin",
+ "features": "http2",
+ "hosts": [
+ {
+ "url": "tcp://{{- .VolthaVip }}"
+ }
+ ]
+ },
+ {
+ "name": "voltha-grpc-RR",
+ "connect_timeout_ms": 250,
+ "type": "static",
+ "lb_type": "round_robin",
+ "features": "http2",
+ "hosts": [
+ {{block "addrlist" .VolthaRR}}
+ {{- range .}}
+ {{- if isFirst}}
+ {{- printf "{\"url\": \"tcp://%s\"}" . }}
+ {{- else }}
+ {{- printf ",{\"url\": \"tcp://%s\"}" . }}
+ {{- end }}
+ {{- end}}
+ {{- end}}
+ ]
+ }
+ ]
+ }
+}
+
diff --git a/envoy/front-proxy/voltha-grpc-proxy-no-https.template.json b/envoy/front-proxy/voltha-grpc-proxy-no-https.template.json
new file mode 100644
index 0000000..7448323
--- /dev/null
+++ b/envoy/front-proxy/voltha-grpc-proxy-no-https.template.json
@@ -0,0 +1,173 @@
+{
+ "listeners": [
+ {
+ "address": "tcp://0.0.0.0:{{- .HttpPort }}",
+ "filters": [
+ {
+ "type": "read",
+ "name": "http_connection_manager",
+ "config": {
+ "codec_type": "http1",
+ "stat_prefix": "ingress_http1",
+ "access_log": [
+ {
+ "path": "/envoy/voltha_access1_log.log"
+ }
+ ],
+ "route_config": {
+ "virtual_hosts": [
+ {
+ "name": "backend2",
+ "domains": ["*"],
+ "routes": [
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+ "cluster": "voltha-grpc-RR"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/schema.SchemaService",
+ "cluster": "voltha-grpc"
+ }
+ ]
+ }
+ ]
+ },
+ "filters": [
+ {
+ "type": "both",
+ "name": "grpc_json_transcoder",
+ "config": {
+ "proto_descriptor": "/envoy/proto.pb",
+ "services": ["voltha.VolthaGlobalService"],
+ "print_options": {
+ "add_whitespace": false,
+ "always_print_primitive_fields": false,
+ "always_print_enums_as_ints": false,
+ "preserve_proto_field_names": false
+
+ }
+ }
+ },
+ {
+ "type": "both",
+ "name": "grpc_http1_bridge",
+ "config": {}
+ },
+ {
+ "type": "decoder",
+ "name": "router",
+ "config": {}
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "address": "tcp://0.0.0.0:{{- .GrpcPort }}",
+ "filters": [
+ {
+ "type": "read",
+ "name": "http_connection_manager",
+ "config": {
+ "codec_type": "http2",
+ "stat_prefix": "ingress_http2",
+ "access_log": [
+ {
+ "path": "/envoy/voltha_access2_log.log"
+ }
+ ],
+ "route_config": {
+ "virtual_hosts": [
+ {
+ "name": "backend",
+ "domains": ["*"],
+ "routes": [
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+ "cluster": "voltha-grpc-RR"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/schema.SchemaService",
+ "cluster": "voltha-grpc"
+ }
+ ]
+ }
+ ]
+ },
+ "filters": [
+ {
+ "type": "decoder",
+ "name": "router",
+ "config": {}
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ],
+ "admin": {
+ "access_log_path": "/envoy/access.log",
+ "address": "tcp://0.0.0.0:8001"
+ },
+ "cluster_manager": {
+ "clusters": [
+ {
+ "name": "voltha-grpc",
+ "connect_timeout_ms": 250,
+ "type": "static",
+ "lb_type": "round_robin",
+ "features": "http2",
+ "hosts": [
+ {
+ "url": "tcp://{{- .VolthaVip }}"
+ }
+ ]
+ },
+ {
+ "name": "voltha-grpc-RR",
+ "connect_timeout_ms": 250,
+ "type": "static",
+ "lb_type": "round_robin",
+ "features": "http2",
+ "hosts": [
+ {{block "addrlist" .VolthaRR}}
+ {{- range .}}
+ {{- if isFirst}}
+ {{- printf "{\"url\": \"tcp://%s\"}" . }}
+ {{- else }}
+ {{- printf ",{\"url\": \"tcp://%s\"}" . }}
+ {{- end }}
+ {{- end}}
+ {{- end}}
+ ]
+ }
+ ]
+ }
+}
+
diff --git a/envoy/front-proxy/voltha-grpc-proxy.template.json b/envoy/front-proxy/voltha-grpc-proxy.template.json
index 469ab18..3ade94f 100644
--- a/envoy/front-proxy/voltha-grpc-proxy.template.json
+++ b/envoy/front-proxy/voltha-grpc-proxy.template.json
@@ -1,7 +1,162 @@
{
"listeners": [
{
- "address": "tcp://0.0.0.0:50555",
+ "address": "tcp://0.0.0.0:{{- .HttpsPort }}",
+ "ssl_context": {
+ "cert_chain_file": "/envoy/voltha.crt",
+ "private_key_file": "/envoy/voltha.key",
+ "ca_cert_file": "/envoy/voltha-CA.pem"
+ },
+ "filters": [
+ {
+ "type": "read",
+ "name": "http_connection_manager",
+ "config": {
+ "codec_type": "http1",
+ "stat_prefix": "ingress_http1",
+ "access_log": [
+ {
+ "path": "/envoy/voltha_access1_log.log"
+ }
+ ],
+ "route_config": {
+ "virtual_hosts": [
+ {
+ "name": "backend2",
+ "domains": ["*"],
+ "routes": [
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+ "cluster": "voltha-grpc-RR"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/schema.SchemaService",
+ "cluster": "voltha-grpc"
+ }
+ ]
+ }
+ ]
+ },
+ "filters": [
+ {
+ "type": "both",
+ "name": "grpc_json_transcoder",
+ "config": {
+ "proto_descriptor": "/envoy/proto.pb",
+ "services": ["voltha.VolthaGlobalService"],
+ "print_options": {
+ "add_whitespace": false,
+ "always_print_primitive_fields": false,
+ "always_print_enums_as_ints": false,
+ "preserve_proto_field_names": false
+
+ }
+ }
+ },
+ {
+ "type": "both",
+ "name": "grpc_http1_bridge",
+ "config": {}
+ },
+ {
+ "type": "decoder",
+ "name": "router",
+ "config": {}
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "address": "tcp://0.0.0.0:{{- .HttpPort }}",
+ "filters": [
+ {
+ "type": "read",
+ "name": "http_connection_manager",
+ "config": {
+ "codec_type": "http1",
+ "stat_prefix": "ingress_http1",
+ "access_log": [
+ {
+ "path": "/envoy/voltha_access1_log.log"
+ }
+ ],
+ "route_config": {
+ "virtual_hosts": [
+ {
+ "name": "backend2",
+ "domains": ["*"],
+ "routes": [
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService/CreateDevice",
+ "cluster": "voltha-grpc-RR"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.VolthaGlobalService",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/voltha.",
+ "cluster": "voltha-grpc"
+ },
+ {
+ "timeout_ms": 0,
+ "prefix": "/schema.SchemaService",
+ "cluster": "voltha-grpc"
+ }
+ ]
+ }
+ ]
+ },
+ "filters": [
+ {
+ "type": "both",
+ "name": "grpc_json_transcoder",
+ "config": {
+ "proto_descriptor": "/envoy/proto.pb",
+ "services": ["voltha.VolthaGlobalService"],
+ "print_options": {
+ "add_whitespace": false,
+ "always_print_primitive_fields": false,
+ "always_print_enums_as_ints": false,
+ "preserve_proto_field_names": false
+
+ }
+ }
+ },
+ {
+ "type": "both",
+ "name": "grpc_http1_bridge",
+ "config": {}
+ },
+ {
+ "type": "decoder",
+ "name": "router",
+ "config": {}
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "address": "tcp://0.0.0.0:{{- .GrpcPort }}",
"filters": [
{
"type": "read",
@@ -11,7 +166,7 @@
"stat_prefix": "ingress_http2",
"access_log": [
{
- "path": "/envoy/voltha_access_log.log"
+ "path": "/envoy/voltha_access2_log.log"
}
],
"route_config": {
diff --git a/envoy/go/envoyd/envoyd.go b/envoy/go/envoyd/envoyd.go
index 57bd446..66fe628 100644
--- a/envoy/go/envoyd/envoyd.go
+++ b/envoy/go/envoyd/envoyd.go
@@ -37,6 +37,10 @@
type EnvoyConfigVars struct {
VolthaVip string
VolthaRR []string
+ vcorePort string
+ HttpPort string
+ HttpsPort string
+ GrpcPort string
}
type VolthaClusterEntry struct {
@@ -52,10 +56,18 @@
// Command line parameters
assignmentKey string
envoyConfigTemplate string
+ envoyConfigTemplateBoth string
+ envoyConfigTemplateNoHttps string
+ envoyConfigTemplateNoHttp string
+ envoyHttpPort string
+ envoyHttpsPort string
+ httpDisabled bool
+ httpsDisabled bool
envoyConfig string
vcoreSvcName string
consulSvcName string
vcorePort string
+ envoyGrpcPort string
consulPort string
retries int
waitTime int
@@ -75,6 +87,14 @@
// Command line parameters
assignmentKey: "service/voltha/data/core/assignment",
envoyConfigTemplate: "/envoy/voltha-grpc-proxy.template.json",
+ envoyConfigTemplateBoth: "/envoy/voltha-grpc-proxy.template.json",
+ envoyConfigTemplateNoHttps: "/envoy/voltha-grpc-proxy-no-https.template.json",
+ envoyConfigTemplateNoHttp: "/envoy/voltha-grpc-proxy-no-http.template.json",
+ envoyHttpsPort: "8443",
+ envoyHttpPort: "8882",
+ envoyGrpcPort: "50555",
+ httpDisabled: false,
+ httpsDisabled: false,
envoyConfig: "/envoy/voltha-grpc-proxy.json",
//envoyLogFile: "/envoy/voltha_access_log.log",
vcoreSvcName: "vcore",
@@ -178,20 +198,17 @@
stderr, err := cmd.StderrPipe()
if err != nil {
- log.Printf("Couldn't attach to stderr running envoy command")
- panic(err)
+ log.Fatal("Couldn't attach to stderr running envoy command: %s", err.Error())
}
stdout, err := cmd.StdoutPipe()
if err != nil {
- log.Printf("Couldn't attach to stdout running envoy command")
- panic(err)
+ log.Fatal("Couldn't attach to stdout running envoy command: %s", err.Error())
}
so := bufio.NewReader(stdout)
se := bufio.NewReader(stderr)
if err = cmd.Start(); err != nil {
- log.Fatal("Error starting envoy")
- panic(err)
+ log.Fatal("Error starting envoy: %s", err.Error())
}
log.Printf("Envoy(%d) started", curEpoch)
soEof := false
@@ -210,8 +227,7 @@
soEof = true
}
} else if err != nil {
- log.Printf("Attempt to read envoy standard out failed")
- panic(err)
+ log.Fatal("Attempt to read envoy standard out failed: %s", err.Error())
} else if count > 0 {
log.Printf("ENVOY_LOG(%d)(%d): %s",curEpoch,count,string(data))
}
@@ -224,16 +240,14 @@
seEof = true
}
} else if err != nil {
- log.Fatal("Attempt to read envoy standard err failed")
- panic(err)
+ log.Fatal("Attempt to read envoy standard err failed: %s", err.Error())
} else if count > 0 {
log.Printf("ENVOY_LOG(%d)(%d): %s",curEpoch,count,string(data))
}
}
log.Printf("Waiting on envoy %d to exit", curEpoch)
if err = cmd.Wait(); err != nil {
- log.Printf("Envoy %d exited with an unexpected exit code", curEpoch)
- panic(err)
+ log.Fatal("Envoy %d exited with an unexpected exit code: %s", curEpoch, err.Error())
}
log.Printf("Envoy %d exited", curEpoch)
// Check if this was the primary envoy, if so
@@ -262,27 +276,23 @@
// Slurp up the template file.
tplt, err := ioutil.ReadFile(ec.envoyConfigTemplate)
if err != nil {
- log.Fatal("ERROR reading the template file, aborting")
- panic(err)
+ log.Fatal("ERROR reading the template file, aborting: %s", err.Error())
}
//fmt.Println(string(tplt))
configTemplate, err := template.New("config").Funcs(funcs).Parse(string(tplt));
if err != nil {
- log.Fatal("Unexpected error loading the Envoy template, aborting")
- panic(err)
+ log.Fatal("Unexpected error loading the Envoy template, aborting: %s", err.Error())
}
outFile,err := os.Create(ec.envoyConfig)
if err != nil {
- log.Fatal("Unexpected error opening the Envoy config file for write, aborting")
- panic(err)
+ log.Fatal("Unexpected error opening the Envoy config file for write, aborting: %s", err.Error())
}
if err = configTemplate.Execute(outFile, ecv); err != nil {
- log.Fatal("Unexpected error executing the Envoy config template, aborting")
- panic(err)
+ log.Fatal("Unexpected error executing the Envoy config template, aborting: %s", err.Error())
}
//cfgFile, err := ioutil.ReadFile(ec.envoyConfig)
//if err != nil {
- // log.Fatal("ERROR reading the config file, aborting")
+ // log.Fatal("ERROR reading the config file, aborting: %s", err.Error())
// panic(err)
//}
//fmt.Println(string(cfgFile))
@@ -298,8 +308,7 @@
//err = json.Unmarshal(jsonString, &f)
err = json.Unmarshal(jsonString, &f)
if err != nil {
- log.Fatal("Unable to parse json record %s", jsonString)
- panic(err)
+ log.Fatal("Unable to parse json record %s : %s", jsonString, err.Error())
} else {
m := f.(map[string]interface{})
for k, v := range m {
@@ -343,6 +352,9 @@
func (ec * EnvoyControl) prepareEnvoyConfig(kvp * consulapi.KVPair, ecv * EnvoyConfigVars) (err error) {
var vCluster []VolthaClusterEntry
+ ecv.HttpPort = ec.envoyHttpPort
+ ecv.HttpsPort = ec.envoyHttpsPort
+ ecv.GrpcPort = ec.envoyGrpcPort
ecv.VolthaVip = ec.ipAddrs[ec.vcoreSvcName][0] + ":" + ec.vcorePort
// Extract all values from the KV record
@@ -358,8 +370,7 @@
ecv.VolthaRR = append(ecv.VolthaRR, vCluster[i].Host + ":" + ec.vcorePort)
}
} else {
- log.Fatal("Couldn't parse the KV record %s", string(kvp.Value))
- panic(err)
+ log.Fatal("Couldn't parse the KV record %s: %s", string(kvp.Value), err.Error())
}
return
}
@@ -369,8 +380,7 @@
var ecv EnvoyConfigVars
if err = ec.prepareEnvoyConfig(kvp, &ecv); err != nil {
- log.Fatal("Error preparing envoy config variables, aborting")
- panic(err)
+ log.Fatal("Error preparing envoy config variables, aborting: %s", err.Error())
}
// Now that we have the data loaded, update the envoy config and start envoy
@@ -400,8 +410,7 @@
kvp, meta, err = kv.Get(ec.assignmentKey, qo)
}
if i == ec.retries {
- log.Printf("Failed to read the assignment key after %d retries, aborting", ec.retries)
- panic(err)
+ log.Fatal("Failed to read the assignment key after %d retries, aborting: %s", ec.retries, err.Error())
}
}
return
@@ -427,8 +436,7 @@
}
kvp, meta, err = ec.readConsulKey(ec.assignmentKey, &qo)
if err != nil {
- log.Printf("Unable to read assignment consul key")
- panic(err)
+ log.Fatal("Unable to read assignment consul key: %s\n", err.Error())
} else {
log.Println(string(kvp.Value))
log.Printf("meta.LastIndex = %d", meta.LastIndex)
@@ -449,6 +457,15 @@
flag.StringVar(&( ec.envoyConfigTemplate),"envoy-cfg-template", ec.envoyConfigTemplate,
"The path to envoy's configuration template")
+ flag.StringVar(&( ec.envoyConfigTemplateBoth),"envoy-cfg-template-both", ec.envoyConfigTemplateBoth,
+ "The path to envoy's configuration template for both http and https")
+
+ flag.StringVar(&( ec.envoyConfigTemplateNoHttps),"envoy-cfg-template-no-https", ec.envoyConfigTemplateNoHttps,
+ "The path to envoy's configuration template with no https")
+
+ flag.StringVar(&( ec.envoyConfigTemplateNoHttp),"envoy-cfg-template-no-http", ec.envoyConfigTemplateNoHttp,
+ "The path to envoy's configuration template with no http")
+
flag.StringVar(&(ec.envoyConfig), "envoy-config", ec.envoyConfig,
"The path to envoy's configuration file" )
@@ -464,31 +481,53 @@
flag.StringVar(&(ec.consulPort), "consul-port", ec.consulPort,
"The port where the consul service api can be found")
+ flag.StringVar(&(ec.envoyHttpPort), "http-port", ec.envoyHttpPort,
+ "The port where the http front-end is served ")
+
+ flag.StringVar(&(ec.envoyHttpsPort), "https-port", ec.envoyHttpsPort,
+ "The port where the https front-end is served ")
+
+ flag.StringVar(&(ec.envoyGrpcPort), "grpc-port", ec.envoyGrpcPort,
+ "The port where the grpc front-end is served ")
+
flag.IntVar(&(ec.retries), "retries", ec.retries,
"The number of times to retry name lookups and connect requests before failing")
flag.IntVar(&(ec.waitTime), "wait-time", ec.waitTime,
"The number of seconds to wait between retries")
+ flag.BoolVar(&(ec.httpDisabled), "disable-http", ec.httpDisabled,
+ "Disables the http front-end")
+
+ flag.BoolVar(&(ec.httpsDisabled), "disable-https", ec.httpsDisabled,
+ "Disables ths https front-end")
+
flag.Parse()
}
func (ec * EnvoyControl) Initialize() (err error) {
// Resolve consul's virtual ip address
if err = ec.resolveServiceAddress(ec.consulSvcName); err != nil {
- log.Fatal("Can't proceed without consul's vIP address")
- panic(err)
+ log.Fatal("Can't proceed without consul's vIP address: %s", err.Error())
}
// Resolve voltha's virtual ip address
if err = ec.resolveServiceAddress(ec.vcoreSvcName); err != nil {
- log.Fatal("Can't proceed without voltha's vIP address")
- panic(err)
+ log.Fatal("Can't proceed without voltha's vIP address: %s", err.Error())
}
if err = ec.consulConnect(ec.consulSvcName, ec.consulPort); err != nil {
- log.Fatal("error creating consul client aborting")
- panic(err)
+ log.Fatal("error creating consul client aborting: %s", err.Error())
+ }
+
+ if ec.httpDisabled == true && ec.httpsDisabled == true {
+ log.Printf("Cowardly refusing to disable both http and https, leavign them both enabled\n")
+ } else if ec.httpDisabled == true {
+ log.Printf("Diasabling http\n")
+ ec.envoyConfigTemplate = ec.envoyConfigTemplateNoHttp
+ } else if ec.httpsDisabled == true {
+ log.Printf("Diasabling https\n")
+ ec.envoyConfigTemplate = ec.envoyConfigTemplateNoHttps
}
return
@@ -502,8 +541,7 @@
ec = NewEnvoyControl()
ec.ParseCommandArguments()
if err = ec.Initialize(); err != nil {
- log.Fatal("Envoy control initialization failed, aboring")
- panic(err)
+ log.Fatal("Envoy control initialization failed, aboring: %s", err.Error())
}