feat: add --wait flag to cluster key create command#73
Merged
Davidonium merged 7 commits intomainfrom Mar 27, 2026
Merged
Conversation
added 7 commits
March 27, 2026 10:39
API key creation is not transactional — it takes time for a newly created key to propagate to the Qdrant cluster. The --wait flag polls the cluster's REST endpoint using the new key until it gets a successful response, confirming the key is active. Flags added: - --wait: opt-in to waiting for key activation - --wait-timeout (default 1m): maximum time to wait - --wait-poll-interval (default 1s, hidden): polling frequency Made-with: Cursor
- Suppress errcheck on best-effort resp.Body.Close() in probe - Remove unused *httptest.Server return from test helper Made-with: Cursor
A key can be created before the cluster has an endpoint (e.g. cluster still provisioning). Instead of failing early when no endpoint exists, the probe now calls GetCluster on each poll iteration and keeps retrying until the endpoint appears and the key is accepted. Made-with: Cursor
- Make HTTP error in probe more descriptive: include status code and URL - Use standard Go error-first checking in waitForKeyReady (if err != nil + continue) instead of positive nil check - Print the probe error in the progress message so users can see why the key is not yet active (e.g. no endpoint, HTTP 403, etc.) Made-with: Cursor
Made-with: Cursor
Replace http.DefaultClient with a purpose-built client configured outside the closure with explicit timeouts (10s overall, 5s TLS handshake, 5s response header). Made-with: Cursor
The per-request context already carries the user's --wait-timeout deadline. A separate client-level Timeout is redundant and could confuse readers. Transport-level timeouts (TLS handshake, response header) are kept since they guard specific connection phases. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--wait,--wait-timeout, and--wait-poll-intervalflags tocluster key create--waitis passed, the CLI fetches the cluster endpoint viaGetClusterand polls it with HTTP GET using the new API key until the cluster accepts it (HTTP 2xx), confirming the key has propagatedwaitForKeyReadygeneric polling helper towait_helpers.gothat accepts a probe function, following the samecontext.WithTimeout+time.NewTickerpattern used bywaitForHealthyWithIntervalWhy
API key creation via the cloud management API is not transactional — it takes time for the key to propagate to the actual Qdrant cluster. Without
--wait, scripts that create a key and immediately use it will get auth errors.Flags
--waitfalse--wait-timeout1m--wait-poll-interval1s(hidden)Example
Test plan
TestKeyCreate_NoWait— without--wait,GetClusteris never calledTestKeyCreate_WaitSuccess— httptest server returns 403 twice then 200; command succeeds, stderr contains "API key is active"TestKeyCreate_WaitTimeout— httptest server always returns 403; command errors with "timed out"TestKeyCreate_WaitNoEndpoint—GetClusterreturns no endpoint; command errors with "no endpoint URL"TestKeyCreate_WaitDefaultPort— verifies the cluster endpoint is actually probedMade with Cursor