28 Commits

Author SHA1 Message Date
761d53a418 feat: update dependencies
Rekres, update dependencies.

Mostly to bring in
https://github.com/siderolabs/discovery-client/releases/tag/v0.1.11 and
get it tested, as this repo has client tests.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2025-02-26 15:34:11 +04:00
b8da986b5a fix: reduce memory allocations (logger)
Rework the gRPC logger by using hand-rolled simple version, rework
version parsing to remove regexp matching.

The baseline (via benchmark):

```
BenchmarkViaClientSimulator-32    	    2934	    387398 ns/op	  101921 B/op	     832 allocs/op
```

The baseline + removed logging middleware:

```
BenchmarkViaClientSimulator-32    	    3543	    331166 ns/op	   73581 B/op	     543 allocs/op
```

Reworked logging middleware:

```
BenchmarkViaClientSimulator-32    	    3394	    334066 ns/op	   77985 B/op	     568 allocs/op
```

Plus reworked version parsing:

```
BenchmarkViaClientSimulator-32    	    3510	    325714 ns/op	   66215 B/op	     561 allocs/op
```

So overall, baseline to this PR:

* allocs 101921 -> 66215 B/op
* alloc ops 832 -> 561 allocs/op

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-10-22 13:30:21 +04:00
3367c7b349 chore: add proto-codec/codec
Unify usage of proto codec v2 across out projects.

Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
2024-10-02 20:34:45 +03:00
efbb10bdfd fix: properly parse peer address
After switch to Go's http/server, the peer address comes wrapped, so use
a different method to unwrap it.

The tests haven't caught that, as they were using gRPC's server, so
switch tests to use same approach as production, ans enable HTTP/2 over
TLS, as otherwise h2c is a mess, and it doesn't abort connections
properly for test purposes.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-09-26 21:02:42 +04:00
cf39974104 feat: support direct TLS serving
Support certificate reload on the fly.

Slice version to just `vX.Y` in the metrics.

Bump IP-based limits.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-09-26 18:05:36 +04:00
270f2575e7 chore: bump deps
Run rekres and bump deps.

Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
2024-09-02 16:34:00 +03:00
196c609d1e fix: use shared gRPC buffers, lower buffer size
As Discovery Service handles lots of connections with relatively low
traffic on each connection, lower the buffer size and re-use the
read/write buffers.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-05-28 14:27:14 +04:00
ea8b8f1493 feat: implement state storage
On a best-effort basis, store the state on the disk periodically and on shutdown & restore it from the disk on startup.

Additionally, bump Go version, deps & rekres.

Closes siderolabs/discovery-service#54.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
2024-05-22 12:00:13 +02:00
c55142668f feat: migrate grpc-middleware to v2, update deps
Update removing multiple old middlewares, rework
the way data is passed through the context, logging fields, etc.

Fix minimum keepalive interval enforcement.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-03-12 18:14:14 +04:00
952dc5438f refactor: update dependencies, small cleanups
No real functional changes, some small cleanups, using generic
functions, refactoring some code.

Use the actual address instead of string for the IP rate limiter
(smaller map key).

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2024-01-12 18:10:28 +04:00
c939fef8e5 chore: fix typo on landing page
Fix typo in index.html.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2023-05-18 19:34:51 +04:00
912943a343 test: add test on client redirect
This matches PR https://github.com/siderolabs/discovery-client/pull/4.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-09-15 17:37:55 +04:00
8db8ef361e feat: add an option to redirect all clients to a fixed endpoint
This allows to launch discovery service with a flag like
`--redirect-endpoint=example.com:443`.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-09-08 21:27:47 +04:00
b34803b6e0 test: add a client test with affiliate deletion
Test affiliate deletion from PR
https://github.com/siderolabs/discovery-client/pull/3.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-08-25 21:35:16 +04:00
69ac844cf5 refactor: replace netaddr with netip/netipx
This removes deprecated inet.af/netaddr.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-08-25 21:11:45 +04:00
d5d0ff5a2f chore: rekres
Bump Go, rename package name to siderolabs, etc.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-08-25 20:29:58 +04:00
9baca2eb53 chore: bump prometheus/client_golang
Bump prometheus/client_golang and other deps

Fixes: [CVE-2022-21698](https://github.com/prometheus/client_golang/security/advisories/GHSA-cg3q-j54f-5p7p)

Signed-off-by: Noel Georgi <git@frezbo.dev>
2022-02-15 20:12:19 +05:30
a20b27d1b9 feat: rate limiting
enforce rate limits and a maximum burst size per IP address

Signed-off-by: Philipp Sauter <sauterp@protonmail.com>
Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-02-10 00:09:57 +03:00
52b44de1f7 feat: implement inspect page
Added a new handler and respective tests to get affiliate data in a cluster.
Signed-off-by: Rohit Dandamudi <rohit.dandamudi@siderolabs.com>
2021-11-23 19:00:46 +05:30
d85ea91d43 feat: extract peer address from nginx headers
- Added additional interceptors function to log the address
- Tests to cover the client IP address case
Signed-off-by: Rohit Dandamudi <rohit.dandamudi@siderolabs.com>
2021-11-17 18:31:58 +05:30
a0e6313af7 chore: relicense under BSL-1.1
Change date is 4 years from now, change license is MPL 2.0.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-10-28 23:13:26 +03:00
5960cd240d feat: improve version parsing
Do not store versions like `v0.14.0-alpha.0-7-gf7d9f211-dirty` to avoid
a combinatorial explosion in Prometheus.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@talos-systems.com>
2021-10-28 17:38:33 +00:00
d4a4ec2fac chore: move api and client out of the repository
The protobuf definitions were moved out to
https://github.com/talos-systems/discovery-api.

The client was moved out to
https://github.com/talos-systems/discovery-client.

No functional changes.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-10-13 21:41:25 +03:00
1655040813 chore: improve state logging
Log cluster creation and removal.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@talos-systems.com>
2021-10-01 15:41:19 +00:00
ab9c7c98dc chore: add Prometheus metrics
Closes #11.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@talos-systems.com>
2021-09-30 15:00:55 +03:00
509e9b2ced feat: implement client wrapper around discovery service API
Fixes #6

This wrapper handles protobuf marshaling, encryption, etc. on the client
data so that service doesn't have a way to see the data.

Client handles data refresh on TTL, updates, discovery of other
affiliates, etc.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-09-27 23:37:24 +03:00
619546696a feat: enable vtprotobuf, watch batching, more limits
Fixes #5

Batch watch responses in a single batch so that client can quickly know
that initial snapshot got delivered.

Bump go.mod deps.

Implement more limits.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-09-23 17:58:45 +03:00
7174ec1042 feat: implement new discovery service
This includes new in-memory core, new gRPC API, tests, etc.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2021-09-23 15:52:42 +03:00