[TT-15954] Make org session fetch non-blocking #7480
🚨 Check Failed
architecture check failed because fail_if condition was met.
Details
📊 Summary
- Total Issues: 5
- Error Issues: 4
- Warning Issues: 1
🔍 Failure Condition Results
❌ Failed Conditions
- global_fail_if: Global failure condition met
⚠️ Severity: Error
🐛 Issues by Category
🏗️ Architecture (4)
- ❌ gateway/rpc_storage_handler.go:1280 - The context-aware method
GetKeyContextdoes not propagate the context to the underlying blocking call (r.GetKey). This defeats the purpose of using a context for cancellation and timeouts, leading to a goroutine leak if the backend is unresponsive. The goroutine spawned infetchOrgSessionWithTimeoutwill block indefinitely even after its parent context times out. - ❌ gateway/ldap_auth_handler.go:248 - The context-aware method
GetKeyContextdoes not propagate the context to the underlying blocking call (l.GetKey). This defeats the purpose of using a context for cancellation and timeouts, leading to a goroutine leak if the backend is unresponsive. The goroutine spawned infetchOrgSessionWithTimeoutwill block indefinitely even after its parent context times out. - ❌ storage/mdcb_storage.go:295 - The context-aware method
GetKeyContextdoes not propagate the context to the underlying blocking call (m.GetKey). This defeats the purpose of using a context for cancellation and timeouts, leading to a goroutine leak if the backend is unresponsive. The goroutine spawned infetchOrgSessionWithTimeoutwill block indefinitely even after its parent context times out. ⚠️ gateway/middleware.go:43 - The timeout for fetching an organization's session is hardcoded to 2 seconds. Hardcoding configuration values like this makes the system less adaptable to different operational environments and violates the principle of separating code from configuration.
🧠 Logic (1)
- ❌ system:0 - Global failure condition met
Powered by Visor from Probelabs
💡 TIP: You can chat with Visor using /visor ask <your question>
Annotations
Check failure on line 1282 in gateway/rpc_storage_handler.go
probelabs / Visor: architecture
architecture Issue
The context-aware method `GetKeyContext` does not propagate the context to the underlying blocking call (`r.GetKey`). This defeats the purpose of using a context for cancellation and timeouts, leading to a goroutine leak if the backend is unresponsive. The goroutine spawned in `fetchOrgSessionWithTimeout` will block indefinitely even after its parent context times out.
Raw output
Propagate the context to the underlying network call. For an HTTP-based RPC handler, this typically involves using `http.NewRequestWithContext(ctx, ...)` to create the request.
Check failure on line 250 in gateway/ldap_auth_handler.go
probelabs / Visor: architecture
architecture Issue
The context-aware method `GetKeyContext` does not propagate the context to the underlying blocking call (`l.GetKey`). This defeats the purpose of using a context for cancellation and timeouts, leading to a goroutine leak if the backend is unresponsive. The goroutine spawned in `fetchOrgSessionWithTimeout` will block indefinitely even after its parent context times out.
Raw output
Update the underlying LDAP client call to respect the context's deadline or cancellation signal. If the client library does not support contexts, this implementation is fundamentally unsafe for concurrent, time-bound operations.
Check failure on line 297 in storage/mdcb_storage.go
probelabs / Visor: architecture
architecture Issue
The context-aware method `GetKeyContext` does not propagate the context to the underlying blocking call (`m.GetKey`). This defeats the purpose of using a context for cancellation and timeouts, leading to a goroutine leak if the backend is unresponsive. The goroutine spawned in `fetchOrgSessionWithTimeout` will block indefinitely even after its parent context times out.
Raw output
Propagate the context through the MDCB client calls to ensure that network operations can be cancelled or timed out correctly. This may require updating the `getFromRPCAndCache` and `getFromLocal` methods to be context-aware.
Check warning on line 43 in gateway/middleware.go
probelabs / Visor: architecture
architecture Issue
The timeout for fetching an organization's session is hardcoded to 2 seconds. Hardcoding configuration values like this makes the system less adaptable to different operational environments and violates the principle of separating code from configuration.
Raw output
Externalize this timeout value by making it a configurable parameter in the gateway's main configuration file (e.g., `tyk.conf`). This allows operators to tune the behavior for their specific environment without requiring a code change.