Compare commits

...
Author SHA1 Message Date
Grant Limberg 4f5dab30e8 index fixups for the prod DB 2026-08-03 10:28:30 -07:00
Grant Limberg 6bf7bb67b3 controller: collapse duplicate OTel spans on the request path
Reduce spans emitted per controller request without touching the head
sample rate. Removes 20 StartSpan sites (97 -> 77) that traced the same
logical op at multiple layers:

- DB.cpp: drop all db:: read-helper/leaf spans; the db_mirror_set::
  wrapper survives as the single span per read op (also removes the
  latent member_id-from-networkId attribute bug).
- CentralDB.cpp: drop inner write-op spans (save/+children, nodeIsOnline,
  eraseNetwork, eraseMember); keep getSSOAuthInfo (errors) and all
  background-thread spans (commitThread, onlineNotificationThread, init).
- EmbeddedNetworkController.cpp: drop per-rule parseRule span and the
  no-op _startThreads span; keep request/_request roots.

Sampler, trace-context propagation, commit/Bigtable-write spans, and all
business logic are unchanged.
2026-07-23 11:35:15 +02:00
Grant Limberg f5ea9422a6 controller: observability and write-path hygiene for change propagation
- Log network/member ids on every inbound PubSub config ('has old/new config'
  lines were untraceable without them), on the frontend-gate drops (previously
  fully silent), on the invalid-id save skips (the one silent path where a
  delivered-and-acked change could vanish), and on the 100-attempt commit drop
- commitThread member branch: missing network is a permanent condition (nodes
  join-looping a deleted network) -- skip with one log line instead of the
  COUNT+GROUP BY+one_row() form that threw on zero rows and turned each item
  into a 100-attempt retry storm; NULL frontend now reads as ''
- cleanMember also strips change_source: request-path saves inherited the
  frontend's provenance from the cached record, mis-attributing the write and
  silently skipping the controller->Central echo (stable CV1/controller
  divergence); the authorized-path save now tags change_source after cleaning
- Deny and SSO-pending paths persist the member only on first sighting or a
  just-learned identity: the old per-request full-snapshot save could race
  with and overwrite a concurrent authorize arriving via PubSub
