many updates later on sunday...

This commit is contained in:
David Tai
2019-05-12 20:16:10 -05:00
parent c1c82df13a
commit a838632006
7 changed files with 168 additions and 8 deletions
+30 -4
View File
@@ -7,6 +7,8 @@ from util import asynctools, convert
from pymongo import MongoClient
import datetime
import asyncio
import requests
import datetime
app = Quart(__name__)
cors(app)
@@ -20,7 +22,7 @@ nodes_collection = bootnode_db.nodes
updates_collection = bootnode_db.updates
# set up system update loop
def update_nodes_lambda():
async def update_nodes_lambda():
print('updating nodes')
try:
date = datetime.datetime.utcnow()
@@ -37,7 +39,31 @@ def update_nodes_lambda():
nodes = convert.to_nodes(deployments, services, pods, zone)
for node in nodes:
node['lateUpdated'] = date
node['lastUpdated'] = date
try:
if node['blockchain'] == 'casper' and node['ip'] is not None:
ip = node['ip']
start = datetime.datetime.now()
blockdata = requests.put('https://{0}:9001/show/blocks'.format(ip),
json={'depth': 1},
verify=False)
end = datetime.datetime.now()
node['metadata'] = {
'block': blockdata.json()[0],
'dag':
requests.put('https://{0}:9001/show/dag'.format(ip),
json={'depth': 10,
'showJustifications':
True}, verify=False).json(),
}
node['latencyMillis'] = (end - start).microseconds / 1000
except Exception as e:
print('cannot get metadata for ' + node['id'] + ': ' +
str(e))
nodes_collection.insert_one(node)
except Exception as e:
@@ -58,7 +84,7 @@ def update_nodes_lambda():
# function to spin off thread
async def update_nodes_loop():
while True:
update_nodes_lambda()
await update_nodes_lambda()
await asyncio.sleep(1)
def update_nodes_daemon():
@@ -87,7 +113,7 @@ async def get_nodes():
update = updates_collection.find_one({ 'name': 'nodes' })
print(update)
print('getting node data as of ' + str(update['date']))
nodes = nodes_collection.find({'lateUpdated': update['date']})
nodes = nodes_collection.find({'lastUpdated': update['date']})
ns = []
for node in nodes:
+7
View File
@@ -675,6 +675,13 @@ class Casper(Blockchain):
port=9001,
targetPort=9001
))
# ports.append(
# ServicePort(
# name='secure-rpc',
# protocol='TCP',
# port=9002,
# targetPort=9002
# ))
service = super(Casper, self).get_service(ports)
+2
View File
@@ -1,3 +1,5 @@
FROM envoyproxy/envoy:latest
COPY config /envoy
ADD casper-envoy.crt /etc/casper-envoy.crt
ADD casper-envoy.key /etc/casper-envoy.key
WORKDIR /envoy
+21
View File
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDhjCCAm4CCQDqVC6OouuZGzANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMC
VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFDASBgNVBAcMC0xvcyBBbmdlbGVzMQ4w
DAYDVQQKDAVIYW56bzEOMAwGA1UECwwFSGFuem8xDjAMBgNVBAMMBUhhbnpvMRow
GAYJKoZIhvcNAQkBFgtoaUBoYW56by5haTAeFw0xOTA1MTIwNDE3MjNaFw0yMDA1
MTEwNDE3MjNaMIGEMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEU
MBIGA1UEBwwLTG9zIEFuZ2VsZXMxDjAMBgNVBAoMBUhhbnpvMQ4wDAYDVQQLDAVI
YW56bzEOMAwGA1UEAwwFSGFuem8xGjAYBgkqhkiG9w0BCQEWC2hpQGhhbnpvLmFp
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuWJNXvx6V65T2kvXoJyx
/KmUFH2PIklQ0AxfuUOPxkdNGh2d8wk4XTy2sRDwPrK7h02qMHWCDlMgOCpKSaUn
U5uWI13uRaGJB6xaZC98SHf1Mn2b8lbvzzCzy57KOJsOq3JxR0ia9POD1ZNWI5xB
Nj3RXQ/N9oxzgpp90+JWmlXneJprGhMLRRHQVwFuBhsTIOK8EaryNk1CwGraYa7H
qSxDoAN4k1OvKAp8Sk021/kMrZzxKyaChHeiMW7ee7wtJ7Z1JcqWbNhuOvBsgtrK
2CxwVa0bzYGNP23GA7fKNUXC/5zG+ODn7v03PRdzptWe1rrHVp3JLK9FMTEacWCT
4wIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQCbRvWdNoga5gH2IsgnyXNcMxX+igEX
x/Mo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3pBTQy8yLqhJ
UQ5qH5VRAoGBAOEB9wOrzw//duAVKgma8wqO2lW1lLp9cCW7+IyX+G6AN+TBKntk
jfl9IimB1oe23HW6wlXHCmQugKDj4nR8Wi3/Ngo8DsrVWg/vP289Jmtvafb8y3vF
3pnamZLHc5aUwBEUT8GkutzvxwHHbSFBMmRA2d4vFOQcAPUfwTUexeq5AoGBANLr
KONz2+fMZA8tR3/0UEKtS8IYqFzl76y0ydL9Phs4EYv5T8rFaAzEgTVD1Uneag4E
yK+7gIXxNiW6ZV9n1jybstBFXdFi2K26GSc+ycDUTxALaGabES4YfyQFt+ZbyG9R
egYzgVfeQRh713P3PvfaSa+IOptKm0vMciKJ9LV7AoGBANEGlERyzS7dcb+FqcG2
kmWSg73vq7T7Zr2HO8TQQNfWgRYfZKmwpjvJRX0twu/crj0oO/SXrU2X7aKJUQxJ
oTTty3QCivNe9AWtik56jkBsBhKOkTHwhXSEIPq8EuMmWK8FIXqQ347zqPo8G2Mz
P+7mV/8R2eR3J2SQFVqVteLxAoGAe1NlJRmpi2/HUdh35ilEhLgvg95HE4qfCazs
FaJdniy6lc3BCh9DJ7P+mNaA8CBMgsXpUlegXrEbqBPFEnP0oJupgn4MzVGuwGYA
LyJXdZiuYgNJmDUzZnCMZtOxI9Cm8fACGX4kMuyRw28mG3iGKQZJ74kIO6T0CO4S
Dn/7xeECgYBzhEIwaBNEXhKS62o4tPAmgj073Rui8ufBVt1SiGpT7tPPYqB4/N+a
ukcCGbJQz9Ovidon0DNZijcd5v5qkEf95bz8BY9Dpj7rT5EdWsELyWaTInkJ2jWG
I/cfRVPOYrRPG3ylXhNaZM8mKzBGczbGePFDwsZgXeWqbF+lgj1Xfw==
-----END RSA PRIVATE KEY-----
+79 -2
View File
@@ -2,6 +2,10 @@
# datatypes are listed in parentheses in comments; if surrounded by square brackets = array of said datatype; if ":R" appended = required
# the top-level object is (config.bootstrap.v2.Bootstrap)
# datatype specs can be found at https://www.envoyproxy.io/docs/envoy/v1.7.1/api-v2/api#envoy-api-reference
# datatypes are listed in parentheses in comments; if surrounded by square brackets = array of said datatype; if ":R" appended = required
# the top-level object is (config.bootstrap.v2.Bootstrap)
admin: #(config.bootstrap.v2.Admin:R)
access_log_path: envoyLog.txt #(string:R)
address:
@@ -23,9 +27,29 @@ static_resources: #(config.bootstrap.v2.Bootstrap.StaticRes
virtual_hosts: #([route.VirtualHost]) array of virtual hosts composing the route table; may need to add "cors" (route.CorsPolicy) to route.VirtualHost
- name: casperNodeWebVHost #(string:R)
domains: [ "*" ] #([string]:R) if this matches the host component of incoming url, route to this virtual host
cors:
allow_credentials: true
allow_methods: GET, PUT, DELETE, POST, PATCH, OPTIONS
allow_headers: content-type,origin,authorization
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web
expose_headers: grpc-status,grpc-message,x-envoy-upstream-service-time
routes: #([route.Route])
- match: { prefix: "/" } #(route.RouteMatch:R) inside "match" element, one of "prefix", "path", "regex" is required
# inside "match" element, can also match headers with "headers" (route.HeaderMatcher) and query params with "query_parameters" (route.QueryParameterMatcher)
- match: { prefix: "/", headers: [ { name: ":method", exact_match: "OPTIONS" } ] }
direct_response:
status: 204
response_headers_to_add:
- header: { key: "Access-Control-Allow-Origin", value: "*" }
append: false
- header: { key: "Access-Control-Allow-Methods", value: "DELETE, HEAD, OPTIONS, GET, PATCH, POST, PUT" }
append: false
- header: { key: "Allow", value: "DELETE, HEAD, OPTIONS, GET, PATCH, POST, PUT" }
append: false
- header: { key: "Access-Control-Allow-Headers", value: "Authorization, Content-Type" }
append: false
- header: { key: "Content-Type", value: "text/html; charset=utf-8" }
append: false
- match: { prefix: "/" } #(route.RouteMatch:R) inside "match" element, one of "prefix", "path", "regex" is required # inside "match" element, can also match headers with "headers" (route.HeaderMatcher) and query params with "query_parameters" (route.QueryParameterMatcher)
route: { cluster: casperNodes } #(route.routeAction) inside "route" element, one of "cluster", "cluster_header", "weighted_clusters" is required
http_filters: #([config.filter.network.http_connection_manager.v2.HttpFilter]) filter order does not appear to be significant
- name: envoy.grpc_json_transcoder #(string:R)
@@ -37,6 +61,59 @@ static_resources: #(config.bootstrap.v2.Bootstrap.StaticRes
- io.casperlabs.casper.protocol.DeployService
- name: envoy.router #(string:R)
# other options for elements of the "http_filters" array: envoy.grpc_web, envoy.grpc_http1_bridge, envoy.cors
# - name: casperNodeWebListener #(string)
# address: #(core.Address:R)
# socket_address: { address: 0.0.0.0, port_value: 9002 } #(core.Address) where a browser should connect to talk to a node
# filter_chains: #([listener.FilterChain]:R)
# - filters: #([listener.Filter])
# - name: envoy.http_connection_manager #(string:R) make downstream http, i.e. facing out from node cluster
# config: #(config.filter.network.http_connection_manager.v2.HttpConnectionManager) specific type depends on value of name field
# stat_prefix: casperNodeWebFilter #(string:R) prepended to stats for this filter
# codec_type: AUTO #(config.filter.network.http_connection_manager.v2.HttpConnectionManager.CodecType) options: AUTO (default), HTTP1, HTTP2
# route_config: #(RouteConfiguration) required for static connection configurations
# name: local_route #(string)
# virtual_hosts: #([route.VirtualHost]) array of virtual hosts composing the route table; may need to add "cors" (route.CorsPolicy) to route.VirtualHost
# - name: casperNodeWebVHost #(string:R)
# domains: [ "*" ] #([string]:R) if this matches the host component of incoming url, route to this virtual host
# cors:
# allow_credentials: true
# allow_methods: GET, PUT, DELETE, POST, PATCH, OPTIONS
# allow_headers: content-type,origin,authorization
# allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web
# expose_headers: grpc-status,grpc-message,x-envoy-upstream-service-time
# routes: #([route.Route])
# - match: { prefix: "/", headers: [ { name: ":method", exact_match: "OPTIONS" } ] }
# direct_response:
# status: 204
# response_headers_to_add:
# - header: { key: "Access-Control-Allow-Origin", value: "*" }
# append: false
# - header: { key: "Access-Control-Allow-Methods", value: "DELETE, HEAD, OPTIONS, GET, PATCH, POST, PUT" }
# append: false
# - header: { key: "Allow", value: "DELETE, HEAD, OPTIONS, GET, PATCH, POST, PUT" }
# append: false
# - header: { key: "Access-Control-Allow-Headers", value: "Authorization, Content-Type" }
# append: false
# - header: { key: "Content-Type", value: "text/html; charset=utf-8" }
# append: false
# - match: { prefix: "/" } #(route.RouteMatch:R) inside "match" element, one of "prefix", "path", "regex" is required # inside "match" element, can also match headers with "headers" (route.HeaderMatcher) and query params with "query_parameters" (route.QueryParameterMatcher)
# route: { cluster: casperNodes } #(route.routeAction) inside "route" element, one of "cluster", "cluster_header", "weighted_clusters" is required
# http_filters: #([config.filter.network.http_connection_manager.v2.HttpFilter]) filter order does not appear to be significant
# - name: envoy.grpc_json_transcoder #(string:R)
# config: #(config.filter.http.transcoder.v2.GrpcJsonTranscoder) specific type depends on value of name field
# proto_descriptor: casperMessageDescSet.pb #(string:R) name of file emitted by protoc using the --descriptor_set_out option
# match_incoming_request_route: true #(bool) if false, match a fixed URL pattern determined by service and endpoint names in .proto file
# # need additional steps when compiling the .proto file; see https://www.envoyproxy.io/docs/envoy/v1.7.1/configuration/http_filters/grpc_json_transcoder_filter
# services: #([string]:R) one element per service in .proto file (which is also in the descriptor set file) that is to be exposed
# - io.casperlabs.casper.protocol.DeployService
# - name: envoy.router #(string:R)
# # other options for elements of the "http_filters" array: envoy.grpc_web, envoy.grpc_http1_bridge, envoy.cors
tls_context:
common_tls_context:
tls_certificates:
- certificate_chain: { filename: "/etc/casper-envoy.crt" }
private_key: { filename: "/etc/casper-envoy.key" }
clusters: #([Cluster])
- name: casperNodes #(string:R)
+2 -2
View File
@@ -25,10 +25,10 @@ users:
user:
auth-provider:
config:
access-token: ya29.GlwEBwbPyZrCEH40LdxS3FTzgZYigW6BAhYCHymurCcIyxEg80BBmGIVIwNGs_cJuRc9HatxmDEjHrhcaIjHVSz4CoAiGm-S-Ig1z-nLR_jPY_bFiobGT0289aoe-g
access-token: ya29.Gl0HB7hbIOeQzEFRnfeFkfSyLZqEaVR1H_p0uvDL5j3-DQw1_5mh1VbEVNwC922DUMjldztnIyw17N63tgll6Q6u4Liwm38tmCJInjnGYwRak35SCIvZ5_lHeEP9-GM
cmd-args: config config-helper --format=json
cmd-path: /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/gcloud
expiry: 2019-05-09T20:37:06Z
expiry: 2019-05-12T13:03:22Z
expiry-key: '{.credential.token_expiry}'
token-key: '{.credential.access_token}'
name: gcp