-
Notifications
You must be signed in to change notification settings - Fork 627
feat: lots of v2 endpoints #3241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8194d51
e33448f
8c12cff
263d16f
ff3687e
f12807e
7e7e0d4
9237bd4
b45c622
984aee0
6d7b4ff
a2e08ab
674e4c0
66a36d5
921c567
1a68d01
44cd9cb
0f7cc52
059a9cc
65c6de6
0a509c5
19a919b
aa364b8
02bf414
e49f531
bb3bc7e
2aad1fb
1d06a98
8e6bbed
44ce71c
4a0a703
8dad02c
e8f70be
7952835
6bc00fe
8f0c769
9a819d8
ced8c59
f5b5098
0765511
104a564
689138c
f1fcdd8
a2af25c
203ccbb
9c567f7
81cdc1c
d4e7d2c
226303f
8f3ac96
dcff5bf
50e52d0
afa31d2
f3f1f6a
32eab82
12e69e1
10fb452
61ce44b
795ca05
87829f7
bb51bb2
36afa1b
7368dd3
af2a6f9
ff936fd
549e93c
7b5c2a2
e34d5ae
a1e216e
5128129
db5e3d8
579747b
7add596
0fad5b6
1d32e97
5688a94
e38ad7e
36fef35
44308f4
356f23f
9f89db9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,73 +1,74 @@ | ||
| # fly.toml app configuration file generated for unkey-production-agent on 2025-06-09T13:58:09+02:00 | ||
| # | ||
| # See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
| # | ||
|
|
||
| app = 'unkey-production-agent' | ||
| primary_region = 'iad' | ||
|
|
||
| [build] | ||
| dockerfile = "Dockerfile" | ||
| [experimental] | ||
| cmd = ["/usr/local/bin/unkey", "agent", "--config=./config.production.json"] | ||
| cmd = ['/usr/local/bin/unkey', 'agent', '--config=./config.production.json'] | ||
|
|
||
| [build] | ||
| dockerfile = 'Dockerfile' | ||
|
|
||
| [deploy] | ||
| strategy = 'canary' | ||
| max_unavailable = 10.0 | ||
|
|
||
| [env] | ||
| PORT = '8080' | ||
| RPC_PORT = '9095' | ||
| SERF_PORT = '7373' | ||
|
|
||
| [http_service] | ||
| internal_port = 8080 | ||
| auto_stop_machines = false | ||
| auto_start_machines = false | ||
| min_machines_running = 7 | ||
| auto_stop_machines = 'stop' | ||
| auto_start_machines = true | ||
| min_machines_running = 0 | ||
| processes = ['app'] | ||
|
|
||
| [http_service.concurrency] | ||
| type = "requests" | ||
| soft_limit = 100 | ||
| type = 'requests' | ||
| hard_limit = 250 | ||
| soft_limit = 100 | ||
|
|
||
| [[http_service.checks]] | ||
| grace_period = "10s" | ||
| interval = "30s" | ||
| method = "GET" | ||
| timeout = "5s" | ||
| path = "/v1/liveness" | ||
|
|
||
| [http_service.http_options] | ||
| [http_service.http_options.response] | ||
| pristine = true | ||
|
|
||
| # Serf | ||
| [[http_service.checks]] | ||
| interval = '30s' | ||
| timeout = '5s' | ||
| grace_period = '10s' | ||
| method = 'GET' | ||
| path = '/v1/liveness' | ||
|
|
||
| [[services]] | ||
| protocol = 'tcp' | ||
| internal_port = 7373 | ||
| protocol = "tcp" | ||
|
|
||
| [[services.ports]] | ||
| handlers = ["tls"] | ||
| port = 7373 | ||
| handlers = ['tls'] | ||
|
|
||
|
|
||
| # RPC | ||
| [[services]] | ||
| protocol = 'tcp' | ||
| internal_port = 9095 | ||
| protocol = "tcp" | ||
|
|
||
| [[services.ports]] | ||
| handlers = ["tls"] | ||
| port = 9095 | ||
| handlers = ['tls'] | ||
|
|
||
| [[restart]] | ||
| policy = 'always' | ||
| retries = 10 | ||
|
|
||
| [[vm]] | ||
| memory = '2gb' | ||
| cpu_kind = 'shared' | ||
| cpus = 2 | ||
|
|
||
| [deploy] | ||
| strategy = "canary" | ||
| max_unavailable = 10 | ||
|
|
||
| [[restart]] | ||
| policy = "always" | ||
| retries = 10 | ||
|
|
||
|
|
||
| [metrics] | ||
| [[metrics]] | ||
| port = 2112 | ||
| path = "/metrics" # default for most prometheus exporters | ||
|
|
||
|
|
||
| [env] | ||
| PORT = "8080" | ||
| RPC_PORT = "9095" | ||
| SERF_PORT = "7373" # Spells 'serf' on a phone, I'm so funny | ||
| path = '/metrics' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,70 @@ | ||
| # fly.toml app configuration file generated for unkey-agent-dev on 2025-06-09T13:29:12+02:00 | ||
| # | ||
| # See https://fly.io/docs/reference/configuration/ for information about how to use this file. | ||
| # | ||
|
|
||
| app = 'unkey-agent-dev' | ||
| primary_region = 'iad' | ||
|
|
||
| [build] | ||
| dockerfile = "Dockerfile" | ||
| [experimental] | ||
| cmd = ["/usr/local/bin/unkey", "agent", "--config=./config.staging.json"] | ||
| cmd = ['/usr/local/bin/unkey', 'agent', '--config=./config.staging.json'] | ||
|
|
||
| [build] | ||
| dockerfile = 'Dockerfile' | ||
|
|
||
| [deploy] | ||
| strategy = 'canary' | ||
| max_unavailable = 1.0 | ||
|
|
||
| [env] | ||
| PORT = '8080' | ||
| RPC_PORT = '9095' | ||
| SERF_PORT = '7373' | ||
|
|
||
| [http_service] | ||
| internal_port = 8080 | ||
| auto_start_machines = false | ||
| auto_stop_machines = false | ||
| min_machines_running = 3 | ||
| processes = ['app'] | ||
| internal_port = 8080 | ||
| auto_stop_machines = 'stop' | ||
| auto_start_machines = true | ||
| min_machines_running = 0 | ||
| processes = ['app'] | ||
|
|
||
| [http_service.concurrency] | ||
| type = "requests" | ||
| soft_limit = 500 | ||
| hard_limit = 1000 | ||
| [http_service.concurrency] | ||
| type = 'requests' | ||
| hard_limit = 1000 | ||
| soft_limit = 500 | ||
|
|
||
| [[http_service.checks]] | ||
| grace_period = "10s" | ||
| interval = "30s" | ||
| method = "GET" | ||
| timeout = "5s" | ||
| path = "/v1/liveness" | ||
| [http_service.http_options] | ||
| [http_service.http_options.response] | ||
| pristine = true | ||
|
|
||
| [http_service.http_options.response] | ||
| pristine = true | ||
| [[http_service.checks]] | ||
| interval = '30s' | ||
| timeout = '5s' | ||
| grace_period = '10s' | ||
| method = 'GET' | ||
| path = '/v1/liveness' | ||
|
|
||
| # Serf | ||
| [[services]] | ||
| internal_port = 7373 | ||
| protocol = "tcp" | ||
| [[services.ports]] | ||
| handlers = ["tls"] | ||
| port = 7373 | ||
| protocol = 'tcp' | ||
| internal_port = 7373 | ||
|
|
||
| [[services.ports]] | ||
| port = 7373 | ||
| handlers = ['tls'] | ||
|
|
||
| # RPC | ||
| [[services]] | ||
| internal_port = 9095 | ||
| protocol = "tcp" | ||
| [[services.ports]] | ||
| handlers = ["tls"] | ||
| port = 9095 | ||
| protocol = 'tcp' | ||
| internal_port = 9095 | ||
|
|
||
| [[services.ports]] | ||
| port = 9095 | ||
| handlers = ['tls'] | ||
|
|
||
| [[vm]] | ||
| memory = '1gb' | ||
| cpu_kind = 'shared' | ||
| cpus = 1 | ||
|
|
||
| [deploy] | ||
| strategy = "canary" | ||
| max_unavailable = 1 | ||
|
|
||
| [env] | ||
| PORT = "8080" | ||
| RPC_PORT = "9095" | ||
| SERF_PORT = "7373" # Spells 'serf' on a phone, I'm so funny | ||
|
|
||
| memory = '1gb' | ||
| cpu_kind = 'shared' | ||
| cpus = 1 | ||
|
|
||
| [metrics] | ||
| port = 2112 | ||
| path = "/metrics" # default for most prometheus exporters | ||
| [[metrics]] | ||
| port = 2112 | ||
| path = '/metrics' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| version: v2 | ||
| plugins: | ||
| - remote: buf.build/protocolbuffers/go | ||
| out: gen | ||
| opt: paths=source_relative | ||
| - remote: buf.build/connectrpc/go:v1.16.2 | ||
| out: gen | ||
| opt: paths=source_relative | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| version: v1 | ||
| breaking: | ||
| use: | ||
| - FILE | ||
| - PACKAGE | ||
| - WIRE | ||
| - WIRE_JSON | ||
| lint: | ||
| use: | ||
| - DEFAULT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,12 +28,12 @@ tasks: | |
| cmds: | ||
| - cmd: echo "Running full tests... this can take more than 30min... run 'task test-unit' for faster tests" | ||
| silent: true | ||
| - cmd: go test -failfast -timeout=60m -shuffle=on -v -json -p=10 ./... | tparse -all -progress -smallscreen | ||
| - cmd: go test -failfast -timeout=60m -shuffle=on -v -json ./... | tparse -all -progress -smallscreen | ||
| silent: true | ||
|
|
||
| test-unit: | ||
| cmds: | ||
| - go test -json -race -failfast -timeout=30m -p=10 ./... | tparse -all -progress -smallscreen | ||
| - go test -json -race -failfast -timeout=30m ./... | tparse -all -progress -smallscreen | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Reevaluate parallelism strategy for unit tests 🤖 Prompt for AI Agents |
||
|
|
||
| build: | ||
| cmds: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,7 @@ import ( | |||||||||||
| "github.com/unkeyed/unkey/go/pkg/port" | ||||||||||||
| "github.com/unkeyed/unkey/go/pkg/testutil/containers" | ||||||||||||
| "github.com/unkeyed/unkey/go/pkg/uid" | ||||||||||||
| "github.com/unkeyed/unkey/go/pkg/vault/keys" | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| // TestContextCancellation verifies that the API server responds properly to context cancellation | ||||||||||||
|
|
@@ -28,6 +29,9 @@ func TestContextCancellation(t *testing.T) { | |||||||||||
| // Create a cancellable context | ||||||||||||
| ctx, cancel := context.WithCancel(context.Background()) | ||||||||||||
|
|
||||||||||||
| _, masterKey, err := keys.GenerateMasterKey() | ||||||||||||
| require.NoError(t, err) | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+32
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Assert the generated master-key ID as well
- _, masterKey, err := keys.GenerateMasterKey()
+ keyID, masterKey, err := keys.GenerateMasterKey()
require.NoError(t, err)
+ require.NotEmpty(t, keyID, "generated Vault master-key ID should not be empty")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| // Configure the API server | ||||||||||||
| config := api.Config{ | ||||||||||||
| Platform: "test", | ||||||||||||
|
|
@@ -41,26 +45,27 @@ func TestContextCancellation(t *testing.T) { | |||||||||||
| DatabasePrimary: dbDsn, | ||||||||||||
| DatabaseReadonlyReplica: "", | ||||||||||||
| OtelEnabled: false, | ||||||||||||
| VaultMasterKeys: []string{masterKey}, | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Create a channel to receive the result of the Run function | ||||||||||||
| resultCh := make(chan error, 1) | ||||||||||||
|
|
||||||||||||
| // Start the API server in a goroutine | ||||||||||||
| go func() { | ||||||||||||
| err := api.Run(ctx, config) | ||||||||||||
| runErr := api.Run(ctx, config) | ||||||||||||
|
|
||||||||||||
| if err != nil { | ||||||||||||
| if runErr != nil { | ||||||||||||
| // it's really hard to get this error cause the test fails before we read from the channel | ||||||||||||
| t.Logf("Error from run: %s", err.Error()) | ||||||||||||
| t.Logf("Error from run: %s", runErr.Error()) | ||||||||||||
| } | ||||||||||||
| resultCh <- err | ||||||||||||
| resultCh <- runErr | ||||||||||||
| }() | ||||||||||||
|
|
||||||||||||
| // Wait for the server to start up | ||||||||||||
| require.Eventually(t, func() bool { | ||||||||||||
| res, err := http.Get(fmt.Sprintf("http://localhost:%d/v2/liveness", httpPort)) | ||||||||||||
| if err != nil { | ||||||||||||
| res, livenessErr := http.Get(fmt.Sprintf("http://localhost:%d/v2/liveness", httpPort)) | ||||||||||||
| if livenessErr != nil { | ||||||||||||
| return false | ||||||||||||
| } | ||||||||||||
| defer res.Body.Close() | ||||||||||||
|
|
@@ -75,7 +80,7 @@ func TestContextCancellation(t *testing.T) { | |||||||||||
|
|
||||||||||||
| // Wait for the server to shut down and check the result | ||||||||||||
| select { | ||||||||||||
| case err := <-resultCh: | ||||||||||||
| case err = <-resultCh: | ||||||||||||
| // The Run function should exit without error when context is canceled | ||||||||||||
| require.NoError(t, err, "API server should shut down gracefully when context is canceled") | ||||||||||||
| t.Log("API server shut down successfully") | ||||||||||||
|
|
@@ -84,6 +89,6 @@ func TestContextCancellation(t *testing.T) { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Verify the server is no longer responding | ||||||||||||
| _, err := http.Get(fmt.Sprintf("http://localhost:%d/v2/liveness", httpPort)) | ||||||||||||
| _, err = http.Get(fmt.Sprintf("http://localhost:%d/v2/liveness", httpPort)) | ||||||||||||
| require.Error(t, err, "Server should no longer be responding after shutdown") | ||||||||||||
| } | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Assess performance regression due to removing parallelism in
test-fullRemoving the
-p=10flag will serialize all integration tests and could significantly increase CI runtime. Consider isolating flaky tests, capping parallelism (e.g.,-p=2–5), or grouping tests into stable and unstable suites to preserve throughput while avoiding intermittent failures.🤖 Prompt for AI Agents