Commit Graph

706 Commits

Author SHA1 Message Date
travisladuke
559e8a907b Improve full controller network list api
it was counting incorrectly in some cases and
returning empty objects.
Basically just handling if network data is null
2024-03-01 09:54:13 -08:00
travisladuke
3593a2d49f Merge branch 'main' into main-into-dev 2024-02-29 10:24:22 -08:00
travisladuke
ac6d532651 Fix deleting controller network member directory
That trailing slash was making it not work.

ZT_HOME/controller.d/network/$nwid
2024-02-22 11:46:50 -08:00
travisladuke
d1a306a021 Prevent creating members on non-existent networks.
```sh
curl -s -X POST "http://localhost:9993/controller/network/abcdabcdabcdabcd/member/1122334455"
```

Would return 200 and ZT_HOME/controller.d/abcdabcdabcdabcd/members/1122334455
would be created. Without a ZT_HOME/controller.d/abcdabcdabcdabcd.json

Then other parts of the system mistakenly think a abcdabcdabcdabcd
network sorta kinda exists and then fail in weird ways.
2024-02-22 11:46:50 -08:00
travisladuke
f027d8f519 Fix typo in metric name 2024-02-07 15:13:42 -08:00
travisladuke
0ca8ae7970 Create an alternate networks list endpoint
Add /unstable/controller/network endpoint

Similar to /unstable/controller/network/{id}/member, it returns actual network objects,
instead of just network ids.
Also includes the total network count,
and each network has it's member counts in meta{}.
2024-02-01 13:12:24 -08:00
travisladuke
0b83f850e4 Create an alternate members list endpoint
The current api at /controller/network/1111111111767f2f/member
Lists only the members' ID and revision number.
If you want details, you have to query each specific member.
So if you want to make a members list, and you have
10000 members on a network, you need to make
10000 http requests.

It's also in a hard to specify and use shape
{ [member-id-1]: 13, [member-id-2]: 14, ... }

GET http://localhost:9993/unstable/controller/network/1111111111767f2f/member ->

