Skip to content

Commit

Permalink
chore: bootstrap updates
Browse files Browse the repository at this point in the history
  • Loading branch information
avatxus committed Mar 30, 2024
1 parent 1e77606 commit c576a50
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 14 deletions.
107 changes: 107 additions & 0 deletions bootstrap/configs/vector-testnet/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"ByronGenesisFile": "/genesis/vector-testnet/byron.json",
"ShelleyGenesisFile": "/genesis/vector-testnet/shelley.json",
"AlonzoGenesisFile": "/genesis/vector-testnet/alonzo.json",
"ConwayGenesisFile": "/genesis/vector-testnet/conway.json",
"SocketPath": "db/node.socket",
"PBftSignatureThreshold": 0.6,
"MaxConcurrencyBulkSync": 1,
"MaxConcurrencyDeadline": 2,
"Protocol": "Cardano",
"RequiresNetworkMagic": "RequiresMagic",
"LastKnownBlockVersion-Major": 6,
"LastKnownBlockVersion-Minor": 0,
"LastKnownBlockVersion-Alt": 0,
"TurnOnLogging": true,
"TurnOnLogMetrics": true,
"minSeverity": "Debug",
"TracingVerbosity": "NormalVerbosity",
"setupBackends": ["KatipBK"],
"defaultBackends": ["KatipBK"],
"hasEKG": 12788,
"hasPrometheus": [
"0.0.0.0",
12798
],
"setupScribes": [
{
"scKind": "FileSK",
"scName": "logs/mainnet.log",
"scFormat": "ScText"
},
{
"scKind": "StdoutSK",
"scName": "stdout",
"scFormat": "ScText"
}
],
"defaultScribes": [
["FileSK", "logs/mainnet.log"],
["StdoutSK", "stdout"]
],
"rotation": {
"rpLogLimitBytes": 5000000,
"rpKeepFilesNum": 3,
"rpMaxAgeHours": 24
},
"TraceBlockFetchClient": false,
"TraceBlockFetchDecisions": false,
"TraceBlockFetchProtocol": false,
"TraceBlockFetchProtocolSerialised": false,
"TraceBlockFetchServer": false,
"TraceBlockchainTime": false,
"TraceChainDb": true,
"TraceChainSyncClient": false,
"TraceChainSyncBlockServer": false,
"TraceChainSyncHeaderServer": false,
"TraceChainSyncProtocol": false,
"TraceDNSResolver": true,
"TraceDNSSubscription": true,
"TraceErrorPolicy": true,
"TraceLocalErrorPolicy": true,
"TraceForge": true,
"TraceHandshake": false,
"TraceIpSubscription": true,
"TraceLocalRootPeers": true,
"TracePublicRootPeers": true,
"TracePeerSelection": true,
"TraceDebugPeerSelection": false,
"TracePeerSelectionActions": true,
"TraceConnectionManager": true,
"TraceServer": true,
"TraceLocalConnectionManager": false,
"TraceLocalServer": false,
"TraceLocalChainSyncProtocol": false,
"TraceLocalHandshake": false,
"TraceLocalTxSubmissionProtocol": false,
"TraceLocalTxSubmissionServer": false,
"TraceMempool": true,
"TraceMux": false,
"TraceTxInbound": false,
"TraceTxOutbound": false,
"TraceTxSubmissionProtocol": false,
"options": {
"mapBackends": {
"cardano.node.metrics": ["EKGViewBK"]
},
"mapScribes": {
"cardano.node.metrics": ["FileSK::logs/mainnet.log"]
},
"mapSeverity": {
"cardano.node.ChainDB": "Notice",
"cardano.node.DnsSubscription": "Debug"
}
},
"TestShelleyHardForkAtEpoch": 0,
"TestAllegraHardForkAtEpoch": 0,
"TestMaryHardForkAtEpoch": 0,
"TestAlonzoHardForkAtEpoch": 0,
"TestBabbageHardForkAtEpoch": 0,
"ExperimentalProtocolsEnabled": true,
"ApplicationName":"cardano-sl",
"ApplicationVersion":0,
"ByronGenesisHash":"abc5e260bf7c5d7008eab849705fc0eae911b638dd6687b1f10cef2e2bc8a713",
"ShelleyGenesisHash":"fb2ca1cc879a9a7600103c2170c9d58e366cd77e17edf39a0e7bc1504f573e88",
"AlonzoGenesisHash":"1cd94b66eade0670885744a858accdb2c3249e43e247db2c66b158050ec6a3e4",
"ConwayGenesisHash":"d43d3f38e01848bddf67e66fe29fbd236aca252de58c7f2c1904c67107c17842"
}
116 changes: 116 additions & 0 deletions bootstrap/configs/vector-testnet/db-sync-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"EnableLogMetrics":false,
"EnableLogging":true,
"NetworkName":"testnet",
"NodeConfigFile":"config.json",
"PrometheusPort":8080,
"RequiresNetworkMagic":"RequiresMagic",
"defaultBackends":[
"KatipBK"
],
"defaultScribes":[
[
"StdoutSK",
"stdout"
]
],
"minSeverity":"Info",
"options":{
"cfokey":{
"value":"Release-1.0.0"
},
"mapBackends":{

},
"mapSeverity":{
"db-sync-node":"Info",
"db-sync-node.Mux":"Error",
"db-sync-node.Subscription":"Error"
},
"mapSubtrace":{
"#ekgview":{
"contents":[
[
{
"contents":"cardano.epoch-validation.benchmark",
"tag":"Contains"
},
[
{
"contents":".monoclock.basic.",
"tag":"Contains"
}
]
],
[
{
"contents":"cardano.epoch-validation.benchmark",
"tag":"Contains"
},
[
{
"contents":"diff.RTS.cpuNs.timed.",
"tag":"Contains"
}
]
],
[
{
"contents":"#ekgview.#aggregation.cardano.epoch-validation.benchmark",
"tag":"StartsWith"
},
[
{
"contents":"diff.RTS.gcNum.timed.",
"tag":"Contains"
}
]
]
],
"subtrace":"FilterTrace"
},
"#messagecounters.aggregation":{
"subtrace":"NoTrace"
},
"#messagecounters.ekgview":{
"subtrace":"NoTrace"
},
"#messagecounters.katip":{
"subtrace":"NoTrace"
},
"#messagecounters.monitoring":{
"subtrace":"NoTrace"
},
"#messagecounters.switchboard":{
"subtrace":"NoTrace"
},
"benchmark":{
"contents":[
"GhcRtsStats",
"MonotonicClock"
],
"subtrace":"ObservableTrace"
},
"cardano.epoch-validation.utxo-stats":{
"subtrace":"NoTrace"
}
}
},
"rotation":{
"rpKeepFilesNum":10,
"rpLogLimitBytes":5000000,
"rpMaxAgeHours":24
},
"setupBackends":[
"AggregationBK",
"KatipBK"
],
"setupScribes":[
{
"scFormat":"ScText",
"scKind":"StdoutSK",
"scName":"stdout",
"scRotation":null
}
]
}
2 changes: 1 addition & 1 deletion bootstrap/feature/configs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ resource "kubernetes_config_map" "pgbouncer_certs" {

data = {
"server.crt" = var.pgbouncer_server_crt
"key.crt" = var.pgbouncer_server_key
"server.key" = var.pgbouncer_server_key
}
}
9 changes: 3 additions & 6 deletions bootstrap/feature/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ variable "dcu_per_second" {
}
}

