fix(tools): catch URLError in latestVersion and listAMIs - #691
Draft
deepak0x wants to merge 1 commit into
Draft
Conversation
Network-level failures (DNS, timeout, connection refused) raise urllib.error.URLError, which is not a subclass of HTTPError and was therefore uncaught, crashing the script before any output was written. Catch URLError in latestVersion() and listAMIs() and raise a clear RuntimeError with the underlying reason. Also set a 30s timeout on urlopen so unreachable hosts fail deterministically instead of hanging. Fixes flatcar/flatcar-website#690 Signed-off-by: Deepak Bhagat <deepak0x@users.noreply.github.com>
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.
Network-level failures (DNS, timeout, connection refused) raise
urllib.error.URLError, which is not a subclass ofHTTPErrorand was therefore uncaught. The exception propagated throughmain()and crashed the script before any output file was written.Changes
URLErrorand catch it inlatestVersion()andlistAMIs(), raising a clearRuntimeErrorwith the underlying reason (e.reason).timeout=30tourlopenso unreachable hosts fail deterministically instead of hanging indefinitely.URLError->RuntimeError(7/7 passing).Verification
Fixes flatcar/Flatcar#2364.
Note: this edits
tools/fcl-fetch-version-data.py, the same file as the open PR #688 (flatcar flatcar/Flatcar#2365, which fixed the silentNonereturn). The two are independent fixes; one will need a rebase after the other merges to resolve the overlappingexceptblock. Happy to rebase on request.