2026-07-22 17:02:33 +02:00
Grant Limberg 3dcbde5185 controller: start member revisions at 1 to unblock echo sync for manual members
A member auto-created by the controller started at revision 0; its first save
bumped to 1 and the echo to Central carried 1. A manually created CV1 member
row also defaults to revision 1, and Central's UpsertMemberFromController only
applies echoes with a strictly greater revision -- 1 < 1 never passed, so the
echo carrying the learned identity was skipped forever and manually created
members stayed identity=""/revision=1 in CV1. Starting at 1 (matching
Central's DB default) makes the first echo carry 2.
2026-07-22 16:42:52 +02:00
Grant Limberg 66479cd2da controller: review fixes for commit-pipeline liveness change
From adversarial review of the previous commit:

- CtlUtil: guard <pthread.h> for Windows (client build compiles the controller
  sources) and define _GNU_SOURCE on Linux for the two-arg pthread_setname_np
  under the strict -std=c++17 make build
- Zero _commitThreadLastActive before the heartbeat thread and PubSub listeners
  start; C++17 atomics are indeterminate until stored (C++20 masked this in
  local checks) and a garbage stamp could spuriously abort at startup
- Watchdog aborts only when every started commit thread is stalled past the
  threshold (the incident signature), or one thread exceeds 3x -- a single slow
  item (e.g. the deauth fan-out of a huge network deletion) can no longer kill
  a healthy controller
- BlockingQueue: lock size() (raced with push/pop; now read cross-thread by
  the health gate, watchdog, and depth gauge) and notify gc in the timed get()
  to match the untimed variant
- Drop statement_timeout from the hardened conninfo: it also capped the
  startup bulk COPY loads, where a timeout exits the process -> crash loop on
  a slow/degraded DB; dead-peer hangs are covered by keepalives and
  tcp_user_timeout, and it could clobber an operator-supplied options=
- Rate-limit the listener nack logs (every redelivery attempt passes through
  the health gate during a stall)
2026-07-22 16:28:27 +02:00
Grant Limberg 2e6fe413b6 controller: prevent commit-pipeline freezes and message loss
The Jul 21-22 incident: a commit thread wedged inside the change-notification
fan-out while holding _changeListeners_l/_dbs_l, every other commit thread piled
up behind it, and the PubSub listeners kept acking member/network changes into a
queue nothing drained -- silently losing them (CV1 authorize never applied).

- Lock hygiene: snapshot-then-call in DB::_memberChanged/_networkChanged,
  DBMirrorSet fan-out, and ENC onNetworkUpdate/onNetworkMemberUpdate/
  onNetworkMemberDeauthorize; no listener callback runs under notification locks
- Liveness watchdog in heartbeat(): warn when a commit thread makes no progress
  for 60s, abort the process at 5min so the orchestrator restarts a zombie
- Ack gating: PubSub listeners nack (redeliver) instead of acking when the
  commit pipeline is stalled or the queue is over depth
- libpq connect_timeout/keepalives/tcp_user_timeout/statement_timeout on pooled
  connections so a dead DB peer throws instead of blocking a thread forever
- Name controller threads (wchan/stack dumps become readable); commit queue
  depth and enqueue-to-commit latency gauges
2026-07-22 16:06:09 +02:00
Grant Limberg ca3d17ddb0 controller: log how long each BigTable batch write took
Timed in the worker around the BulkApply call; reported on the per-batch
completion line and the exception line.  Gives a direct client-observed
latency signal to compare against Bigtable's server-side metrics.
2026-07-21 16:54:09 +02:00
Grant Limberg 2e7e4a58a8 controller: write BigTable status batches from sync worker threads; re-queue failures
Replace AsyncBulkApply with synchronous BulkApply calls fanned out to a
small worker pool (8 threads, 500-row batches).  The async client path
makes progress only on the connection's shared background event threads,
which stall for tens of seconds at a time in production (observed
2026-07-21: 26k-row flushes taking 3.5-8 minutes against a near-idle
cluster with server-side MutateRows p99 of 50-80ms, completions arriving
in window-sized bursts).  A sync call is driven entirely by its own
thread and has months of healthy history in this environment.

Batches are built and their results processed on the calling thread, so
_lastNodeInfo and the re-queue list stay lock-free; workers only perform
the RPC and record the outcome.

Also stop dropping failed mutations: re-queue them for the next cycle
(idempotent replays via deterministic cell timestamps, backlog capped by
requeuePendingStatus) unless the status is INVALID_ARGUMENT.  This
covers transient per-mutation failures the client does not retry
internally, e.g. ACCESS_TOKEN_EXPIRED and UNAVAILABLE.
2026-07-21 16:29:10 +02:00
Grant Limberg b2bd72953a smaller parallel batches of writes 2026-07-21 10:48:19 +02:00
Grant Limberg 2f0cae4447 bootstrap-deps: force WITH_API_ONLY=OFF in the full OTel build
A stale .deps-build/otel CMake cache from an API-only run kept
WITH_API_ONLY=ON even under ZT_CONTROLLER_DEPS=1, silently installing an
API-only opentelemetry-cpp; the controller configure then fails with
"Component sdk is not a built component". Pass the flag explicitly so
the full build always overrides a cached value.
2026-07-21 02:15:57 +02:00
Grant Limberg 121ce0e8b9 controller: chunk BigTable status writes under the 100k mutation limit
Bigtable's MutateRows API rejects requests with more than 100,000
mutations total, and google-cloud-cpp sends a BulkMutation as a single
request -- it never splits by mutation count. writePending() built one
batch from every pending check-in (up to 5 SetCells per row), so a cold
node_info cache after a controller restart could push a single flush far
past the limit (observed: 124582). INVALID_ARGUMENT is permanent, so the
whole batch failed and those check-ins were dropped for the cycle.

Flush in chunks of at most 25,000 mutations. Failure handling is now
per-chunk: FailedMutation::original_index() aligns against a chunk-local
row-hash vector, and if BulkApply throws, only the not-yet-written tail
is re-queued so already-applied chunks are not replayed.
2026-07-21 02:15:46 +02:00
Grant Limberg 53acb42f11 controller: erase netconf request de-dup key if enqueue throws 2026-07-02 12:29:32 -07:00
Grant Limberg 54b61f3927 set max netconf queue length to 2M requests 2026-07-02 12:28:56 -07:00
Grant Limberg 4097f646a9 cap & de-dupe netconf request queue 2026-07-02 12:22:53 -07:00
Grant Limberg 9a0f635045 Set a minimum of 8 threads for netconf request handling in the Central controllers 2026-07-02 12:21:50 -07:00
Grant Limberg 50bfed682a don't do migrations via the startup script 2026-07-01 18:47:06 -07:00
Grant Limberg cb65567de3 Fix possible UB in calling operator[] on a const json& 2026-07-01 18:45:05 -07:00
Grant Limberg 5951981622 Merge pull request #2526 from zerotier/gl/ctl-pubsub
Add PubSub and BigTable support for Central hosted network controllers
2026-06-29 11:55:55 -07:00
Grant Limberg 1f6a1fd51f Remove ZT_CONTROLLER=1 from makefile. No longer used to build central
controllers
2026-06-29 11:13:40 -07:00
Grant Limberg edcc066d25 Add a SIGSEGV handler to print a stack trace for central controllers
Only enabled in the central controller builds.  Trying to find more info
about some mystery controller restarts in prod
2026-06-26 13:33:07 -07:00
Grant Limberg 0797626b3e Fix a potential crash on central controller shutdown 2026-06-26 13:32:09 -07:00
Grant Limberg 4bcff9d3e3 Fix the sso template for errors returned by IdP
Template was looking for {{networkId}} but that hadn't been populated
yet in the case where the IdP returned an error. This caused the
template parsing to crash and return its own error, disguising the error
from the IdP
2026-06-22 09:47:24 -07:00
Grant Limberg 64cc25baf6 bump actions to get rid of node warnings 2026-06-17 16:51:08 -07:00
Grant Limberg 8304ec79fe update documentation for ConnectionPool 2026-06-17 16:39:32 -07:00
Grant Limberg fcb016b9c1 standardize log formatting across the controller 2026-06-17 16:20:17 -07:00
Grant Limberg 75b51ec229 Ensure everything in nonfree/controller has the proper header comment
pointing to LICENSE.TXT
2026-06-17 13:50:44 -07:00
Grant Limberg 5640b82252 Update build.sh with build instructions
Also add presets for the BSDs
2026-06-17 13:39:22 -07:00
Grant Limberg ab9efc722c use the checkin timestamps for the cell timestamps in BigTable 2026-06-17 13:10:23 -07:00
Grant Limberg 4706ed9682 enable metrics by default for the central controller 2026-06-17 12:45:07 -07:00
Grant Limberg bf426497b0 Conneciton pool update to a timed wait on connection pool exhaustion
More use of scoped RAII guard for connections where appropriate.
2026-06-17 10:54:57 -07:00
Grant Limberg afd8a828df fix printf, connection pool smart pointer semantics, wait for ready spin
lock -> notification, and double notify on erase
2026-06-17 10:17:51 -07:00
Grant Limberg 7192b65a2c Correcting a few things 2026-06-17 09:59:20 -07:00
Grant Limberg 7be64c6bac Concurrency hygene updates 2026-06-17 09:48:18 -07:00
Grant Limberg 4a517e2d27 status update batch delivery reliablilty 2026-06-17 09:33:07 -07:00
Grant Limberg 6f57a77c43 Better connection handling for postgres status writer 2026-06-17 09:20:44 -07:00
Grant Limberg 8271fcadf2 Pubsub devlivery reliability updates 2026-06-17 09:12:15 -07:00
Grant Limberg 111228128f bugfixes 2026-06-17 08:46:15 -07:00
Grant Limberg fd98e0baa3 Addressing comments 2026-06-17 08:08:21 -07:00
Grant Limberg b6d5fb6fce set vcpagkage baseline and remove comment with text windows doesn't like 2026-06-15 18:54:41 -07:00
Grant Limberg c02c649cd3 more build updates.
removing openssl dependency (except on Linux where it's still necessary)
upgrade cpp-httplib
new cmake-presets
2026-06-15 18:51:24 -07:00
Grant Limberg ace5352388 Bump cpp-httplib so it supports win32 2026-06-15 17:41:09 -07:00
Grant Limberg deee555fbf fix deps so that architecture is taken into account 2026-06-15 17:27:00 -07:00
Grant Limberg 404fa9b2f9 fix incompatible options on crypto files in windows 2026-06-15 16:59:49 -07:00
Grant Limberg 4988d53d0e fix linking via CMake on Windows 2026-06-15 16:54:12 -07:00
Grant Limberg 14faaaa13e update to use makefiles by default on *ix 2026-06-15 16:48:58 -07:00
Grant Limberg 8ae153b44c Set thinkgs up for Windows in CMake
Also fixed a ZT_NONFREE issue
2026-06-15 16:22:17 -07:00
Grant Limberg f1c6a64035 build fix 2026-06-15 13:46:15 -07:00
Grant Limberg 0e637a1de6 More linux/mac cmake cleanup
* Brewfile for homebrew dependencies on macos
* Pull & build google-cloud-cpp/otel via bootstrap script rather than
  keeping it all in the ext/ subfolder.
* Update controller CI build with new steps
2026-06-15 12:59:32 -07:00
Grant Limberg e09e7b5c9b Fix PIC/PIE flags 2026-06-12 17:41:45 -07:00
Grant Limberg 052ea55636 bring CMake in line with make-linux/mac/bsd 2026-06-12 17:15:30 -07:00
Grant Limberg 378dd27361 main controller cmake file cleanup 2026-06-12 16:34:26 -07:00
Grant Limberg a4904c97b0 Repo cleanup.
* Remove now dead separate CV1/CV2 implementations.  Consolidated into
  CentralDB.
* Remove smeeclient.  No longer needed.
2026-06-12 16:23:04 -07:00
Grant Limberg 407bfdfd0b fix pubsub flood on ctl startup 2026-06-10 16:45:29 -07:00
Grant Limberg 85eec45372 remove db check from onlineNotificationThread 2026-06-10 15:46:12 -07:00
Grant Limberg fede9b9afb better logging of commit thread ticks
shows whats happening on each
2026-06-10 15:44:05 -07:00
Grant Limberg a3a45a75a7 Better data handling if a db write fails 2026-06-10 14:29:07 -07:00
Grant Limberg a001eba98f better closed connection handling to postgres 2026-06-10 14:05:46 -07:00
Grant Limberg af7c882315 perf(controller): drop per-row BigTable reads in status writer
writePending() did a synchronous ReadRow per queued node to avoid
rewriting unchanged os/arch/version. With thousands of check-ins per
cycle that's thousands of sequential round-trips every 10s, and the read
was nearly pointless since last_seen and the IP cell are written every
cycle anyway.

Replace it with an in-process cache of the last-written node_info per
row (keyed by a 64-bit hash of the row key). node_info is emitted only
when changed, new, or past its refresh window; check_in is still written
every cycle. Failed rows are dropped from the cache so they're rewritten
next cycle, and stale entries are evicted (24h TTL). Net result: one
BulkApply per cycle, no read RPCs.
2026-06-10 13:28:40 -07:00
Grant Limberg eec53a5866 Add handling sso networks for both CV1 & CV2 simultaneously 2026-06-02 14:54:55 -07:00
Grant Limberg 174130c080 More sso error logging & removing a few logs as well 2026-06-02 13:43:50 -07:00
Grant Limberg f76e6b916c This workflow does need to be removed from this branch.
once finally merged it'll be irrelevant.
2026-05-28 09:25:39 -07:00
Grant Limberg 3dffacc024 cargo fix 2026-05-28 09:12:38 -07:00
Grant Limberg 29f5464dbd Merge branch 'dev' into gl/ctl-pubsub 2026-05-28 08:49:48 -07:00
Grant Limberg 346dc907a1 remove noisy log 2026-05-28 08:03:07 -07:00
Grant Limberg b1427153aa handle nulls for remote trace target 2026-05-27 07:52:25 -07:00
Grant Limberg 80f5e81d8c ensure controller doesn't change assigned frontend 2026-05-19 11:09:02 -07:00
Grant Limberg 9a9a8c09c3 fix for missing field in json 2026-05-14 15:30:44 -07:00
Grant Limberg ac20c320cf update network.proto in line with CV1 and CV2 2026-05-14 13:07:13 -07:00
Grant Limberg 1c755845f0 align JSON keys between CentralDB and PubSub listener/writer
- Default enableBroadcast to true on load (initializeNetworks and _getNetwork) to match DB::initNetwork. Networks whose JSONB lacks the field now get broadcast on instead of off, which is the documented ZeroTier default.

- Stop overwriting networks_ctl.frontend on every UPDATE. It should remain whatever was set at INSERT. The early-exit guard already prevents cross-frontend writes from applying, so dropping the SET preserves correctness. Members are unaffected — they source frontend from the network row, not the change payload.

- Add enableBroadcast, creationTime, and revision to PubSubListener's network toJson. The protobuf carries them, but the listener was dropping them on inbound, which caused revision to reset on every PubSub-delivered network update.

- Rename member version keys to vMajor/vMinor/vRev/vProto in both PubSubListener (incoming) and PubSubWriter (outgoing). CentralDB, EmbeddedNetworkController, and the rest of the codebase already use these names; the listener/writer were the only sites using versionMajor/Minor/Rev/Protocol, so member version info was being silently dropped through PubSub in both directions.

- Pass newMember by const reference in ControllerChangeNotifier::notifyMemberChange to match notifyNetworkChange. Avoids a full JSON copy on every member notify.

- Remove duplicate nlohmann::json::parse call in RedisNetworkListener.
2026-05-13 11:01:39 -07:00
Grant Limberg 7b44e0a3a5 Fix json key inconsistency in pubsub writer 2026-05-13 10:40:02 -07:00
Grant Limberg b79592c71f Bugfix pass
ssoConfig checked wrong variable
DNS missing-branch wrote to input not output
SSO fields renamed to sso* and nested under ssoConfig (across CentralDB, DB defaults, migration_models)
Member identity populated into the right field; address = memberId
noAutoAssignIPs → noAutoAssignIps casing
Member version columns now SELECTed + populated (both sites)
removeTraceLevel typo in DB.cpp defaults
8. eraseMember uninitialized tmp2 — member deletes now actually delete
9. Connection leak on continue in both commit branches
10. Unsafe (uint64_t)config["revision"] cast → OSUtils::jsonInt
11. target = "NULL" literal text → std::optional<std::string> for real SQL NULL
~13 unsafe direct json→string casts → OSUtils::jsonString; dead vars removed from save(); change_source blocks use is_string() checks.
Heartbeat zadd literal "controllerId" → variable
Network revision double-increment removed
PubSub notifier now sees actual old state (DB query moved before INSERT in both branches)
_delete_network reads config["id"] instead of config["nwid"]
ip_assignments empty-string guards added at both sites (also closes G)
ensure last_modified is set on every write to networks & members
2026-05-13 10:28:15 -07:00
Grant Limberg f0522a7cdb fix a typo in some json handling that could be affecting an issue I'm tracking down 2026-05-08 10:58:05 -07:00
Grant Limberg 8c3a777108 addressing pr comments 2026-05-04 16:27:45 -07:00
Grant Limberg 23d395d781 change sso topic names for clarity 2026-04-30 09:41:24 -07:00
Grant Limberg 0e8ec661c8 make sure subscribe pulls stay running 2026-04-11 13:42:44 -07:00
Grant Limberg d2361a9a66 logging 2026-04-11 12:39:05 -07:00
Grant Limberg 910334c2a5 Fix silent PubSub message loss in controller subscription loop
The 10-second session.cancel() loop raced with in-flight acks — when
cancel fired while the GCP client was processing messages, acks were
lost before reaching the server. With message ordering enabled, an
unacked message blocks all subsequent messages on that ordering key,
causing silent stalls with no error output.

Two fixes:
- Replace the cancel/reconnect timer with a blocking session.get(),
  storing the session future so the destructor can cancel on shutdown.
- Always ack messages even when onNotification fails — permanent errors
  (bad protobuf, missing fields) will never succeed on retry and would
  otherwise poison the ordering key indefinitely.
2026-04-11 09:30:21 -07:00
Grant Limberg 4ca5c9b820 fix poison pill blocking proccessing 2026-04-11 07:40:11 -07:00
Grant Limberg 1f3a04f303 periodic queue size logging, and fix some db connection leaks 2026-04-03 10:28:28 -07:00
Grant Limberg af7eae5d9e Added a little bit more logging for the node checkin/bigtable write process 2026-04-03 09:52:55 -07:00
Grant Limberg ea5c91b0e9 Remove smee from CentralDB.
Now handled in CV1 on new member join via pubsub integration when a new member comes through
2026-04-02 10:04:23 -07:00
Grant Limberg 20f7311622 Skip redundant nonce sending with an expiry time of 0 2026-04-01 09:48:05 -07:00
Grant Limberg dd6e69f530 sso query fix in controller 2026-03-31 14:04:30 -07:00
Grant Limberg 78b25f4ae2 update settings to enable SSO networks 2026-03-31 13:24:03 -07:00
Grant Limberg 895b06033d temporary logging 2026-03-31 10:56:04 -07:00
Grant Limberg b047038ca1 print a message when the SSO PSK is configured 2026-03-31 08:48:00 -07:00
Grant Limberg 7ec42461d8 configure assigned central version in startup script 2026-03-19 11:57:35 -07:00
Grant Limberg e49b347a8f plumb through config changes for sso pubsub 2026-03-19 11:56:17 -07:00
Grant Limberg 7faf30d0cc another fix 2026-03-18 13:51:16 -07:00
Grant Limberg d9507dd895 Undo change to old migration that shouldn't have been made 2026-03-18 13:18:03 -07:00
Grant Limberg 2c57f85e25 add assigned_central_version column to controllers_ctl
Allow controllers to advertise which central version (cv1, cv2, or all)
they are assigned to handle via a new configurable field. The value is
persisted to the database on each heartbeat and validated at startup
against the DB CHECK constraint.
2026-03-17 16:30:25 -07:00
Grant Limberg a840b94e0d add SSO nonce/auth PubSub messaging with frontend routing
Publish CTL_NONCE_UPDATE to PubSub when nonces are created or reused in
getSSOAuthInfo(), with the network's frontend as a message attribute so
only the correct CV frontend receives it. Listen for ZT1_AUTH_UPDATE
messages and update sso_expiry.authentication_expiry_time accordingly,
with a network existence check before applying.

- Add sso_send_topic/sso_recv_topic to PubSubConfig
- Add PubSubWriter::publishSSONonceUpdate() with frontend param
- Add PubSubSSOListener class for inbound auth updates
- Rename CV1_AUTH_UPDATE to ZT1_AUTH_UPDATE in sso.proto
- Fix pre-existing connection pool leak in getSSOAuthInfo() catch block
2026-03-17 14:42:49 -07:00
Grant Limberg 03aa33bba7 set network member frontend based on the network its a member of 2026-03-12 09:20:05 -07:00
Grant Limberg 38f4d124b0 woops. out of order here 2026-02-25 15:04:40 -08:00
Grant Limberg 0ad6b19705 drop index 2026-02-25 14:37:27 -08:00
Grant Limberg ae7ee51b9d fix db migrations 2026-02-25 14:36:53 -08:00
Grant Limberg 0f0e6b3b16 add a linked_id column to the oidc_config table.
Required to get the list of configs  for a particular org that the controller has.  Named it `linked_id` rather than `org_id` since we don't know what it will be linked to in CV2
2026-02-25 13:37:04 -08:00
Grant Limberg c653e764b8 WIP: Update sso info retrieval method 2026-02-24 14:01:33 -08:00
Grant Limberg 35f7bf2291 disable peer metrics in Central controller 2026-01-23 13:06:02 -08:00
Grant Limberg ccb9a45d21 Remove extra verbose logging from controller 2026-01-23 11:53:06 -08:00
Grant Limberg 68a96344ed Merge branch 'dev' into gl/ctl-pusub 2026-01-23 11:18:45 -08:00
Grant Limberg 2ba50f4544 set --provenance false on docker build to try and fix docker image creation issue 2025-11-12 16:17:03 -08:00
Grant Limberg 50daf9537b controller build readme update 2025-11-11 18:40:58 -08:00
Grant Limberg 00dca6a2c0 Merge branch 'dev' into gl/ctl-pubsub 2025-11-06 10:01:11 -08:00
Grant Limberg 5c27068b80 Enable cross-service propagation of otel trace metadata 2025-10-30 13:47:50 +01:00
Grant Limberg 30c4484731 Set ordering key on pubsub message publishing. 2025-10-27 11:01:36 +01:00
Grant Limberg c21ff23477 Added some more logging to the ctl around deauths 2025-10-27 09:44:36 +01:00
Grant Limberg 76ba89060b ensure change source is controller if otherwise unset 2025-10-09 16:29:43 -07:00
Grant Limberg 77aa8c7bf8 missed one 2025-10-09 15:47:34 -07:00
Grant Limberg bf0fe2c09a these should be empty json arrays, not just "[]".
Actually these *should* be structs, not filling out json.  Adding this to the tech debt backlog
2025-10-09 15:39:40 -07:00
Grant Limberg 19ccc98f91 more variations on checking json 2025-10-09 15:28:48 -07:00
Grant Limberg e3f65ff359 compiler fix 2025-10-09 15:02:16 -07:00
Grant Limberg 47367673f9 more robustifying incoming messages 2025-10-09 14:47:25 -07:00
Grant Limberg 46a8cd7b67 robustify the handling of tags/capabilities/rules which are strings of encoded json 2025-10-09 14:39:46 -07:00
Grant Limberg 946d96f482 dont NACK failed messages. That gets us into a loop of failing the same messages over and over again 2025-10-09 14:34:24 -07:00
Grant Limberg b92fb93f8f Merge branch 'dev' into gl/ctl-pubsub 2025-10-06 16:55:28 -07:00
Grant Limberg 6b74bf289a fix assign mode json 2025-10-06 15:10:42 -07:00
Grant Limberg fe221b9359 debug output for IP addressing & fixing order of operations in a couple of places. Only send notification of a change to pubsub after it's been written to the DB 2025-10-06 14:24:57 -07:00
Grant Limberg 6df7366753 no need for these timeouts 2025-10-02 16:00:08 -07:00
Grant Limberg 1ef7ea0fe6 Fixing more JSON issues 2025-10-02 15:04:57 -07:00
Grant Limberg 18714c7785 add explicit nack if there's an error processing a pubsub message 2025-10-02 11:56:44 -07:00
Grant Limberg a75d06ad64 cleaning up some gross JSON code 2025-10-02 11:35:03 -07:00
Grant Limberg 4861b7df1e one last json parsing fix. but really this time 2025-10-01 17:18:31 -07:00
Grant Limberg 0d21250b62 one last json parsing fix 2025-10-01 16:33:17 -07:00
Grant Limberg 3bbf194594 pubsub writer should work now 2025-10-01 16:25:27 -07:00
Grant Limberg fb75369597 throwing stuff at the wall cuz I can't actually debug this right now 2025-10-01 16:08:06 -07:00
Grant Limberg a8b5c89efa think this is where things are crashing, but I'm not sure why yet. Comment it out to make sure 2025-10-01 15:05:34 -07:00
Grant Limberg 80f82132dd fix tags/capabilities? 2025-10-01 14:00:17 -07:00
Grant Limberg 7faf705e10 make the default an empty array here 2025-10-01 13:33:02 -07:00
Grant Limberg 1f557b516f more debug output 2025-10-01 13:30:25 -07:00
Grant Limberg aecd7fdace more logging 2025-10-01 13:13:58 -07:00
Grant Limberg dad1a1eda6 more logging 2025-10-01 13:12:45 -07:00
Grant Limberg f028213c7f debug output 2025-10-01 12:40:50 -07:00
Grant Limberg b4f018b918 debug output from parsing pubsub messages 2025-10-01 09:07:08 -07:00
Grant Limberg 20a67ab1de fix attempted null -> string conversion 2025-10-01 08:06:40 -07:00
Grant Limberg 02908e5202 stray ` got in there 2025-09-30 10:52:00 -07:00
Grant Limberg 97d20a1155 more logging for errors on pubsub listener 2025-09-30 10:32:21 -07:00
Grant Limberg 315bf240fc json field fix 2025-09-25 16:34:08 -07:00
Grant Limberg c6b7c263d2 query fix for new networks 2025-09-25 16:09:57 -07:00
Grant Limberg e51e516f85 fix subscription creation 2025-09-25 15:38:28 -07:00
Grant Limberg 069d7c1862 set objtype on messages received via PubSub 2025-09-25 15:14:30 -07:00
Grant Limberg 6196e87303 only create the subscription if pubsub emulator is being used. 2025-09-22 16:32:28 -07:00
Grant Limberg d96d3b27d2 try making the controller attach to an existing pubsub subscription if it already exists 2025-09-22 10:52:06 -07:00
Grant Limberg 6113bad61e make pubsub topics configurable
Also for pubsub trips back to CV1/CV2, rather than having 2 queues for each service (networks & members), theres now only a single queue for each change type, and `frontend = (cv1|cv2)` attribute is set on the message for filtering.
2025-09-18 09:33:04 -07:00
Grant Limberg cb2de5aae1 fix migration 2025-09-13 10:29:45 -07:00
Grant Limberg ad1fc5fb3d add tables for the controller load log and sso nonces & expiry 2025-09-13 10:05:20 -07:00
Grant Limberg 1ce37e7770 add use_for_new_networks column in controller table 2025-09-11 10:02:45 -07:00
Grant Limberg 493cc4fe4f fix version string 2025-09-10 08:13:56 -07:00
Grant Limberg 7aa451bec1 clean up deprecation warnings in pqxx 2025-09-10 07:43:21 -07:00
Grant Limberg 012443acfa wire up pubsub notifications from controller to frontend 2025-09-08 16:01:50 -07:00
Grant Limberg ee87eb3101 removing some log output 2025-09-08 11:34:03 -07:00
Grant Limberg facca364fb only update os, architecture and client version if they've changed (or don't exist) 2025-09-08 11:00:17 -07:00
Grant Limberg 1d65c1e43e back to bulk apply for status updates in BigTable 2025-09-08 10:50:10 -07:00
Grant Limberg 1ba4ccd98d pass version info to status writer 2025-09-08 10:46:01 -07:00
Grant Limberg 934aa93ef8 forgot a ; 2025-09-08 10:32:57 -07:00
Grant Limberg 88f08fa58c append 8 random hex chars to the subscription id 2025-09-08 10:29:30 -07:00
Grant Limberg f51bfdb666 delete pubsub subscription on shutdown 2025-09-08 10:25:32 -07:00
Grant Limberg 190d836b42 alloc meatadata with new so pubsub can delete it 2025-09-08 09:49:26 -07:00
Grant Limberg 006ced2900 more fixes 2025-09-08 09:05:00 -07:00
Grant Limberg ebf66b7920 fix typo in cmake file 2025-09-08 08:53:35 -07:00
Grant Limberg 71d68e9a60 fix stack corruption in DB::get 2025-09-08 08:49:23 -07:00
Grant Limberg a78ac17d10 fix compile & link on macOS 2025-09-06 15:02:59 -07:00
Grant Limberg 36219c59ae compiler on mac doesn't like this. not really needed though 2025-09-06 15:02:48 -07:00
Grant Limberg 69efa924e2 apply patch to libnatpmp repo so we can compile on macOS with CMake 2025-09-06 15:01:48 -07:00
Grant Limberg 3d72a43a19 misc bugfixes 2025-09-06 12:37:28 -07:00
Grant Limberg 7ad264df92 whoops. mesed up the migrate naming convention 2025-09-05 15:20:33 -07:00
Grant Limberg 024824c2fe wire up pubsub outgoing status changes from controller -> CV2 2025-09-05 14:52:16 -07:00
Grant Limberg 74f0525470 Add frontend column to networks & network_memberships tables so the controller knows which system owns the networks & members 2025-09-05 08:43:06 -07:00
Grant Limberg ba6200fb96 add a ChangeSource enum to the change protobuf messages 2025-09-05 08:19:32 -07:00
Grant Limberg 282d7c7f9d another fix 2025-09-04 17:45:38 -07:00
Grant Limberg 48ff61b392 fix 2025-09-04 17:28:14 -07:00
Grant Limberg a061c86594 fix 2025-09-04 17:00:15 -07:00
Grant Limberg a18e370d48 another query fix 2025-09-04 16:31:16 -07:00
Grant Limberg e9565cf97c another query fix 2025-09-04 16:12:21 -07:00
Grant Limberg 3b7958aec1 another query fix 2025-09-04 16:07:28 -07:00
Grant Limberg 20746b2754 query fix 2025-09-04 15:41:33 -07:00
Grant Limberg b16d9372b8 fix otel exporting 2025-09-04 15:11:57 -07:00
Grant Limberg f208007226 enable otel exporter 2025-09-04 14:48:04 -07:00
Grant Limberg dcd583f62b cleanup controller github action 2025-09-04 14:47:58 -07:00
Grant Limberg 3616c4026b move up the gcp auth step 2025-09-04 14:23:49 -07:00
Grant Limberg 67526d494a move up docker auth 2025-09-04 14:15:51 -07:00
Grant Limberg 8bd96d360f build in containers 2025-09-04 14:14:59 -07:00
Grant Limberg 70d24fc7eb trying to build in a docker container 2025-09-04 14:02:58 -07:00
Grant Limberg 40f6508717 add conda builder dockerfile 2025-09-04 13:50:11 -07:00
Grant Limberg 7d5a60b44e will this make arm64 containers work? 2025-09-04 13:08:27 -07:00
Grant Limberg 2264452ad8 try to make this work on both x64 & arm64 2025-09-04 12:19:53 -07:00
Grant Limberg 73e3287fd6 debugging runtime link issues on arm64 2025-09-04 12:14:32 -07:00
Grant Limberg f33e706887 get a running controller in docker 2025-09-04 11:42:53 -07:00
Grant Limberg 686653509a debug printf 2025-09-04 11:27:59 -07:00
Grant Limberg ce84de605d and instead of or in postgres check 2025-09-04 11:24:01 -07:00
Grant Limberg 7e4e7ef753 fix case for redis: null 2025-09-04 11:19:22 -07:00
Grant Limberg b94fa2d95d . 2025-09-04 11:18:08 -07:00
Grant Limberg c9c8e95d60 debug output of main script 2025-09-04 11:16:48 -07:00
Grant Limberg d216a3739f run process in conda env directly from docker 2025-09-04 11:14:34 -07:00
Grant Limberg 092fc268d3 ok back to full path 2025-09-04 11:11:14 -07:00
Grant Limberg 1da9e24905 no absolute path for pg_isready 2025-09-04 11:03:30 -07:00
Grant Limberg 158d24545a also have to add postgres to the container for pg_isready 2025-09-04 10:30:08 -07:00
Grant Limberg 96aa893df4 stray backtick 2025-09-04 09:50:19 -07:00
Grant Limberg 4516e6a340 need a conda init here first apparently 2025-09-04 09:27:08 -07:00
Grant Limberg 2416c42df7 change tag to match existing 2025-09-04 08:48:54 -07:00
Grant Limberg 4f07599992 add jemalloc 2025-09-03 15:04:51 -07:00
Grant Limberg 6ceb8eac97 text alignment 2025-09-03 13:56:32 -07:00
Grant Limberg 3ad352c08e no trailing comma on bigtable block 2025-09-03 13:56:04 -07:00
Grant Limberg 9d73c346b7 new modified startup script for central controller docker images with support for configuring bigtable, pubsub, redis 2025-09-03 13:48:38 -07:00
Grant Limberg 4abf90247d update ld.so.conf for paths to libraries 2025-09-03 13:22:21 -07:00
Grant Limberg 594d227f92 fix multi-arch manifest creation 2025-09-03 12:18:21 -07:00
Grant Limberg 7fd112eb4f fix short hash 2025-09-03 11:50:09 -07:00
Grant Limberg 000f3d5a8c let's build a docker image 2025-09-03 11:37:26 -07:00
Grant Limberg 3f3e684811 only update conda env if cache was not hit 2025-09-03 10:42:22 -07:00
Grant Limberg a841e96bd2 put git branch ref into cache key name 2025-09-03 10:40:31 -07:00
Grant Limberg 3ff4d67d21 bump 2025-09-03 10:29:53 -07:00
Grant Limberg b09956ae59 fix run arg 2025-09-03 10:28:42 -07:00
Grant Limberg 4395574706 cache conda environment 2025-09-03 10:27:06 -07:00
Grant Limberg 1dae4c4c5f cache conda environment 2025-09-03 10:23:33 -07:00
Grant Limberg d31b3a08db set ZT_AES_NEON for arm64 2025-09-03 10:08:16 -07:00
Grant Limberg 0f3a5148b1 fix deps for selftest 2025-09-03 09:29:33 -07:00
Grant Limberg d3f1ec74ba fix arm64 build flag 2025-09-03 09:20:13 -07:00
Grant Limberg 3470ceb13d cmake --build args 2025-09-03 09:12:04 -07:00
Grant Limberg 648f0915e5 skip cmake action 2025-09-03 09:09:17 -07:00
Grant Limberg 21e20f2104 more conda 2025-09-03 09:04:40 -07:00
Grant Limberg f43bc3d10c more conda 2025-09-03 09:00:36 -07:00
Grant Limberg 3ad36c773d fix cmake options 2025-09-03 08:55:29 -07:00
Grant Limberg 22484c708f dependency juggling 2025-09-03 08:51:21 -07:00
Grant Limberg cab33dfc89 no linux/arm64 build available for google-cloud-cpp 2.39 :/. Downgrade to 2.38 2025-09-03 08:45:33 -07:00
Grant Limberg e1db40d932 test 2025-09-03 08:39:02 -07:00
Grant Limberg 97681b589e trying to get this working 2025-09-03 08:37:30 -07:00
Grant Limberg 09f1ee77e1 skip caching until this all works 2025-09-03 08:26:08 -07:00
Grant Limberg 0f13363895 runs-on matrix 2025-09-03 08:22:47 -07:00
Grant Limberg 7c1bfc97c4 setup github action for building 2025-09-03 08:18:56 -07:00
Grant Limberg 2a647d497a remove otel warning 2025-09-02 16:25:16 -07:00
Grant Limberg 70f9fe0412 update central controller readme with config block 2025-09-02 14:15:28 -07:00
Grant Limberg 0753556aa3 wire up configuration.
New config block in local.conf for controllers:

```
{
  "settings": {
    ...standard zt1 local.conf settings...
  },
  "controller": {
    "listenMode": (pgsql|redis|pubsub),
    "statusMode": (pgsql|redis|bigtable),
    "redis": {
      "hostname": ...,
      "port": 6379,
      "clusterMode": true
    },
    "pubsub": {
      "project_id": <gcp-project-id>
    },
    "bigtable": {
      "project_id": <gcp-project-id>,
      "instance_id": <bigtable-instance-id>,
      "table_id": <bigtable-table-id>
    }
  }
}
```
2025-09-02 14:06:24 -07:00
Grant Limberg a5bd262b3a Wiring through initialization of the CentralDB version of the controller
Still need to do the actual configuration from local.conf
2025-09-02 13:30:08 -07:00
Grant Limberg 4ddb1fbe58 Create the pubsub topic if it doesn't exist 2025-09-02 07:49:41 -07:00
Grant Limberg 195d5b47f0 Merge branch 'adam/1.16' into gl/ctl-pubsub 2025-09-01 16:47:55 -07:00
Grant Limberg 496e69e666 add def for new style controllers 2025-09-01 15:29:27 -07:00
Grant Limberg 0f63783592 remove rust-based pubsub 2025-09-01 14:55:16 -07:00
Grant Limberg db6e698245 rework the pubsub listener again so the subscription is set up on its own thread 2025-09-01 14:40:18 -07:00
Grant Limberg b114896e7b PubSub to gcloud-cpp library for simplicity's sake 2025-09-01 14:25:15 -07:00
Grant Limberg 17b48d78cb Merge branch 'dev' into gl/ctl-pubsub 2025-09-01 09:50:15 -07:00
Grant Limberg e347f895b8 add sleep at end of online notificaiton loop 2025-09-01 09:44:39 -07:00
Grant Limberg d119547a95 wire up status writers 2025-09-01 09:18:01 -07:00
Grant Limberg 85f23356a3 add a StatusWriter class hierarchy for writing member status updates
* Postgres Direct
* Redis
* BigTable
2025-08-28 17:03:59 -07:00
Grant Limberg 3187c2ffce clang format change (not applied project-wide yet) 2025-08-28 17:00:06 -07:00
Grant Limberg 9bdd564bdc spacing 2025-08-27 16:23:55 -07:00
Grant Limberg 7f3b15011e Update central controller build to use CMake + conda
Muuuuch easier to use external dependencies now

Also tried out conan and vcpkg.   Ran into dependency issues when solving for packages to install with conan.

vcpkg is just obtuse as all hell to install and not easy to integrate
2025-08-27 16:23:02 -07:00
Grant Limberg f8a4a5d6af rework protobuf messages
PubSub allows us to do schema validation, however it only allows one top level message at a time.  Move other sub-message declarations under the main message declaration so that we can enable schema validation in the pubsub stream directly
2025-08-25 15:09:10 -07:00
Grant Limberg 2833d0e4f4 make whether SSO is enabled a switchable config value 2025-08-20 17:07:56 -07:00
Grant Limberg 95224379aa Refactor Redis & Posgres notification listeners into listener subclass in new CentralDB class
This allows us to interchangeably use different listeners (pgsql, redis, pubsub) depending on configuration values passed into the constructor.
2025-08-20 17:04:28 -07:00
Grant Limberg ebe8fdb08e rename classes 2025-08-20 10:07:13 -07:00
Grant Limberg 650fc0c74b Add C++ wrapper around pubsub listeners 2025-08-15 16:53:58 -07:00
Grant Limberg b90ad51723 more calling async from non-async changes 2025-08-15 08:22:55 -07:00
Grant Limberg 4237830a97 revert default feature list once again 2025-08-14 14:25:19 -07:00
Grant Limberg 4fab227c23 fix calling into async functions from non-async via the FFI 2025-08-14 14:20:34 -07:00
Grant Limberg e4147f7b80 fix build script 2025-08-14 13:00:11 -07:00
Grant Limberg d4ee95e445 feature cleanup 2025-08-14 12:51:22 -07:00
Grant Limberg a842ad8b61 remove ztcontroller from default feature list 2025-08-14 12:43:42 -07:00
Grant Limberg 3a209e2930 expose change_handler to C via FFI 2025-08-14 12:43:00 -07:00
Grant Limberg ccb0fa748f updates & tests.
Tests currently need to be run with --test-threads=1.  Seems like the instances of the pubsub emulator stomp on each other without that
2025-08-14 12:31:42 -07:00
Grant Limberg bf8c9d0124 function naming cleanup.
match other things already written
2025-08-13 12:25:36 -07:00
Grant Limberg 0e94891e5b plumb through callbacks 2025-08-13 12:17:03 -07:00
Grant Limberg 06b2ce9f30 WIP: pubsub wrapper in Rust 2025-08-12 10:42:07 -07:00
Grant Limberg f079f8bc82 cleanup warnings 2025-08-11 11:31:15 -07:00
Grant Limberg 837f15d01b tokio is needed by both temporal & gcloud pubsub, so make just one instance for the whole library, add init/shutdown functions for it exposed to C 2025-08-07 11:28:22 -07:00
Grant Limberg 4b3b847c7f fix windows bui ld 2025-08-05 16:38:57 -07:00
Grant Limberg a55216310a fix macos build 2025-08-05 16:18:21 -07:00
Grant Limberg 44d0e81572 gcloud-pubsub only if ztcontroller is flagged 2025-08-05 16:07:26 -07:00
Grant Limberg f9500ca5ff fix dependencies when temporal isn't needed 2025-08-05 16:05:51 -07:00
Grant Limberg e822811f29 reorganize rustybits into a single library with smeeclient behind the ztcontroller feature flag 2025-08-05 15:52:58 -07:00
1409 changed files with 10699 additions and 191567 deletions

No files matched your search

+46 -47
View File
@@ -4,72 +4,71 @@ BreakBeforeBraces: Stroustrup
IndentWidth: 4
TabWidth: 4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignConsecutiveMacros: "true"
AlignConsecutiveAssignments: "false"
AlignConsecutiveDeclarations: "false"
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'false'
AlignOperands: "true"
AlignTrailingComments: "true"
AllowAllArgumentsOnNextLine: "false"
AllowAllConstructorInitializersOnNextLine: "false"
AllowAllParametersOfDeclarationOnNextLine: "false"
AllowShortBlocksOnASingleLine: "true"
AllowShortCaseLabelsOnASingleLine: "false"
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AlwaysBreakAfterReturnType: None
BinPackArguments: 'false'
BinPackParameters: 'false'
BinPackArguments: "true"
BinPackParameters: OnePerLine
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: 'true'
BreakBeforeTernaryOperators: "true"
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'false'
FixNamespaceComments: 'true'
CompactNamespaces: "false"
ConstructorInitializerAllOnOneLineOrOnePerLine: "true"
ConstructorInitializerIndentWidth: "4"
ContinuationIndentWidth: "4"
Cpp11BracedListStyle: "false"
FixNamespaceComments: "true"
IncludeBlocks: Regroup
IndentCaseLabels: 'true'
IndentCaseLabels: "true"
IndentPPDirectives: None
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
MaxEmptyLinesToKeep: '1'
IndentWrappedFunctionNames: "false"
KeepEmptyLinesAtTheStartOfBlocks: "false"
MaxEmptyLinesToKeep: "1"
NamespaceIndentation: None
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterLogicalNot: 'true'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
ReflowComments: "true"
SortIncludes: "true"
SortUsingDeclarations: "true"
SpaceAfterCStyleCast: "false"
SpaceAfterLogicalNot: "true"
SpaceAfterTemplateKeyword: "true"
SpaceBeforeAssignmentOperators: "true"
SpaceBeforeCpp11BracedList: "true"
SpaceBeforeCtorInitializerColon: "true"
SpaceBeforeInheritanceColon: "true"
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '3'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'true'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
UseTab: 'Always'
SpaceBeforeRangeBasedForLoopColon: "true"
SpaceInEmptyParentheses: "false"
SpacesBeforeTrailingComments: "3"
SpacesInAngles: "false"
SpacesInCStyleCastParentheses: "false"
SpacesInContainerLiterals: "true"
SpacesInParentheses: "false"
SpacesInSquareBrackets: "false"
UseTab: "Always"
---
Language: Cpp
Standard: Cpp03
ColumnLimit: '240'
ColumnLimit: "120"
---
Language: ObjC
ColumnLimit: '240'
ColumnLimit: "120"
---
Language: Java
ColumnLimit: '240'
ColumnLimit: "120"
---
Language: CSharp
ColumnLimit: '240'
...
ColumnLimit: "120"
+10
View File
@@ -1,2 +1,12 @@
.git/
workspace/
# Local from-source dependency builds (scripts/bootstrap-deps.sh) and CMake output;
# never ship these into an image -- they are host-specific and large.
.deps/
.deps-build/
build/
build-*/
out/
# Dockerfiles are supplied via -f; keeping them out of the context means editing
# them does not invalidate the COPY layers (and the heavy build cache).
ext/central-controller-docker/Dockerfile*
@@ -1,67 +0,0 @@
name: Central Controller CV1 Build and Push
on:
push:
pull_request:
workflow_dispatch:
jobs:
central_controller:
name: Central Controller CV1 Build
strategy:
matrix:
runner: [gha-runner-x64, gha-runner-arm64]
runs-on: ${{ matrix.runner }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Docker Auth
run: echo "${{ secrets.PORTUS_PW }}" | docker login registry.zerotier.com -u ${{ secrets.PORTUS_USER }} --password-stdin
- name: Get branch name and sanitize
id: branch
run: |
BRANCH_NAME="${GITHUB_REF##*/}"
SANITIZED_BRANCH="${BRANCH_NAME//\//-}"
echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT
- name: Get short git commit SHA
id: sha
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Build & Push Docker Image
run: |
docker build --provenance false --no-cache -t registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile . --push
multi-arch-docker:
runs-on: gha-runner-x64
needs: central_controller
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Auth
run: echo "${{ secrets.PORTUS_PW }}" | docker login registry.zerotier.com -u ${{ secrets.PORTUS_USER }} --password-stdin
- name: Get branch name and sanitize
id: branch
run: |
BRANCH_NAME="${GITHUB_REF##*/}"
SANITIZED_BRANCH="${BRANCH_NAME//\//-}"
echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT
- name: Get short git commit SHA
id: sha
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Create and push multi-arch manifest
run: |
docker manifest create registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \
--amend registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \
--amend registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64
docker manifest push registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}
+104
View File
@@ -0,0 +1,104 @@
# on:
# workflow_dispatch:
on:
push:
workflow_dispatch:
jobs:
central_controller:
name: Central Controller Build
strategy:
matrix:
runner: [gha-runner-x64, gha-runner-arm64]
runs-on: ${{ matrix.runner }}
steps:
- name: checkout
uses: actions/checkout@v6
- name: GCP Auth
uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}}
- name: Set up GCloud CLI
uses: google-github-actions/setup-gcloud@v3
with:
# v3 no longer uses the tool cache by default; restore the prior caching
# behavior on these self-hosted runners (perf: avoids re-fetching the SDK).
cache: true
- name: Docker Auth
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- name: Get branch name and sanitize
id: branch
run: |
BRANCH_NAME="${GITHUB_REF##*/}"
SANITIZED_BRANCH="${BRANCH_NAME//\//-}"
echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT
- name: Get short git commit SHA
id: sha
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build & Push Docker Image
# Registry layer cache (mode=max) so the expensive builder stage -- which
# builds opentelemetry-cpp + google-cloud-cpp from source -- is reused across
# runs and fresh runners. The cache invalidates automatically when the
# bootstrap inputs change. Cache is per-arch (the deps layer is arch-specific).
run: |
CACHE=us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller-buildcache:${{ runner.arch }}
docker buildx build \
-t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} \
-f ext/central-controller-docker/Dockerfile \
--cache-from type=registry,ref=$CACHE \
--cache-to type=registry,ref=$CACHE,mode=max \
--provenance false \
--push .
multi-arch-docker:
runs-on: gha-runner-x64
needs: central_controller
steps:
- name: Checkout
uses: actions/checkout@v6
- name: GCP Auth
uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}}
- name: Set up GCloud CLI
uses: google-github-actions/setup-gcloud@v3
with:
# v3 no longer uses the tool cache by default; restore the prior caching
# behavior on these self-hosted runners (perf: avoids re-fetching the SDK).
cache: true
- name: Docker Auth
run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet
- name: Get branch name and sanitize
id: branch
run: |
BRANCH_NAME="${GITHUB_REF##*/}"
SANITIZED_BRANCH="${BRANCH_NAME//\//-}"
echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT
- name: Get short git commit SHA
id: sha
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Create and push multi-arch manifest
run: |
docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \
--amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \
--amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64
docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}
+7 -2
View File
@@ -143,6 +143,11 @@ __pycache__
*.pyc
*_source.tar.bz2
snap/.snapcraft
build/
# local Claude configurations
.claude/*.local.*
# Local dependency bootstrap output (scripts/bootstrap-deps.sh): the install
# prefix and the build/clone scratch dir. Large + host-specific; never commit.
.deps/
.deps-build/
.claude/*.local.*
+28
View File
@@ -0,0 +1,28 @@
# Central Controller build dependencies for macOS development.
#
# brew bundle # install the deps below
# ZT_CONTROLLER_DEPS=1 scripts/bootstrap-deps.sh # build the two pinned controller deps (full OTel + google-cloud-cpp)
#
# The two version-sensitive C++ libraries (opentelemetry-cpp, google-cloud-cpp)
# are NOT taken from Homebrew -- they are pinned and built from source by
# scripts/bootstrap-deps.sh so every dev/CI machine uses the same versions
# (the role conda previously filled). Everything below is stable enough to take
# from Homebrew.
brew "cmake"
brew "ninja"
brew "pkg-config"
brew "rustup-init" # then: rustup-init -y && rustup default stable
brew "libpqxx"
brew "libpq" # keg-only; add $(brew --prefix libpq) to CMAKE_PREFIX_PATH so find_package(PostgreSQL) resolves
brew "hiredis"
brew "jemalloc"
brew "nlohmann-json"
brew "openssl@3"
brew "abseil"
brew "protobuf"
brew "grpc"
brew "googletest" # google-cloud-cpp requires GTest/GMock at configure (builds its *_mocks libs)
brew "curl"
brew "inja"
+676 -7
View File
File diff suppressed because it is too large. Load diff
+167
View File
@@ -0,0 +1,167 @@
{
"version": 3,
"cmakeMinimumRequired": { "major": 3, "minor": 21, "patch": 0 },
"configurePresets": [
{
"name": "unix-base",
"hidden": true,
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build-${presetName}",
"cacheVariables": {
"CMAKE_PREFIX_PATH": "${sourceDir}/.deps",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-base",
"hidden": true,
"inherits": "unix-base",
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux" }
},
{
"name": "macos-base",
"hidden": true,
"inherits": "unix-base",
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Darwin" },
"cacheVariables": {
"CMAKE_PREFIX_PATH": "${sourceDir}/.deps;$env{HOMEBREW_PREFIX};$env{HOMEBREW_PREFIX}/opt/openssl@3;$env{HOMEBREW_PREFIX}/opt/libpq"
}
},
{ "name": "linux-release", "inherits": "linux-base", "displayName": "Linux daemon (Release)" },
{ "name": "linux-debug", "inherits": "linux-base", "displayName": "Linux daemon (Debug)", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "linux-controller-release", "inherits": "linux-base", "displayName": "Linux Central Controller (Release)", "cacheVariables": { "ZT1_CENTRAL_CONTROLLER": "ON" } },
{ "name": "linux-controller-debug", "inherits": "linux-base", "displayName": "Linux Central Controller (Debug)", "cacheVariables": { "ZT1_CENTRAL_CONTROLLER": "ON", "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "linux-free-release", "inherits": "linux-base", "displayName": "Linux daemon, free / no controller (Release)", "cacheVariables": { "ZT_NONFREE": "OFF" } },
{ "name": "linux-free-debug", "inherits": "linux-base", "displayName": "Linux daemon, free / no controller (Debug)", "cacheVariables": { "ZT_NONFREE": "OFF", "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "macos-release", "inherits": "macos-base", "displayName": "macOS daemon (Release)" },
{ "name": "macos-debug", "inherits": "macos-base", "displayName": "macOS daemon (Debug)", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "macos-controller-release", "inherits": "macos-base", "displayName": "macOS Central Controller (Release)", "cacheVariables": { "ZT1_CENTRAL_CONTROLLER": "ON" } },
{ "name": "macos-controller-debug", "inherits": "macos-base", "displayName": "macOS Central Controller (Debug)", "cacheVariables": { "ZT1_CENTRAL_CONTROLLER": "ON", "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "macos-free-release", "inherits": "macos-base", "displayName": "macOS daemon, free / no controller (Release)", "cacheVariables": { "ZT_NONFREE": "OFF" } },
{ "name": "macos-free-debug", "inherits": "macos-base", "displayName": "macOS daemon, free / no controller (Debug)", "cacheVariables": { "ZT_NONFREE": "OFF", "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "macos-universal-release", "inherits": "macos-base", "displayName": "macOS universal daemon (arm64 + x86_64, Release)", "cacheVariables": { "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64" } },
{ "name": "macos-universal-debug", "inherits": "macos-base", "displayName": "macOS universal daemon (arm64 + x86_64, Debug)", "cacheVariables": { "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64", "CMAKE_BUILD_TYPE": "Debug" } },
{
"name": "freebsd-base",
"hidden": true,
"inherits": "unix-base",
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "FreeBSD" }
},
{
"name": "openbsd-base",
"hidden": true,
"inherits": "unix-base",
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "OpenBSD" }
},
{
"name": "netbsd-base",
"hidden": true,
"inherits": "unix-base",
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "NetBSD" }
},
{ "name": "freebsd-release", "inherits": "freebsd-base", "displayName": "FreeBSD daemon (Release)" },
{ "name": "freebsd-debug", "inherits": "freebsd-base", "displayName": "FreeBSD daemon (Debug)", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "freebsd-free-release", "inherits": "freebsd-base", "displayName": "FreeBSD daemon, free / no controller (Release)", "cacheVariables": { "ZT_NONFREE": "OFF" } },
{ "name": "freebsd-free-debug", "inherits": "freebsd-base", "displayName": "FreeBSD daemon, free / no controller (Debug)", "cacheVariables": { "ZT_NONFREE": "OFF", "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "openbsd-release", "inherits": "openbsd-base", "displayName": "OpenBSD daemon (Release)" },
{ "name": "openbsd-debug", "inherits": "openbsd-base", "displayName": "OpenBSD daemon (Debug)", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "openbsd-free-release", "inherits": "openbsd-base", "displayName": "OpenBSD daemon, free / no controller (Release)", "cacheVariables": { "ZT_NONFREE": "OFF" } },
{ "name": "openbsd-free-debug", "inherits": "openbsd-base", "displayName": "OpenBSD daemon, free / no controller (Debug)", "cacheVariables": { "ZT_NONFREE": "OFF", "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "netbsd-release", "inherits": "netbsd-base", "displayName": "NetBSD daemon (Release)" },
{ "name": "netbsd-debug", "inherits": "netbsd-base", "displayName": "NetBSD daemon (Debug)", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "netbsd-free-release", "inherits": "netbsd-base", "displayName": "NetBSD daemon, free / no controller (Release)", "cacheVariables": { "ZT_NONFREE": "OFF" } },
{ "name": "netbsd-free-debug", "inherits": "netbsd-base", "displayName": "NetBSD daemon, free / no controller (Debug)", "cacheVariables": { "ZT_NONFREE": "OFF", "CMAKE_BUILD_TYPE": "Debug" } },
{
"name": "windows-x64",
"displayName": "Windows x64 daemon (MSVC + vcpkg)",
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"binaryDir": "${sourceDir}/build-${presetName}",
"condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows" },
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"CMAKE_PREFIX_PATH": "${sourceDir}/.deps/x64"
}
},
{
"name": "windows-arm64",
"inherits": "windows-x64",
"displayName": "Windows ARM64 daemon (MSVC + vcpkg)",
"architecture": "ARM64",
"cacheVariables": { "VCPKG_TARGET_TRIPLET": "arm64-windows-static", "CMAKE_PREFIX_PATH": "${sourceDir}/.deps/ARM64" }
},
{
"name": "windows-x86",
"inherits": "windows-x64",
"displayName": "Windows x86 daemon (MSVC + vcpkg)",
"architecture": "Win32",
"cacheVariables": { "VCPKG_TARGET_TRIPLET": "x86-windows-static", "CMAKE_PREFIX_PATH": "${sourceDir}/.deps/Win32" }
},
{
"name": "windows-x64-free",
"inherits": "windows-x64",
"displayName": "Windows x64 daemon (free / ZT_NONFREE=OFF, no bundled controller)",
"cacheVariables": { "ZT_NONFREE": "OFF" }
},
{
"name": "windows-arm64-free",
"inherits": "windows-arm64",
"displayName": "Windows ARM64 daemon (free / ZT_NONFREE=OFF, no bundled controller)",
"cacheVariables": { "ZT_NONFREE": "OFF" }
},
{
"name": "windows-x86-free",
"inherits": "windows-x86",
"displayName": "Windows x86 daemon (free / ZT_NONFREE=OFF, no bundled controller)",
"cacheVariables": { "ZT_NONFREE": "OFF" }
}
],
"buildPresets": [
{ "name": "linux-release", "configurePreset": "linux-release" },
{ "name": "linux-debug", "configurePreset": "linux-debug" },
{ "name": "linux-controller-release", "configurePreset": "linux-controller-release" },
{ "name": "linux-controller-debug", "configurePreset": "linux-controller-debug" },
{ "name": "linux-free-release", "configurePreset": "linux-free-release" },
{ "name": "linux-free-debug", "configurePreset": "linux-free-debug" },
{ "name": "macos-release", "configurePreset": "macos-release" },
{ "name": "macos-debug", "configurePreset": "macos-debug" },
{ "name": "macos-controller-release", "configurePreset": "macos-controller-release" },
{ "name": "macos-controller-debug", "configurePreset": "macos-controller-debug" },
{ "name": "macos-free-release", "configurePreset": "macos-free-release" },
{ "name": "macos-free-debug", "configurePreset": "macos-free-debug" },
{ "name": "macos-universal-release", "configurePreset": "macos-universal-release" },
{ "name": "macos-universal-debug", "configurePreset": "macos-universal-debug" },
{ "name": "freebsd-release", "configurePreset": "freebsd-release" },
{ "name": "freebsd-debug", "configurePreset": "freebsd-debug" },
{ "name": "freebsd-free-release", "configurePreset": "freebsd-free-release" },
{ "name": "freebsd-free-debug", "configurePreset": "freebsd-free-debug" },
{ "name": "openbsd-release", "configurePreset": "openbsd-release" },
{ "name": "openbsd-debug", "configurePreset": "openbsd-debug" },
{ "name": "openbsd-free-release", "configurePreset": "openbsd-free-release" },
{ "name": "openbsd-free-debug", "configurePreset": "openbsd-free-debug" },
{ "name": "netbsd-release", "configurePreset": "netbsd-release" },
{ "name": "netbsd-debug", "configurePreset": "netbsd-debug" },
{ "name": "netbsd-free-release", "configurePreset": "netbsd-free-release" },
{ "name": "netbsd-free-debug", "configurePreset": "netbsd-free-debug" },
{ "name": "windows-x64-release", "configurePreset": "windows-x64", "configuration": "Release" },
{ "name": "windows-x64-debug", "configurePreset": "windows-x64", "configuration": "Debug" },
{ "name": "windows-arm64-release", "configurePreset": "windows-arm64", "configuration": "Release" },
{ "name": "windows-arm64-debug", "configurePreset": "windows-arm64", "configuration": "Debug" },
{ "name": "windows-x86-release", "configurePreset": "windows-x86", "configuration": "Release" },
{ "name": "windows-x86-debug", "configurePreset": "windows-x86", "configuration": "Debug" },
{ "name": "windows-x64-free-release", "configurePreset": "windows-x64-free", "configuration": "Release" },
{ "name": "windows-x64-free-debug", "configurePreset": "windows-x64-free", "configuration": "Debug" },
{ "name": "windows-arm64-free-release", "configurePreset": "windows-arm64-free", "configuration": "Release" },
{ "name": "windows-arm64-free-debug", "configurePreset": "windows-arm64-free", "configuration": "Debug" },
{ "name": "windows-x86-free-release", "configurePreset": "windows-x86-free", "configuration": "Release" },
{ "name": "windows-x86-free-debug", "configurePreset": "windows-x86-free", "configuration": "Debug" }
]
}
+73
View File
@@ -31,6 +31,79 @@ To build on Mac and Linux just type `make`. On FreeBSD and OpenBSD `gmake` (GNU
- GNU make is required. Type `gmake` to build.
- Rust for x86_64 and ARM64 targets *if SSO is enabled in the build*.
### Building with CMake (optional)
> **Note:** CMake is an *alternative* build path, offered as a convenience. The official
> builds are still produced by the platform makefiles (above) and the Visual Studio solution
> in `windows/`.
#### Prerequisites
- **CMake** 3.15 or newer.
- The same compiler/toolchain (and Rust, if SSO is enabled) as the makefile build for your
platform — see *Platform Requirements* above.
- The header-only **OpenTelemetry API** must be present on `CMAKE_PREFIX_PATH`. Populate it
into `./.deps` by running the bootstrap script once, in its **default** (quick, header-only)
mode — i.e. *without* `ZT_CONTROLLER_DEPS=1`, which is the heavyweight controller-only path:
```bash
scripts/bootstrap-deps.sh # default mode: header-only OTel API into ./.deps
```
The script prints the exact `-DCMAKE_PREFIX_PATH` to use when it finishes.
#### Free vs. default (non-free) builds
By default the daemon is built **with the bundled FileDB network controller**, which lives
under `nonfree/` and is "source available" (non-free) — this matches what ships in official
builds (`ZT_NONFREE=ON`). To produce a **purely free** daemon (MPL-2.0 `node/`, `osdep/`,
`service/` only, with no `nonfree/` code compiled or linked), set **`-DZT_NONFREE=OFF`** — or
use one of the `*-free-*` presets, which set it for you.
#### Using presets (recommended)
`cmake --list-presets` shows the presets for your OS. The daemon presets are:
| Preset | Build |
| --- | --- |
| `macos-release` / `linux-release` | Default daemon (**includes** the non-free bundled controller) |
| `macos-free-release` / `linux-free-release` | **Free** daemon (`ZT_NONFREE=OFF`, no non-free code) |
| `macos-debug` / `linux-debug` (and `*-free-debug`) | Debug variants of the above |
| `macos-universal-release` | macOS universal (arm64 + x86_64) daemon |
| `freebsd-release` / `openbsd-release` / `netbsd-release` (and `*-free-release`, `*-debug`) | BSD daemon / free variant |
| `windows-x64-release` (and `windows-x64-free`) | Windows daemon / free variant |
```bash
# Default (non-free) daemon:
cmake --preset macos-release
cmake --build --preset macos-release
# Purely free daemon:
cmake --preset macos-free-release
cmake --build --preset macos-free-release
```
Each preset builds into its own directory, `build-<presetName>/`, so the binary lands at e.g.
`build-macos-free-release/zerotier-one`. (macOS/Linux presets use single-config Unix Makefiles,
so the build type is baked into the preset name — there's no `Release/` subdirectory.)
#### Manual invocation
The equivalent without presets:
```bash
# Default (non-free) daemon — .deps holds the OTel API from bootstrap-deps.sh:
cmake -DCMAKE_PREFIX_PATH="$PWD/.deps" -S . -B build
cmake --build build -j8
# Purely free daemon:
cmake -DZT_NONFREE=OFF -DCMAKE_PREFIX_PATH="$PWD/.deps" -S . -B build
cmake --build build -j8
```
The binary is `build/zerotier-one`. (On macOS, append the Homebrew prefixes to
`CMAKE_PREFIX_PATH` if your dependencies come from Homebrew, as the presets do.)
### Testing
Typing `make selftest` will build a *zerotier-selftest* binary which unit tests various internals and reports on a few aspects of the build environment. It's a good idea to try this on novel platforms or architectures.
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
cmake -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 -DCMAKE_INSTALL_PREFIX=$PWD -S . -B build/ -DCMAKE_INSTALL_PREFIX=$(shell pwd)/build-out
cmake --build build/ --target all -j4 --verbose
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi
if [ -z "$TARGET_DOCKER_REPO" ]; then
TARGET_DOCKER_REPO="us-central1-docker.pkg.dev/zerotier-421eb9/docker-images"
fi
docker build -platform linux/$ARCH -t $TARGET_DOCKER_REPO/ztcentral-controller:$(git rev-parse --short HEAD)-$ARCH -f ext/central-controller/docker/Dockerfile.central-controller . --load --push
+28
View File
@@ -0,0 +1,28 @@
set(FETCHCONTENT_QUIET OFF)
FetchContent_Declare(
cpp-httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
# v0.47.0+: supports 32-bit Windows. v0.25.0 had a `#warning` refusing 32-bit
# Windows that MSVC's default preprocessor escalates to a fatal C1021 (breaks
# the windows-x86 build).
GIT_TAG v0.47.0
GIT_SHALLOW ON
)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
set(HTTPLIB_COMPILE OFF CACHE INTERNAL "")
set(HTTPLIB_USE_ZLIB_IF_AVAILABLE ON CACHE INTERNAL "Use zlib if available")
set(HTTPLIB_USE_BROTLI_IF_AVAILABLE ON CACHE INTERNAL "Use brotli if available")
# The ZeroTier control plane is plain HTTP on localhost (no httplib SSLServer/SSLClient
# anywhere), and outbound SSO/OIDC TLS lives in rustybits (native-tls), so httplib never
# needs OpenSSL. Keeping this ON would link OpenSSL purely as dead weight -- which also
# blocks universal macOS builds (Homebrew OpenSSL is single-arch).
set(HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF CACHE INTERNAL "ZeroTier uses httplib for plain HTTP only")
set(HTTPLIB_USE_ZSTD_IF_AVAILABLE ON CACHE INTERNAL "Use zstd if available")
FetchContent_MakeAvailable(cpp-httplib)
if (NOT TARGET httplib::httplib)
message(FATAL_ERROR "A required cpp-httplib target (cpp-httplib) was not imported")
endif()
+18
View File
@@ -0,0 +1,18 @@
# inja -- header-only C++ templating engine used by service/OneService.cpp
# (`#include <inja/inja.hpp>`). Homebrew ships no usable CMake config and Debian
# has no package, so we vendor the headers via FetchContent. We populate the
# source only and skip inja's own CMakeLists (its build/test/json machinery) by
# pointing SOURCE_SUBDIR at a non-existent directory. inja consumes
# nlohmann::json, which the build already provides via find_package(nlohmann_json)
# and links into the targets that use inja; we only need inja's headers on the
# include path here (header-only, no link), matching the previous conda setup.
include(FetchContent)
FetchContent_Declare(inja
GIT_REPOSITORY https://github.com/pantor/inja.git
GIT_TAG v3.4.0
GIT_SHALLOW ON
SOURCE_SUBDIR _skip_inja_cmakelists_) # populate only; no add_subdirectory
FetchContent_MakeAvailable(inja)
# inja ships an amalgamated header under single_include/inja/inja.hpp.
include_directories("${inja_SOURCE_DIR}/single_include")
+32
View File
@@ -0,0 +1,32 @@
set(FETCHCONTENT_QUIET OFF)
FetchContent_Declare(
miniupnpc
URL https://github.com/miniupnp/miniupnp/releases/download/miniupnpc_2_3_3/miniupnpc-2.3.3.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
set(UPNPC_BUILD_TESTS FALSE CACHE INTERNAL "Build tests" FORCE)
set(UPNPC_BUILD_SHARED FALSE CACHE INTERNAL "Build shared library" FORCE)
set(UPNPC_BUILD_STATIC TRUE CACHE INTERNAL "Build static library" FORCE)
set(UPNPC_BUILD_SAMPLE FALSE CACHE INTERNAL "Build sample" FORCE)
FetchContent_MakeAvailable(miniupnpc)
if (NOT TARGET miniupnpc::miniupnpc)
message(FATAL_ERROR "A required miniupnpc target (miniupnpc::miniupnpc) was not imported")
endif()
add_definitions(-DZT_USE_MINIUPNPC)
FetchContent_Declare(
libnatpmp
GIT_REPOSITORY https://github.com/miniupnp/libnatpmp.git
GIT_TAG master
GIT_SHALLOW ON
PATCH_COMMAND git apply ${CMAKE_SOURCE_DIR}/ext/cmake-patches/libnatpmp.patch
UPDATE_DISCONNECTED TRUE
)
FetchContent_MakeAvailable(libnatpmp)
if (NOT TARGET natpmp)
message(FATAL_ERROR "A required libnatpmp target (natpmp) was not imported")
endif()
+28
View File
@@ -0,0 +1,28 @@
set(FETCHCONTENT_QUIET OFF)
FetchContent_Declare(
redis-plus-plus
GIT_REPOSITORY https://github.com/sewenew/redis-plus-plus.git
GIT_TAG 1.3.15
GIT_SHALLOW ON
)
set(REDIS_PLUS_PLUS_BUILD_STATIC ON CACHE INTERNAL "Build static library" FORCE)
# We only link redis++::redis++_static, so skip the unused shared library.
set(REDIS_PLUS_PLUS_BUILD_SHARED OFF CACHE INTERNAL "Build shared library" FORCE)
set(REDIS_PLUS_PLUS_BUILD_TEST OFF CACHE INTERNAL "Build tests" FORCE)
set(REDIS_PLUS_PLUS_BUILD_STATIC_WITH_PIC ON CACHE INTERNAL "Build static library with PIC" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libraries" FORCE)
FetchContent_MakeAvailable(redis-plus-plus)
if(NOT TARGET redis++::redis++_static)
message(FATAL_ERROR "A required redis-plus-plus target (redis++::redis++_static) was not imported")
endif()
# redis++'s static library calls into hiredis but does not propagate that
# dependency to consumers, so the final link fails with undefined hiredis
# symbols (redisAppendCommand, redisFree, freeReplyObject, ...). Attach hiredis
# to the static target's interface. find_library (not find_package(hiredis))
# because Debian's libhiredis-dev ships no CMake config.
find_library(HIREDIS_LIB hiredis REQUIRED)
target_link_libraries(redis++_static INTERFACE ${HIREDIS_LIB})
message(STATUS "redis-plus-plus imported (hiredis: ${HIREDIS_LIB})")
+12
View File
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.13)
project(ext)
file(GLOB_RECURSE PROM_CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/core/include/*.h )
set(PROMETHEUS_CPP_LITE_HEADERS ${PROM_CORE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/simpleapi/include)
add_library(prometheus-cpp-lite INTERFACE)
target_sources(prometheus-cpp-lite INTERFACE ${PROMETHEUS_CPP_LITE_HEADERS})
target_include_directories(prometheus-cpp-lite INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/simpleapi/include ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/core/include)
add_custom_target(prometheus-cpp-lite-ide SOURCES ${PROMETHEUS_CPP_LITE_HEADERS})
set(prometheus-cpp-lite_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/simpleapi/include ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/core/include PARENT_SCOPE)
+63 -16
View File
@@ -1,21 +1,68 @@
# Dockerfile for ZeroTier Central Controllers
FROM registry.zerotier.com/zerotier/ctlbuild:2025-07-14 AS builder
ADD . /ZeroTierOne
RUN export PATH=$PATH:~/.cargo/bin && cd ZeroTierOne && make clean && make central-controller -j8
# Central Controller -- conda-free, CMake-based, Debian trixie. Multi-stage:
# builder : apt deps + scripts/bootstrap-deps.sh (OTel 1.27 + google-cloud-cpp
# 2.38 from source) + CMake build of zerotier-one
# go_base : golang-migrate
# runtime : slim trixie with exactly the runtime libs the binary needs
#
# Build (context = repo root, see .dockerignore):
# docker build -f ext/central-controller-docker/Dockerfile -t ztctl .
FROM debian:trixie AS builder
FROM golang:1.24.1-bookworm AS go_base
RUN GONOSUMDB=* GOFLAGS='-p=1' go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential cmake ninja-build git pkg-config ca-certificates curl \
libpqxx-dev libpq-dev libhiredis-dev libjemalloc-dev nlohmann-json3-dev \
libabsl-dev libprotobuf-dev protobuf-compiler protobuf-compiler-grpc libgrpc++-dev \
libgtest-dev libgmock-dev libssl-dev libcurl4-openssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --default-toolchain 1.89.0 --profile minimal
ENV PATH="/root/.cargo/bin:${PATH}"
WORKDIR /ZeroTierOne
# Pinned from-source deps -> /opt/zt-deps, against apt's abseil/protobuf/grpc.
# ZT_CONTROLLER_DEPS=1 builds the full controller set (OTel SDK + OTLP exporters +
# google-cloud-cpp); without it the script only builds the header-only OTel API.
# Copy only the bootstrap script first so this expensive layer stays cached across
# changes to the rest of the tree.
COPY scripts/bootstrap-deps.sh scripts/bootstrap-deps.sh
RUN ZT_CONTROLLER_DEPS=1 bash scripts/bootstrap-deps.sh /opt/zt-deps
COPY . .
RUN cmake -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 \
-DCMAKE_PREFIX_PATH=/opt/zt-deps -S . -B build-cmake -G Ninja \
&& cmake --build build-cmake -j"$(nproc)"
# Compute the exact runtime apt packages the binary links (robust against the
# trixie t64 package renames). The two non-apt OTel proto .so's are copied
# explicitly in the runtime stage, so dpkg-S misses there are expected.
# readlink -f resolves the usrmerge /lib -> /usr/lib symlinks so dpkg -S can
# attribute each .so to its package (and naturally picks up the trixie t64 names).
RUN ldd build-cmake/zerotier-one | awk '/=> \//{print $3}' | xargs -r readlink -f \
| xargs -r dpkg -S 2>/dev/null | cut -d: -f1 | tr ',' '\n' | sort -u > /opt/runtime-pkgs.txt \
&& echo "--- runtime packages ---" && cat /opt/runtime-pkgs.txt
# ---------------------------------------------------------------------------
FROM golang:1.24-bookworm AS go_base
RUN GOFLAGS='-p=1' go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
# ---------------------------------------------------------------------------
FROM debian:trixie AS runtime
COPY --from=builder /opt/runtime-pkgs.txt /opt/runtime-pkgs.txt
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
$(cat /opt/runtime-pkgs.txt) \
libjemalloc2 postgresql-client netcat-openbsd ca-certificates \
&& rm -rf /var/lib/apt/lists/* /opt/runtime-pkgs.txt
COPY --from=builder /ZeroTierOne/build-cmake/zerotier-one /usr/local/bin/zerotier-one
# The only dynamically-linked from-source libs (OTel/gcloud are otherwise static).
COPY --from=builder /opt/zt-deps/lib/libopentelemetry_proto.so /opt/zt-deps/lib/libopentelemetry_proto_grpc.so /usr/local/lib/
RUN echo /usr/local/lib > /etc/ld.so.conf.d/zerotier.conf && ldconfig
FROM registry.zerotier.com/zerotier/ctlrun:2025-07-14 AS run_base
COPY --from=builder /ZeroTierOne/zerotier-one /usr/local/bin/zerotier-one
COPY --from=builder /ZeroTierOne/ext/opentelemetry-cpp-1.21.0/localinstall/lib/*.so /usr/local/lib64/
COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate
COPY ext/central-controller-docker/migrations /migrations
COPY ext/central-controller-docker/main.sh /main.sh
RUN chmod +x /usr/local/bin/zerotier-one /usr/local/bin/migrate /main.sh
RUN chmod a+x /usr/local/bin/zerotier-one
RUN echo "/usr/local/lib64" > /etc/ld.so.conf.d/usr-local-lib64.conf && ldconfig
ADD ext/central-controller-docker/main.sh /
RUN chmod a+x /main.sh
ENTRYPOINT /main.sh
ENTRYPOINT ["/main.sh"]
@@ -1,34 +0,0 @@
# Dockerfile for building ZeroTier Central Controllers
FROM debian:bookworm
RUN apt update && apt upgrade -y
RUN apt -y install \
build-essential \
pkg-config \
bash \
clang \
libjemalloc2 \
libjemalloc-dev \
libpq5 \
libpq-dev \
openssl \
libssl-dev \
postgresql-client \
postgresql-client-common \
curl \
libcurl4-openssl-dev \
google-perftools \
libgoogle-perftools-dev \
protobuf-compiler \
protobuf-compiler-grpc \
protobuf-c-compiler \
grpc-proto \
libgrpc++1.51 \
libgrpc++-dev \
libgrpc-dev \
libgrpc29 \
cmake \
git
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
@@ -1,19 +0,0 @@
FROM debian:bookworm
RUN apt update && apt upgrade -y
RUN apt -y install \
netcat-traditional \
postgresql-client \
postgresql-client-common \
libjemalloc2 \
libpq5 \
curl \
binutils \
perf-tools-unstable \
google-perftools \
gnupg \
libgrpc++1.51 \
libgrpc29
-16
View File
@@ -1,16 +0,0 @@
registry = registry.zerotier.com/zerotier
all: controller-builder controller-runbase
buildx:
@echo "docker buildx create"
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --privileged --rm tonistiigi/binfmt --install all
@echo docker buildx create --name multiarch --driver docker-container --use
@echo docker buildx inspect --bootstrap
controller-builder: buildx
docker buildx build --no-cache --platform linux/amd64,linux/arm64 -t $(registry)/ctlbuild:$(shell date +"%Y-%m-%d") -f Dockerfile.builder . --push
controller-runbase: buildx
docker buildx build --no-cache --platform linux/amd64,linux/arm64 -t $(registry)/ctlrun:$(shell date +"%Y-%m-%d") -f Dockerfile.run_base . --push
+118 -20
View File
@@ -20,9 +20,6 @@ if [ -z "$ZT_DB_PASSWORD" ]; then
echo '*** FAILED: ZT_DB_PASSWORD environment variable not defined'
exit 1
fi
if [ -z "$ZT_DB_TYPE" ]; then
ZT_DB_TYPE="postgres"
fi
REDIS=""
if [ "$ZT_USE_REDIS" == "true" ]; then
@@ -41,7 +38,7 @@ if [ "$ZT_USE_REDIS" == "true" ]; then
exit 1
fi
REDIS="\"redis\": {
REDIS=", \"redis\": {
\"hostname\": \"${ZT_REDIS_HOST}\",
\"port\": ${ZT_REDIS_PORT},
\"clusterMode\": ${ZT_REDIS_CLUSTER_MODE},
@@ -49,7 +46,7 @@ if [ "$ZT_USE_REDIS" == "true" ]; then
}
"
else
REDIS="\"redis\": null"
REDIS=", \"redis\": null"
fi
mkdir -p /var/lib/zerotier-one
@@ -60,8 +57,9 @@ if [ -d "$ZT_IDENTITY_PATH" ]; then
ln -s $ZT_IDENTITY_PATH/identity.public identity.public
ln -s $ZT_IDENTITY_PATH/identity.secret identity.secret
if [ -f "$ZT_IDENTITY_PATH/authtoken.secret" ]; then
if [ -L "$ZT_IDENTITY_PATH/authtoken.secret" ] && [ -e "$ZT_IDENTITY_PATH/authtoken.secret" ]; then
ln -s $ZT_IDENTITY_PATH/authtoken.secret authtoken.secret
ln -s $ZT_IDENTITY_PATH/authtoken.secret metricstoken.secret
fi
fi
popd
@@ -71,9 +69,90 @@ DEFAULT_LB_MODE=false
APP_NAME="controller-$(cat /var/lib/zerotier-one/identity.public | cut -d ':' -f 1)"
BIGTABLE_CONF=""
if [ "$ZT_USE_BIGTABLE" == "true" ]; then
if [ -z "$ZT_BIGTABLE_PROJECT" ] || [ -z "$ZT_BIGTABLE_INSTANCE" ] || [ -z "$ZT_BIGTABLE_TABLE" ]; then
echo '*** FAILED: ZT_BIGTABLE_PROJECT, ZT_BIGTABLE_INSTANCE, and ZT_BIGTABLE_TABLE environment variables must all be defined to use Bigtable as a controller backend'
exit 1
fi
BIGTABLE_CONF=", \"bigtable\": {
\"project_id\": \"${ZT_BIGTABLE_PROJECT}\",
\"instance_id\": \"${ZT_BIGTABLE_INSTANCE}\",
\"table_id\": \"${ZT_BIGTABLE_TABLE}\"
}
"
fi
PUBSUB_CONF=""
if [ "$ZT_USE_PUBSUB" == "true" ]; then
if [ -z "$ZT_PUBSUB_PROJECT" ]; then
echo '*** FAILED: ZT_PUBSUB_PROJECT environment variable must be defined to use PubSub as a controller backend'
exit 1
fi
if [ -z "$ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC" ]; then
echo '*** FAILED: ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC, ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC, ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC, and ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC environment variables must all be defined to use PubSub as a controller backend'
exit 1
fi
PUBSUB_CONF=", \"pubsub\": {
\"project_id\": \"${ZT_PUBSUB_PROJECT}\",
\"member_change_recv_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC}\",
\"member_change_send_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC}\",
\"network_change_recv_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC}\",
\"network_change_send_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC}\",
\"sso_nonce_publish_topic\": \"${ZT_PUBSUB_SSO_NONCE_PUBLISH_TOPIC}\",
\"sso_auth_subscribe_topic\": \"${ZT_PUBSUB_SSO_AUTH_SUBSCRIBE_TOPIC}\"
}
"
fi
# Backwards compatibility: if the per-frontend URLs aren't set but the legacy
# ZT_SSO_REDIRECT_URL and ZT_ASSIGNED_CENTRAL_VERSION are both populated, map
# the legacy URL into the new format keyed by the assigned Central version.
if [ -z "$ZT_SSO_REDIRECT_URL_CV1" ] && [ -z "$ZT_SSO_REDIRECT_URL_CV2" ]; then
if [ -n "$ZT_SSO_REDIRECT_URL" ] && [ -n "$ZT_ASSIGNED_CENTRAL_VERSION" ]; then
case "$ZT_ASSIGNED_CENTRAL_VERSION" in
cv1)
ZT_SSO_REDIRECT_URL_CV1="$ZT_SSO_REDIRECT_URL"
;;
cv2)
ZT_SSO_REDIRECT_URL_CV2="$ZT_SSO_REDIRECT_URL"
;;
all)
echo '*** FAILED: controllers assigned to "all" must define ZT_SSO_REDIRECT_URL_CV1 and ZT_SSO_REDIRECT_URL_CV2; the legacy ZT_SSO_REDIRECT_URL cannot serve both Central versions'
exit 1
;;
esac
fi
fi
# Per-frontend Central SSO redirect URLs. SSO-enabled networks are routed to the
# SSO endpoint of the Central version ("cv1" or "cv2") they belong to.
SSO_REDIRECT_URLS_CONF=""
if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ] || [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then
SSO_REDIRECT_URLS=""
if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ]; then
SSO_REDIRECT_URLS="\"cv1\": \"${ZT_SSO_REDIRECT_URL_CV1}\""
fi
if [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then
if [ -n "$SSO_REDIRECT_URLS" ]; then
SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS},
"
fi
SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS}\"cv2\": \"${ZT_SSO_REDIRECT_URL_CV2}\""
fi
SSO_REDIRECT_URLS_CONF=", \"ssoRedirectURLs\": {
${SSO_REDIRECT_URLS}
}
"
fi
echo "{
\"settings\": {
\"controllerDbPath\": \"${ZT_DB_TYPE}:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\",
\"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\",
\"portMappingEnabled\": true,
\"softwareUpdate\": \"disable\",
\"interfacePrefixBlacklist\": [
@@ -83,38 +162,48 @@ echo "{
\"lowBandwidthMode\": ${ZT_LB_MODE:-$DEFAULT_LB_MODE},
\"ssoRedirectURL\": \"${ZT_SSO_REDIRECT_URL}\",
\"allowManagementFrom\": [\"127.0.0.1\", \"::1\", \"10.0.0.0/8\"],
\"enableMetrics\": ${ZT_ENABLE_METRICS:-true},
\"otel\": {
\"exporterEndpoint\": \"${ZT_EXPORTER_ENDPOINT}\",
\"exporterSampleRate\": ${ZT_EXPORTER_SAMPLE_RATE:-0}
},
}
${REDIS}
},
\"controller\": {
\"listenMode\": \"${ZT_LISTEN_MODE:-pgsql}\",
\"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\",
\"assignedCentralVersion\": \"${ZT_ASSIGNED_CENTRAL_VERSION:-all}\",
\"ssoEnabled\": ${ZT_SSO_ENABLED:-false}
${SSO_REDIRECT_URLS_CONF}
${REDIS}
${BIGTABLE_CONF}
${PUBSUB_CONF}
}
}
}
" > /var/lib/zerotier-one/local.conf
if [ -n "$DB_SERVER_CA" ]; then
echo "secret list"
chmod 600 /secrets/db/*.pem
ls -l /secrets/db/
until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do
until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do
echo "Waiting for PostgreSQL...";
sleep 2;
done
else
until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do
until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do
echo "Waiting for PostgreSQL...";
sleep 2;
done
fi
if [ "$ZT_DB_TYPE" == "cv2" ]; then
echo "Migrating database (if needed)..."
if [ -n "$DB_SERVER_CA" ]; then
/usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=verify-full&sslrootcert=$DB_SERVER_CA&sslcert=$DB_CLIENT_CERT&sslkey=$DB_CLIENT_KEY" up
else
/usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=disable" up
fi
fi
# echo "Migrating database (if needed)..."
# if [ -n "$DB_SERVER_CA" ]; then
# /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=verify-full&sslrootcert=$DB_SERVER_CA&sslcert=$DB_CLIENT_CERT&sslkey=$DB_CLIENT_KEY" up
# else
# /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=disable" up
# fi
if [ -n "$ZT_TEMPORAL_HOST" ] && [ -n "$ZT_TEMPORAL_PORT" ]; then
echo "waiting for temporal..."
@@ -125,7 +214,16 @@ if [ -n "$ZT_TEMPORAL_HOST" ] && [ -n "$ZT_TEMPORAL_PORT" ]; then
echo "Temporal is up"
fi
cat /var/lib/zerotier-one/local.conf
export GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes
export LIBC_FATAL_STDERR_=1
export GLIBCXX_FORCE_NEW=1
export GLIBCPP_FORCE_NEW=1
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
# Preload jemalloc, located arch-agnostically (libjemalloc2 installs it under the
# multiarch dir, e.g. /usr/lib/<triple>/libjemalloc.so.2). Skip if not present.
JEMALLOC="$(ldconfig -p 2>/dev/null | awk '/libjemalloc\.so\.2/ {print $NF; exit}')"
if [ -n "$JEMALLOC" ]; then
export LD_PRELOAD="$JEMALLOC"
fi
exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one
Loaded 20 of 1409 files, more files were not shown because too many files have changed in this diff. Show more