fix: correct misleading log, swallowed exception, and HTTP client leak in RegistryTEEConnection.reconnect()#232
Open
amathxbt wants to merge 1 commit intoOpenGradient:mainfrom
Conversation
…nection.reconnect() Three bugs fixed: 1. Wrong log message — error said 'close previous HTTP client' but the failure was actually in _connect(), not in closing anything. 2. Exception was silently swallowed — callers had no way to know reconnect failed and self._active was left pointing to a potentially stale/dead TEE. 3. Resource leak — old HTTP client was never closed on a successful reconnect, leaking the underlying TCP connection. Fix: snapshot old_active before attempting _connect(), re-raise on failure with a correct warning-level log, and close the old client in the else branch only after a successful reconnect.
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.
Bug Fix:
RegistryTEEConnection.reconnect()— misleading log, swallowed exception, resource leakSummary
Three bugs found in
RegistryTEEConnection.reconnect()intee_connection.py:Bug 1 — Wrong log message
Before:
The log message says
"Failed to close previous HTTP client"— but the code never tried to close anything. The actual failure was inself._connect()(registry lookup, TLS handshake, etc.). The error message was completely wrong, making debugging nearly impossible.Bug 2 — Exception silently swallowed
After
self._connect()fails, the exception is caught and discarded. The caller (including_tee_refresh_loop) has no way to know that the reconnect failed.self._activestays pointing to the old (potentially dead) TEE and the system appears healthy.Bug 3 — Resource leak on successful reconnect
When
self._connect()succeeds, the oldActiveTEE.http_clientis never closed. The oldhttpxclient and its underlying TCP connection are leaked every time a reconnect happens (every 5 minutes by the background loop).Fix
Impact