From f33e706887cb872e346963fee42ab54aa874646d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:42:53 -0700 Subject: [PATCH] get a running controller in docker --- ext/central-controller-docker/main-new.sh | 8 +----- nonfree/controller/CentralDB.cpp | 25 +------------------ .../controller/EmbeddedNetworkController.cpp | 4 +-- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index d2e3e6056..f40933ef2 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -164,10 +164,4 @@ fi export GLIBCXX_FORCE_NEW=1 export GLIBCPP_FORCE_NEW=1 export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2" -#exec -/usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one -if [ $? -ne 0 ]; then - echo '*** FAILED: zerotier-one exited unexpectedly' - cat /var/lib/zerotier-one/local.conf - exit 1 -fi \ No newline at end of file +exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index a7471129f..fd5b07c62 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -42,12 +42,6 @@ using json = nlohmann::json; -namespace { - -static const int DB_MINIMUM_VERSION = 38; - -} // anonymous namespace - using namespace ZeroTier; using Attrs = std::vector >; @@ -88,7 +82,7 @@ CentralDB::CentralDB( char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); _connString = std::string(connString); - fprintf(stderr, "connstring: %s\n", _connString.c_str()); + auto f = std::make_shared(_connString); _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); @@ -110,23 +104,6 @@ CentralDB::CentralDB( fprintf(stderr, "Using redis for member status\n"); } - auto c = _pool->borrow(); - pqxx::work txn { *c->c }; - - pqxx::row r { txn.exec1("SELECT version FROM ztc_database") }; - int dbVersion = r[0].as(); - txn.commit(); - - if (dbVersion < DB_MINIMUM_VERSION) { - fprintf( - stderr, - "Central database schema version too low. This controller version requires a minimum schema version of " - "%d. Please upgrade your Central instance", - DB_MINIMUM_VERSION); - exit(1); - } - _pool->unborrow(c); - if ((listenMode == LISTENER_MODE_REDIS || statusMode == STATUS_WRITER_MODE_REDIS) && _cc->redisConfig != NULL) { auto innerspan = tracer->StartSpan("CentralDB::CentralDB::configureRedis"); auto innerscope = tracer->WithActiveSpan(innerspan); diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index 05332f936..c708e4f3b 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -655,7 +655,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) throw std::runtime_error("central controller requires postgres db"); } - const char* connString = _path.substr(9).c_str(); + std::string connString = _path.substr(9); CentralDB::ListenerMode lm; if (_cc->listenMode == "pgsql") { @@ -685,7 +685,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) throw std::runtime_error("unsupported status mode"); } - _db.addDB(std::shared_ptr(new CentralDB(_signingId, connString, _listenPort, lm, sm, _cc))); + _db.addDB(std::shared_ptr(new CentralDB(_signingId, connString.c_str(), _listenPort, lm, sm, _cc))); #else #ifdef ZT_CONTROLLER_USE_LIBPQ if ((_path.length() > 9) && (_path.substr(0, 9) == "postgres:")) {