Skip to content

Commit

Permalink
refactor: rename dapi envoy to gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Apr 24, 2024
1 parent a693e7c commit b783278
Show file tree
Hide file tree
Showing 36 changed files with 392 additions and 334 deletions.
4 changes: 2 additions & 2 deletions packages/dashmate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ $ dashmate update
║ Drive ABCI │ dashpay/drive:0.24 │ updated ║
║ Drive Tenderdash │ dashpay/tenderdash:0.11.2 │ up to date ║
║ DAPI API │ dashpay/dapi:0.24 │ updated ║
DAPI Envoy │ dashpay/envoy:0.24 │ updated ║
Gateway │ dashpay/envoy:0.24 │ updated ║
║ Dashmate Helper │ dashpay/dashmate-helper:0.24 │ updated ║
╚══════════════════╧══════════════════════════════╧════════════╝
$ dashmate update --format=json
[{"name":"core","title":"Core","updated":false,"image":"dashpay/dashd:19.2.0"},{"name":"drive_abci","title":"Drive ABCI","pulled":false,"image":"dashpay/drive:0.24"},{"name":"drive_tenderdash","title":"Drive Tenderdash","pulled":true,"image":"dashpay/tenderdash:0.11.2"},{"name":"dapi_api","title":"DAPI API","pulled":false,"image":"dashpay/dapi:0.24"},{"name":"dapi_envoy","title":"DAPI Envoy","pulled":false,"image":"dashpay/envoy:0.24"},{"name":"dashmate_helper","title":"Dashmate Helper","pulled":false,"image":"dashpay/dashmate-helper:0.24"}]
[{"name":"core","title":"Core","updated":false,"image":"dashpay/dashd:19.2.0"},{"name":"drive_abci","title":"Drive ABCI","pulled":false,"image":"dashpay/drive:0.24"},{"name":"drive_tenderdash","title":"Drive Tenderdash","pulled":true,"image":"dashpay/tenderdash:0.11.2"},{"name":"dapi_api","title":"DAPI API","pulled":false,"image":"dashpay/dapi:0.24"},{"name":"gateway","title":"Gateway","pulled":false,"image":"dashpay/envoy:0.24"},{"name":"dashmate_helper","title":"Dashmate Helper","pulled":false,"image":"dashpay/dashmate-helper:0.24"}]
$ dashmate start
```

Expand Down
115 changes: 60 additions & 55 deletions packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,73 +125,78 @@ export default function getBaseConfigFactory(homeDir) {
indexes: true,
},
platform: {
dapi: {
envoy: {
docker: {
image: 'dashpay/envoy:1.30.1',
gateway: {
docker: {
image: 'dashpay/envoy:1.30.1',
},
maxConnections: 10000,
maxHeapSizeInBytes: 125000000, // 1 Gb
upstreams: {
driveGrpc: {
maxConnections: 1500,
maxRequests: 10000,
maxPendingRequests: 1000,
},
maxConnections: 10000,
maxHeapSizeInBytes: 125000000, // 1 Gb
upstreams: {
driveGrpc: {
maxConnections: 1500,
maxRequests: 10000,
maxPendingRequests: 1000,
},
dapiApi: {
maxConnections: 1500,
maxRequests: 10000,
maxPendingRequests: 1000,
},
dapiCoreStreams: {
maxConnections: 100,
maxRequests: 100,
maxPendingRequests: 50,
},
dapiApi: {
maxConnections: 1500,
maxRequests: 10000,
maxPendingRequests: 1000,
},
metrics: {
enabled: false,
host: '127.0.0.1',
port: 9090,
},
admin: {
enabled: false,
host: '127.0.0.1',
port: 9901,
dapiCoreStreams: {
maxConnections: 100,
maxRequests: 100,
maxPendingRequests: 50,
},
http: {
},
metrics: {
enabled: false,
host: '127.0.0.1',
port: 9090,
},
admin: {
enabled: false,
host: '127.0.0.1',
port: 9901,
},
listeners: {
dapiAndDrive: {
http2: {
maxConcurrentStreams: 100,
},
host: '0.0.0.0',
port: 443,
},
rateLimiter: {
},
rateLimiter: {
docker: {
image: 'envoyproxy/ratelimit:3fcc3609',
},
metrics: {
enabled: false,
docker: {
image: 'envoyproxy/ratelimit:3fcc3609',
image: 'prom/statsd-exporter:v0.26.1',
},
metrics: {
enabled: false,
docker: {
image: 'prom/statsd-exporter:v0.26.1',
},
host: '127.0.0.1',
port: 9102,
},
unit: 'minute',
requestsPerUnit: 150,
blacklist: [],
whitelist: [],
enabled: true,
host: '127.0.0.1',
port: 9102,
},
ssl: {
enabled: false,
provider: 'zerossl',
providerConfigs: {
zerossl: {
apiKey: null,
id: null,
},
unit: 'minute',
requestsPerUnit: 150,
blacklist: [],
whitelist: [],
enabled: true,
},
ssl: {
enabled: false,
provider: 'zerossl',
providerConfigs: {
zerossl: {
apiKey: null,
id: null,
},
},
},
},
dapi: {
api: {
docker: {
image: `dashpay/dapi:${dockerImageVersion}`,
Expand Down
18 changes: 9 additions & 9 deletions packages/dashmate/configs/defaults/getLocalConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ export default function getLocalConfigFactory(getBaseConfig) {
},
},
platform: {
dapi: {
envoy: {
ssl: {
provider: SSL_PROVIDERS.SELF_SIGNED,
},
http: {
gateway: {
ssl: {
provider: SSL_PROVIDERS.SELF_SIGNED,
},
listeners: {
dapiAndDrive: {
port: 2443,
},
rateLimiter: {
enabled: false,
},
},
rateLimiter: {
enabled: false,
},
},
drive: {
Expand Down
6 changes: 3 additions & 3 deletions packages/dashmate/configs/defaults/getTestnetConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export default function getTestnetConfigFactory(homeDir, getBaseConfig) {
},
},
platform: {
dapi: {
envoy: {
http: {
gateway: {
listeners: {
dapiAndDrive: {
port: 1443,
},
},
Expand Down
107 changes: 71 additions & 36 deletions packages/dashmate/configs/getConfigFileMigrationsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)

options.platform.dapi.api.docker.image = base.get('platform.dapi.api.docker.image');

options.platform.dapi.envoy.docker.image = base.get('platform.dapi.envoy.docker.image');
options.platform.gateway.docker.image = base.get('platform.gateway.docker.image');
});

return configFile;
Expand Down Expand Up @@ -106,7 +106,7 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)
'0.24.16': (configFile) => {
Object.entries(configFile.configs)
.forEach(([, options]) => {
options.platform.dapi.envoy.docker = base.get('platform.dapi.envoy.docker');
options.platform.gateway.docker = base.get('platform.gateway.docker');

options.platform.dapi.api.docker.build = base.get('platform.dapi.api.docker.build');

Expand Down Expand Up @@ -382,7 +382,7 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)

options.core.p2p.host = base.get('core.p2p.host');
options.core.rpc.host = base.get('core.rpc.host');
options.platform.dapi.envoy.http.host = base.get('platform.dapi.envoy.http.host');
options.platform.dapi.envoy.http.host = '0.0.0.0';
options.platform.drive.tenderdash.p2p.host = base.get('platform.drive.tenderdash.p2p.host');
options.platform.drive.tenderdash.rpc.host = base.get('platform.drive.tenderdash.rpc.host');
options.platform.drive.tenderdash.metrics.host = base.get('platform.drive.tenderdash.metrics.host');
Expand All @@ -401,11 +401,8 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)
'0.25.20': (configFile) => {
Object.entries(configFile.configs)
.forEach(([name, options]) => {
// Removed in the future version
// options.platform.dapi.envoy.http.connectTimeout =
// base.get('platform.dapi.envoy.http.connectTimeout');
// options.platform.dapi.envoy.http.responseTimeout =
// base.get('platform.dapi.envoy.http.responseTimeout');
options.platform.dapi.envoy.http.connectTimeout = '5s';
options.platform.dapi.envoy.http.responseTimeout = '15s';

options.platform.drive.tenderdash.rpc.maxOpenConnections = base.get('platform.drive.tenderdash.rpc.maxOpenConnections');

Expand Down Expand Up @@ -526,48 +523,86 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)
},
'1.0.0-dev.12': (configFile) => {
Object.entries(configFile.configs)
.forEach(([, options]) => {
options.platform.dapi.envoy.maxConnections = base.get('platform.dapi.envoy.maxConnections');
options.platform.dapi.envoy.maxHeapSizeInBytes = base.get('platform.dapi.envoy.maxHeapSizeInBytes');

if (options.platform.dapi.envoy.http.connectTimeout) {
delete options.platform.dapi.envoy.http.connectTimeout;
.forEach(([name, options]) => {
// Do nothing if it's already migrated for some reason
if (!options.platform.dapi.envoy) {
return;
}

if (options.platform.dapi.envoy.http.responseTimeout) {
delete options.platform.dapi.envoy.http.responseTimeout;
}
options.platform.gateway = lodash.cloneDeep(options.platform.dapi.envoy);

options.platform.dapi.envoy.metrics = base.get('platform.dapi.envoy.metrics');
options.platform.dapi.envoy.admin = base.get('platform.dapi.envoy.admin');
options.platform.dapi.envoy.upstreams = base.get('platform.dapi.envoy.upstreams');
// add new options
options.platform.gateway.maxConnections = base.get('platform.gateway.maxConnections');
options.platform.gateway.maxHeapSizeInBytes = base.get('platform.gateway.maxHeapSizeInBytes');
options.platform.gateway.metrics = base.get('platform.gateway.metrics');
options.platform.gateway.admin = base.get('platform.gateway.admin');
options.platform.gateway.upstreams = base.get('platform.gateway.upstreams');

options.platform.dapi.envoy.rateLimiter.docker = base.get('platform.dapi.envoy.rateLimiter.docker');
options.platform.dapi.envoy.rateLimiter.unit = base.get('platform.dapi.envoy.rateLimiter.unit');
options.platform.dapi.envoy.rateLimiter.requestsPerUnit = base.get('platform.dapi.envoy.rateLimiter.requestsPerUnit');
options.platform.dapi.envoy.rateLimiter.blacklist = base.get('platform.dapi.envoy.rateLimiter.blacklist');
options.platform.dapi.envoy.rateLimiter.whitelist = base.get('platform.dapi.envoy.rateLimiter.whitelist');
options.platform.dapi.envoy.rateLimiter.metrics = base.get('platform.dapi.envoy.rateLimiter.metrics');
// http -> listeners
options.platform.gateway.listeners = lodash.cloneDeep(
base.get('platform.gateway.listeners'),
);

if (options.platform.dapi.envoy.rateLimiter.fillInterval) {
delete options.platform.dapi.envoy.rateLimiter.fillInterval;
}
options.platform.gateway.listeners.dapiAndDrive.host = options.platform.dapi.envoy
.http.host;
options.platform.gateway.listeners.dapiAndDrive.port = options.platform.dapi.envoy
.http.port;

if (options.platform.dapi.envoy.rateLimiter.maxTokens) {
delete options.platform.dapi.envoy.rateLimiter.maxTokens;
}
delete options.platform.gateway.http;

if (options.platform.dapi.envoy.rateLimiter.tokensPerFill) {
delete options.platform.dapi.envoy.rateLimiter.tokensPerFill;
}
// update rate limiter
options.platform.gateway.rateLimiter.docker = base.get('platform.gateway.rateLimiter.docker');
options.platform.gateway.rateLimiter.unit = base.get('platform.gateway.rateLimiter.unit');
options.platform.gateway.rateLimiter.requestsPerUnit = base.get('platform.gateway.rateLimiter.requestsPerUnit');
options.platform.gateway.rateLimiter.blacklist = base.get('platform.gateway.rateLimiter.blacklist');
options.platform.gateway.rateLimiter.whitelist = base.get('platform.gateway.rateLimiter.whitelist');
options.platform.gateway.rateLimiter.metrics = base.get('platform.gateway.rateLimiter.metrics');

delete options.platform.gateway.rateLimiter.fillInterval;
delete options.platform.gateway.rateLimiter.maxTokens;
delete options.platform.gateway.rateLimiter.tokensPerFill;

// delete envoy
delete options.platform.dapi.envoy;

options.platform.dapi.envoy.docker.image = base.get('platform.dapi.envoy.docker.image');
// update image
options.platform.gateway.docker.image = base.get('platform.gateway.docker.image');

// rename non conventional field
if (options.platform.drive.abci.tokioConsole.retention_secs) {
options.platform.drive.abci.tokioConsole.retention = options.platform.drive.abci
.tokioConsole.retention_secs;
delete options.platform.drive.abci.tokioConsole.retention_secs;
}

// move SSL files
if (options.network !== NETWORK_MAINNET) {
const filenames = ['private.key', 'bundle.crt', 'bundle.csr', 'csr.pem'];

for (const filename of filenames) {
const oldFilePath = homeDir.joinPath(
name,
'platform',
'dapi',
'envoy',
'ssl',
filename,
);
const newFilePath = homeDir.joinPath(
name,
'platform',
'gateway',
'ssl',
filename,
);

if (fs.existsSync(oldFilePath)) {
fs.mkdirSync(path.dirname(newFilePath), { recursive: true });
fs.copyFileSync(oldFilePath, newFilePath);
fs.rmSync(oldFilePath, { recursive: true });
}
}
}
});

return configFile;
Expand Down
12 changes: 6 additions & 6 deletions packages/dashmate/docker-compose.rate_limiter.metrics.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
version: '3.7'

services:
dapi_envoy_rate_limiter_metrics:
image: ${PLATFORM_DAPI_ENVOY_RATE_LIMITER_METRICS_DOCKER_IMAGE:?err}
gateway_rate_limiter_metrics:
image: ${PLATFORM_GATEWAY_RATE_LIMITER_METRICS_DOCKER_IMAGE:?err}
labels:
org.dashmate.service.title: "DAPI Envoy rate limiter metrics exporter"
org.dashmate.service.title: "Gateway rate limiter metrics exporter"
restart: unless-stopped
entrypoint: /bin/statsd_exporter
command:
- "--statsd.mapping-config=/etc/statsd-exporter/config.yaml"
networks:
- envoy_rate_limiter
- gateway_rate_limiter
volumes:
- ${DASHMATE_HOME_DIR:?err}/${CONFIG_NAME:?err}/platform/dapi/envoy/rate_limiter/statsd_exporter.yaml:/etc/statsd-exporter/config.yaml:ro
- ${DASHMATE_HOME_DIR:?err}/${CONFIG_NAME:?err}/platform/gateway/rate_limiter/statsd_exporter.yaml:/etc/statsd-exporter/config.yaml:ro
expose:
- 9125
- 9125/udp
ports:
- ${PLATFORM_DAPI_ENVOY_RATE_LIMITER_METRICS_HOST:?err}:${PLATFORM_DAPI_ENVOY_RATE_LIMITER_METRICS_PORT:?err}:9102
- ${PLATFORM_GATEWAY_RATE_LIMITER_METRICS_HOST:?err}:${PLATFORM_GATEWAY_RATE_LIMITER_METRICS_PORT:?err}:9102
Loading

0 comments on commit b783278

Please sign in to comment.