Skip to content

Commit 1a0624a

Browse files
authored
Merge pull request #626 from aperture-data/release-0.4.51
Release 0.4.51
2 parents 28df333 + 2bd614d commit 1a0624a

38 files changed

+410
-119
lines changed

.devcontainer/devcontainer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "devcontainer",
3+
"dockerComposeFile": [
4+
"docker-compose.yml"
5+
],
6+
"service": "devcontainer",
7+
"workspaceFolder": "/aperturedb-python",
8+
"customizations": {
9+
"vscode": {
10+
"extensions": [
11+
"ms-python.python",
12+
"ms-python.pylint",
13+
"ms-toolsai.jupyter"
14+
]
15+
}
16+
},
17+
"settings": {
18+
"python.defaultInterpreterPath": "/opt/venv/bin/python",
19+
"python.linting.enabled": true,
20+
"python.linting.pylintEnabled": true,
21+
"files.exclude": {
22+
"**/__pycache__": true,
23+
"**/*.pyc": true
24+
}
25+
},
26+
"initializeCommand": "./initcommand.sh",
27+
"postCreateCommand": "./postinstall.sh"
28+
}

.devcontainer/docker-compose.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: $RUNNER_NAME
2+
3+
services:
4+
ca:
5+
image: nginx
6+
restart: on-failure
7+
command: |
8+
bash -c "
9+
openssl genpkey -algorithm RSA -out /ca/ca.key -aes256 -pass pass:1234
10+
openssl req -x509 -new -nodes -key /ca/ca.key -sha256 -days 3650 -out /ca/ca.crt -subj \"/C=US/ST=CA/L=Los Gatos/O=ApertureData/OU=ApertureDataCA/CN=ApertureDataCA\" -passin pass:1234
11+
openssl genrsa -out /cert/tls.key 4096
12+
openssl req -new -key /cert/tls.key -out /ca/tcp.csr -days 3650 -subj \"/C=US/ST=NY/L=NYC/O=instance/OU=instanceDB/CN=${DB_TCP_CN:-localhost}\"
13+
openssl x509 -req -CA /ca/ca.crt -CAkey /ca/ca.key -in /ca/tcp.csr -out /cert/tcp.crt -passin pass:1234
14+
openssl req -new -key /cert/tls.key -out /ca/http.csr -days 3650 -subj \"/C=US/ST=NY/L=NYC/O=instance/OU=instanceDB/CN=${DB_HTTP_CN:-localhost}\"
15+
openssl x509 -req -CA /ca/ca.crt -CAkey /ca/ca.key -in /ca/http.csr -out /cert/http.crt -passin pass:1234"
16+
volumes:
17+
- ./aperturedb/certificate:/cert
18+
- ./ca:/ca
19+
20+
lenz:
21+
depends_on:
22+
ca:
23+
condition: service_completed_successfully
24+
aperturedb:
25+
condition: service_started
26+
image: $LENZ_REPO:$LENZ_TAG
27+
ports:
28+
- $GATEWAY:55556:55551
29+
restart: always
30+
environment:
31+
LNZ_HEALTH_PORT: 58085
32+
LNZ_TCP_PORT: 55551
33+
LNZ_HTTP_PORT: 8080
34+
LNZ_ADB_BACKENDS: '["aperturedb:55553"]'
35+
LNZ_REPLICAS: 1
36+
LNZ_ADB_MAX_CONCURRENCY: 48
37+
LNZ_FORCE_SSL: false
38+
LNZ_CERTIFICATE_PATH: /etc/lenz/certificate/tcp.crt
39+
LNZ_PRIVATE_KEY_PATH: /etc/lenz/certificate/tls.key
40+
volumes:
41+
- ./aperturedb/certificate:/etc/lenz/certificate
42+
43+
aperturedb:
44+
image: $ADB_REPO:$ADB_TAG
45+
volumes:
46+
- ./aperturedb/db_$RUNNER_NAME:/aperturedb/db
47+
- ./aperturedb/logs:/aperturedb/logs
48+
restart: always
49+
environment:
50+
ADB_KVGD_DB_SIZE: "204800"
51+
ADB_LOG_PATH: "logs"
52+
ADB_ENABLE_DEBUG: 1
53+
ADB_MASTER_KEY: "admin"
54+
ADB_PORT: 55553
55+
ADB_FORCE_SSL: false
56+
57+
webui:
58+
image: aperturedata/aperturedata-platform-web-private:latest
59+
restart: always
60+
61+
nginx:
62+
depends_on:
63+
ca:
64+
condition: service_completed_successfully
65+
image: nginx
66+
restart: always
67+
ports:
68+
- $GATEWAY:8087:80
69+
- $GATEWAY:8443:443
70+
configs:
71+
- source: nginx.conf
72+
target: /etc/nginx/conf.d/default.conf
73+
volumes:
74+
- ./aperturedb/certificate:/etc/nginx/certificate
75+
devcontainer:
76+
build:
77+
context: ../docker/devcontainer
78+
environment:
79+
DB_HOST: lenz
80+
DB_PORT: 55551
81+
CA_CERT: /ca/ca.crt
82+
command: bash -c "while true; do sleep 1000; done"
83+
volumes:
84+
- ../:/aperturedb-python
85+
- ./ca:/ca
86+
configs:
87+
nginx.conf:
88+
content: |
89+
server {
90+
listen 80;
91+
listen 443 ssl;
92+
client_max_body_size 256m;
93+
ssl_certificate /etc/nginx/certificate/http.crt;
94+
ssl_certificate_key /etc/nginx/certificate/tls.key;
95+
location / {
96+
proxy_pass http://webui;
97+
}
98+
location /api/ {
99+
proxy_pass http://lenz:8080;
100+
}
101+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,6 @@ docker/pytorch-gpu/aperturedata/*
154154
.aperturedb
155155
test/data/
156156
test/aperturedb/certificate/
157+
.devcontainer/aperturedb/
158+
.devcontainer/ca/
159+
test/*_ca/

aperturedb/CommonLibrary.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __create_connector(configuration: Configuration):
4040
token=configuration.token,
4141
password=configuration.password,
4242
use_ssl=configuration.use_ssl,
43+
ca_cert=configuration.ca_cert,
4344
config=configuration)
4445
else:
4546
connector = Connector(
@@ -49,6 +50,7 @@ def __create_connector(configuration: Configuration):
4950
token=configuration.token,
5051
password=configuration.password,
5152
use_ssl=configuration.use_ssl,
53+
ca_cert=configuration.ca_cert,
5254
config=configuration)
5355
logger.debug(
5456
f"Created connector using: {configuration}. Will connect on query.")
@@ -147,6 +149,7 @@ def _store_config(config: Configuration, name: str):
147149
password=config.password,
148150
use_ssl=config.use_ssl,
149151
use_rest=config.use_rest,
152+
ca_cert=config.ca_cert,
150153
interactive=False,
151154
overwrite=True,
152155
active=True,

aperturedb/Configuration.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from base64 import b64encode, b64decode
66

77
APERTUREDB_CLOUD = ".cloud.aperturedata.io"
8-
APERTUREDB_KEY_VERSION = 1
8+
APERTUREDB_KEY_VERSION = 2
9+
APERTUREDB_OLD_KEY_VERSION = 1
910
FLAG_USE_COMPRESSED_HOST = 4
1011
FLAG_USE_REST = 2
1112
FLAG_USE_SSL = 1
@@ -33,6 +34,7 @@ class Configuration:
3334
retry_max_attempts: int = 3
3435
token: str = None
3536
user_keys: dict = None
37+
ca_cert: str = None
3638

3739
def __repr__(self) -> str:
3840
mode = "REST" if self.use_rest else "TCP"
@@ -41,7 +43,7 @@ def __repr__(self) -> str:
4143

4244
def deflate(self) -> list:
4345
return self.create_aperturedb_key(self.host, self.port, self.token,
44-
self.use_rest, self.use_ssl, self.username, self.password)
46+
self.use_rest, self.use_ssl, self.ca_cert, self.username, self.password)
4547

4648
def has_user_keys(self) -> bool:
4749
return self.user_keys is not None
@@ -82,8 +84,10 @@ def config_default_port(cls, use_rest: bool, use_ssl: bool):
8284
return DEFAULT_TCP_PORT
8385

8486
@classmethod
85-
def create_aperturedb_key(cls, host: str, port: int, token_string: str,
86-
use_rest: bool, use_ssl: bool, username: str = None, password: str = None) -> None:
87+
def create_aperturedb_key(
88+
cls, host: str, port: int, token_string: str,
89+
use_rest: bool, use_ssl: bool, ca_cert: str = None,
90+
username: str = None, password: str = None) -> None:
8791
compressed = False
8892
if token_string is not None and token_string.startswith("adbp_"):
8993
token_string = token_string[5:]
@@ -100,10 +104,11 @@ def create_aperturedb_key(cls, host: str, port: int, token_string: str,
100104
if port != default_port:
101105
host = f"{host}:{port}"
102106
if token_string is not None:
103-
key_json = [APERTUREDB_KEY_VERSION, key_type, host, token_string]
107+
key_json = [APERTUREDB_KEY_VERSION,
108+
key_type, host, ca_cert, token_string]
104109
else:
105110
key_json = [APERTUREDB_KEY_VERSION,
106-
key_type, host, username, password]
111+
key_type, host, ca_cert, username, password]
107112
simplified = json.dumps(key_json, separators=(',', ':'))
108113
encoded = b64encode(simplified.encode('utf-8')).decode('utf-8')
109114
return encoded
@@ -118,16 +123,25 @@ def reinflate(cls, encoded_str: list) -> object:
118123
raise Exception(
119124
"Unable to make configuration from the provided string")
120125
version = as_list[0]
121-
if version not in (APERTUREDB_KEY_VERSION,):
126+
if version not in (APERTUREDB_KEY_VERSION, APERTUREDB_OLD_KEY_VERSION):
122127
raise ValueError("version identifier of configuration was"
123128
f"{version}, which is not supported")
124129
is_compressed, use_rest, use_ssl = cls.key_type_to_config(as_list[1])
125130
host = as_list[2]
131+
pem = None
132+
133+
if version == APERTUREDB_KEY_VERSION:
134+
pem = as_list[3]
135+
list_offset = 4
136+
else:
137+
list_offset = 3
126138
token = username = password = None
127-
if len(as_list) == 4:
128-
token = "adbp_" + as_list[3]
129-
elif len(as_list) == 5:
130-
username, password = as_list[3:]
139+
if len(as_list) == list_offset + 1:
140+
token = "adbp_" + as_list[list_offset]
141+
elif len(as_list) == list_offset + 2:
142+
username, password = as_list[list_offset:]
143+
else:
144+
raise ValueError("Bad format for key list")
131145

132146
port_match = re.match(".*:(\d+)$", host)
133147
if port_match is not None:
@@ -146,7 +160,7 @@ def reinflate(cls, encoded_str: list) -> object:
146160
f"Unable to parse compressed host: {host} Error: {e}")
147161

148162
c = Configuration(
149-
host, port, username, password, name, use_ssl, use_rest)
163+
host, port, username, password, name, use_ssl, use_rest, ca_cert=pem)
150164
if token:
151165
c.token = token
152166
return c

0 commit comments

Comments
 (0)