variable "postgres_host_1" {
type = string
}

variable "postgres_host_2" {
type = string
variable "postgres_hosts" {
type = list(string)
}

variable "postgres_secret_name" {
Expand All @@ -45,4 +42,4 @@ variable "pgbouncer_server_crt" {

variable "pgbouncer_server_key" {
type = string
}
}
11 changes: 8 additions & 3 deletions bootstrap/feature/operator.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
locals {
postgres_urls = [for host in var.postgres_hosts : "postgres://postgres:$(POSTGRES_PASSWORD)@${host}:5432"]
combined_postgres_urls = join(",", local.postgres_urls)
}

resource "kubernetes_deployment_v1" "operator" {
wait_for_rollout = false

Expand Down Expand Up @@ -57,17 +62,17 @@ resource "kubernetes_deployment_v1" "operator" {

env {
name = "DCU_PER_SECOND"
value = "mainnet=${var.dcu_per_second["mainnet"]},preprod=${var.dcu_per_second["preprod"]},preview=${var.dcu_per_second["preview"]}"
value = "mainnet=${var.dcu_per_second["mainnet"]},preprod=${var.dcu_per_second["preprod"]},preview=${var.dcu_per_second["preview"]},vector-testnet=${var.dcu_per_second["vector-testnet"]}"
}

env {
name = "DB_URLS"
value = "postgres://postgres:$(POSTGRES_PASSWORD)@${var.postgres_host_1}:5432,postgres://postgres:$(POSTGRES_PASSWORD)@${var.postgres_host_2}:5432"
value = local.combined_postgres_urls
}

env {
name = "DB_NAMES"
value = "mainnet=dbsync-mainnet,preprod=dbsync-preprod,preview=dbsync-preview"
value = "mainnet=dbsync-mainnet,preprod=dbsync-preprod,preview=dbsync-preview,vector-testnet=dbsync-vector-testnet"
}

env {
Expand Down
8 changes: 4 additions & 4 deletions bootstrap/pgbouncer/pgbouncer.ini.tftpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[databases]
*=host=${db_host} port=5432 auth_user=pgbouncer
mainnet=host=${db_host} port=5432 dbname=dbsync-mainnet auth_user=pgbouncer
preview=host=${db_host} port=5432 dbname=dbsync-preview auth_user=pgbouncer
preprod=host=${db_host} port=5432 dbname=dbsync-preprod auth_user=pgbouncer
dbsync-mainnet=host=${db_host} port=5432 dbname=dbsync-mainnet auth_user=pgbouncer pool_size=60 max_db_connections=70
dbsync-preview=host=${db_host} port=5432 dbname=dbsync-preview auth_user=pgbouncer max_db_connections=10
dbsync-preprod=host=${db_host} port=5432 dbname=dbsync-preprod auth_user=pgbouncer max_db_connections=10
cardanodbsync=host=${db_host} port=5432 dbname=dbsync-mainnet auth_user=pgbouncer

[pgbouncer]
Expand All @@ -27,7 +27,7 @@ tcp_keepcnt=9
tcp_keepidle=300
tcp_keepintvl=75
admin_users=pgbouncer
max_db_connections=40
max_db_connections=80
[users]
%{ for user in users ~}
${user.name} = max_user_connections=${user.max_connections}
Expand Down
19 changes: 19 additions & 0 deletions scripts/reload-pgbouncer-configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

echo "updating pgbouncer userlist.txt"
# Combine the files and sort them
cat /etc/pgbouncer/users.txt /opt/bitnami/pgbouncer/conf/userlist.txt | sort > combined_sorted.txt

# Use awk to remove duplicates, keeping the last occurrence
awk '!seen[$1]++' combined_sorted.txt > /opt/bitnami/pgbouncer/conf/userlist.txt

# Clean up intermediate file
rm combined_sorted.txt

echo "updating pgbouncer.ini"

cp /bitnami/pgbouncer/conf/pgbouncer.ini /opt/bitnami/pgbouncer/conf/pgbouncer.ini

echo "reloading pgbouncer"

psql -p 6432 -U pgbouncer -c "RELOAD" pgbouncer

0 comments on commit c576a50

Please sign in to comment.