fix: auto-detect etcd API prefix for v3.4.x compatibility#382
fix: auto-detect etcd API prefix for v3.4.x compatibility#382
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAutomatically detect etcd API prefixes by probing candidates ( Changes
Sequence Diagram(s)sequenceDiagram
actor Client as Client (TablePro)
participant HTTP as EtcdHttpClient
participant Etcd as etcd Server
rect rgba(200, 100, 100, 0.5)
Note over Client,Etcd: Old Flow (Hardcoded /v3 → possible 404)
Client->>HTTP: connect()
HTTP->>Etcd: POST /v3/maintenance/status
Etcd-->>HTTP: 404 Not Found
HTTP-->>Client: Connection error (404)
end
rect rgba(100, 200, 100, 0.5)
Note over Client,Etcd: New Flow (Prefix auto-detection)
Client->>HTTP: connect()
HTTP->>HTTP: detectApiPrefix()
HTTP->>Etcd: POST /v3/maintenance/status
Etcd-->>HTTP: 404 Not Found
HTTP->>Etcd: POST /v3beta/maintenance/status
Etcd-->>HTTP: 200 OK
HTTP->>HTTP: set apiPrefix = "v3beta"
HTTP-->>Client: Connection established
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Plugins/EtcdDriverPlugin/EtcdHttpClient.swift`:
- Around line 468-470: The detector currently throws
EtcdError.connectionFailed("No supported etcd API..."), which causes connect()
to double-wrap probe failures; change the detector to throw a distinct error
(e.g., EtcdError.unsupportedAPI or a plain ProbeError) instead of
EtcdError.connectionFailed, or rethrow the underlying probe error unwrapped so
connect() can wrap it once; update the EtcdError enum to include unsupportedAPI
if needed and replace the throw at the detector site (the existing throw
EtcdError.connectionFailed(...) line) accordingly so connect() remains the
single place that classifies probe failures as connectionFailed.
- Around line 456-465: The probe currently treats any non-404 status as a valid
prefix, causing false positives for auth-required (401/403) or server errors;
update the probe inside the loop to only accept successful responses (e.g.
status codes in 200...299 or specifically 200) before setting apiPrefix and
returning. Keep the lock/apiPrefix assignment around the accepted case (use
lock.lock()/lock.unlock() or a defer) and for non-404/non-2xx responses log the
unexpected status via Self.logger.debug or warn and continue probing instead of
binding the prefix. Ensure the change references httpResponse.statusCode,
apiPrefix, lock, and Self.logger.debug in the modified logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a454156d-c4bf-4a86-85fb-82addde4c82f
📒 Files selected for processing (2)
CHANGELOG.mdPlugins/EtcdDriverPlugin/EtcdHttpClient.swift
Summary
Closes #380
/v3/vs/v3beta/) during connection, fixing 404 errors on etcd 3.4.x/v3beta/, while 3.5+ uses/v3/— the plugin previously hardcoded/v3//v3/maintenance/statusfirst, falls back to/v3beta/on HTTP 404; network errors propagate immediatelyTest plan
Summary by CodeRabbit