```
{
  data: [ {...member1}, {...member2}, ...],
  meta: { totalCount: 4, authorizedCount: 3 }
}

```
2024-02-01 12:47:51 -08:00
travisladuke
06399c86f6 Store a network members name
Because the GET request to get a specific member just dumps
the whole member object, `name` is included there too for free.
2024-02-01 12:31:44 -08:00
Grant Limberg
2fd50b104c
check hooks are enabled before firing 2023-10-31 12:16:26 -07:00
Grant Limberg
85cab3d0f1
remove some debug logging 2023-10-30 15:20:09 -07:00
Grant Limberg
125257f264
Merge branch 'dev' into temporal 2023-09-06 09:52:22 -07:00
Grant Limberg
8426677c55
fix /controller endpoint 2023-09-06 09:44:25 -07:00
Grant Limberg
d322f332e8
simplify hook firing
only need network and member IDs
2023-08-30 14:51:39 -07:00
Grant Limberg
60fb8c941a
fully wire up temporal. add startup script test to ensure temporal is running 2023-08-29 16:43:05 -07:00
Grant Limberg
d865c42ef8
get connected to temporal 2023-08-29 12:19:28 -07:00
Grant Limberg
69c590ff81
Merge branch 'dev' into temporal 2023-08-28 12:54:29 -07:00
Grant Limberg
c974a159af
fix for issue #2114 2023-08-28 08:10:17 -07:00
Joseph Henry
7637ef10d7
Fix primary port binding issue in 1.12 (#2107)
* Add test for primary port bindings to validator - See #2105

* Add delay to binding test

* Remove TCP binding logic from Binder to fix #2105

* add second control plane socket for ipv6

* fix controller network post endpoint

* exit if we can't bind at least one of IPV4 or IPV6 for control plane port

---------

Co-authored-by: Grant Limberg <grant.limberg@zerotier.com>
2023-08-25 12:51:33 -04:00
Grant Limberg
5becb41bd4
pass hook_id instead of url 2023-08-15 14:51:14 -07:00
Grant Limberg
802c9907a1
limit to hooks with hook_type = NETWORK_JOIN enabled 2023-08-08 13:14:55 -07:00
Grant Limberg
88b96265d7
look up hook URLs dynamically 2023-08-07 16:42:23 -07:00
Grant Limberg
a9c8307d97
should only run this if smee is configured 2023-08-04 15:14:40 -07:00
Grant Limberg
581489f67b
this should theoretically send the new member notification 2023-08-04 15:02:37 -07:00
Grant Limberg
d71d051c53
instantiate smee client 2023-08-04 14:31:35 -07:00
Grant Limberg
3efb731b40
don't unborrow bad connections
pool will clean them up later
2023-06-08 08:45:50 -07:00
Grant Limberg
9a8b74d744
Fix oidc client lookup query
join condition referenced the wrong table.  Worked fine unless there were multiple identical client IDs
2023-05-31 09:34:31 -07:00
Grant Limberg
f42841a6ab
fix init order for EmbeddedNetworkController (#2014) 2023-05-25 11:09:08 -07:00
Grant Limberg
17f6b3a10b
central controller metrics & request path updates (#2012)
* internal db metrics

* use shared mutexes for read/write locks

* remove this lock. only used for a metric

* more metrics

* remove exploratory metrics

place controller request benchmarks behind ifdef
2023-05-23 12:11:26 -07:00
Brenton Bostick
da71e2524c
fix typos (#2010) 2023-05-19 19:21:24 +02:00
Brenton Bostick
f3da2b4031
Capture setContent by-value instead of by-reference (#2006)
Co-authored-by: Grant Limberg <glimberg@users.noreply.github.com>
2023-05-17 17:55:32 -07:00
Grant Limberg
adfbbc3fb0
Controller Metrics & Network Config Request Fix (#2003)
* add new metrics for network config request queue size and sso expirations
* move sso expiration to its own thread in the controller
* fix potential undefined behavior when modifying a set
2023-05-16 11:56:58 -07:00
Grant Limberg
f621261ff9
Update readme files for metrics (#2000) 2023-05-05 12:44:41 -07:00
Grant Limberg
e5fc89821f
use cpp-httplib for HTTP control plane (#1979)
refactored the old control plane code to use [cpp-httplib](https://github.com/yhirose/cpp-httplib) instead of a hand rolled HTTP server.  Makes the control plane code much more legible.  Also no longer randomly stops responding.
2023-04-28 11:03:28 -07:00
Grant Limberg
e4cb74896b
Central startup update (#1973)
* allow specifying authtoken in central startup

* set allowManagedFrom

* move redis_mem_notification to the correct place

* add node checkins metric

* wire up min/max connection pool size metrics
2023-04-25 12:44:18 -07:00
Grant Limberg
8e6e4ede6d
Add prometheus metrics for Central controllers (#1969)
* add header-only prometheus lib to ext

* rename folder

* Undo rename directory

* prometheus simpleapi included on mac & linux

* wip

* wire up some controller stats

* Get windows building with prometheus

* bsd build flags for prometheus

* Fix multiple network join from environment entrypoint.sh.release (#1961)

* _bond_m guards _bond, not _paths_m (#1965)

* Fix: warning: mutex '_aqm_m' is not held on every path through here [-Wthread-safety-analysis] (#1964)

* Serve prom metrics from /metrics endpoint

* Add prom metrics for Central controller specific things

* reorganize metric initialization

* testing out a labled gauge on Networks

* increment error counter on throw

* Consolidate metrics definitions

Put all metric definitions into node/Metrics.hpp.  Accessed as needed
from there.

* Revert "testing out a labled gauge on Networks"

This reverts commit 499ed6d95e.

* still blows up but adding to the record for completeness right now

* Fix runtime issues with metrics

* Add metrics files to visual studio project

* Missed an "extern"

* add copyright headers to new files

* Add metrics for sent/received bytes (total)

* put /metrics endpoint behind auth

* sendto returns int on Win32

---------

Co-authored-by: Leonardo Amaral <leleobhz@users.noreply.github.com>
Co-authored-by: Brenton Bostick <bostick@gmail.com>
2023-04-21 12:12:43 -07:00
Grant Limberg
03bd96d1d1
move begin/commit into try/catch block (#1932)
Thread was exiting in some cases
2023-03-24 13:03:15 -07:00
Grant Limberg
dea47f601d
more info on exception 2023-02-22 16:13:05 -08:00
Grant Limberg
0ae09577f6
Client & Central Controller updates to support additonal OIDC features (#1848)
Client side:
* Fix compatibility with OneLogin
* Requested scopes vary by OIDC provider. Different providers have different

Controller side:
*Update Postgres queries to latest Central schema
* Added Central Controller support for the different providers
* Base OIDC provider details are still attached to an org. Client ID & group/email lists are now associated with individual networks.
2023-01-19 15:39:15 -08:00
Brenton Bostick
98e0bf22d3 fix actual typo in config key code 2022-12-07 10:23:11 -05:00
Brenton Bostick
1e2ff042b4 fix typos in docs, comments, and strings 2022-12-07 10:17:53 -05:00
Grant Limberg
4e57abb159
Revert "modify sso queries for schema change"
This reverts commit 8b67d06272.
2022-09-28 13:26:41 -07:00
Grant Limberg
2b1ba60f24
Optimize member load query for Central controllers 2022-09-28 13:10:34 -07:00
Grant Limberg
638c868a07
Revert "query update for sso"
This reverts commit 3c343eb775.
2022-09-28 13:04:08 -07:00
Grant Limberg
b909330518
Revert "bump min db version"
This reverts commit 802072ec17.
2022-09-28 13:03:41 -07:00
Grant Limberg
802072ec17
bump min db version 2022-09-27 14:21:20 -07:00
Grant Limberg
3c343eb775
query update for sso 2022-09-27 13:41:52 -07:00
Grant Limberg
8b67d06272
modify sso queries for schema change 2022-09-21 14:29:47 -07:00
Grant Limberg
9cf8dacfbb
don't crash out of the controller heartbeat loop here 2022-06-30 11:40:04 -07:00
Grant Limberg
b5d7d71e1e
use connection pool instead of new connection for member status writes
redis plus plus has an annoying feature where it will open a new
connection for each tx or pipeline by default, rather than just fetching
an existing connection from the pool.  Let's change that
2022-06-30 09:59:47 -07:00
Grant Limberg
6fdc7be502
redis connection pool tuning 2022-06-29 09:39:51 -07:00