-
Notifications
You must be signed in to change notification settings - Fork 38
fix(agent): handle None response from retry exhaustion to prevent crashes #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,12 +214,20 @@ def post_result(self, job_id, data): | |
| logger.error(exc) | ||
| raise TFServerError("other exception") from exc | ||
| if not job_request: | ||
| logger.error( | ||
| "Unable to post results to: %s (error: %d)", | ||
| result_uri, | ||
| job_request.status_code, | ||
| ) | ||
| raise TFServerError(job_request.status_code) | ||
| if job_request is None: | ||
| logger.error( | ||
| "Unable to post results to: %s (error: %s)", | ||
| result_uri, | ||
| "No response received", | ||
| ) | ||
| raise TFServerError("No response received") | ||
| else: | ||
| logger.error( | ||
| "Unable to post results to: %s (error: %d)", | ||
| result_uri, | ||
| job_request.status_code, | ||
| ) | ||
| raise TFServerError(job_request.status_code) | ||
|
|
||
| def get_result(self, job_id): | ||
| """Get current results data to the testflinger server for this job. | ||
|
|
@@ -238,11 +246,18 @@ def get_result(self, job_id): | |
| logger.error(exc) | ||
| return {} | ||
| if not job_request: | ||
| logger.error( | ||
| "Unable to get results from: %s (error: %d)", | ||
| result_uri, | ||
| job_request.status_code, | ||
| ) | ||
| if job_request is None: | ||
| logger.error( | ||
| "Unable to get results from: %s (error: %s)", | ||
| result_uri, | ||
| "No response received", | ||
| ) | ||
| else: | ||
| logger.error( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated! |
||
| "Unable to get results from: %s (error: %d)", | ||
| result_uri, | ||
| job_request.status_code, | ||
| ) | ||
| return {} | ||
| if job_request.content: | ||
| return job_request.json() | ||
|
|
@@ -332,12 +347,20 @@ def save_artifacts(self, rundir, job_id): | |
| artifact_uri, files=file_upload, timeout=600 | ||
| ) | ||
| if not artifact_request: | ||
| logger.error( | ||
| "Unable to post results to: %s (error: %d)", | ||
| artifact_uri, | ||
| artifact_request.status_code, | ||
| ) | ||
| raise TFServerError(artifact_request.status_code) | ||
| if artifact_request is None: | ||
| logger.error( | ||
| "Unable to post results to: %s (error: %s)", | ||
| artifact_uri, | ||
| "No response received", | ||
| ) | ||
| raise TFServerError("No response received") | ||
| else: | ||
| logger.error( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated! |
||
| "Unable to post results to: %s (error: %d)", | ||
| artifact_uri, | ||
| artifact_request.status_code, | ||
| ) | ||
| raise TFServerError(artifact_request.status_code) | ||
| else: | ||
| shutil.rmtree(artifacts_dir) | ||
|
|
||
|
|
@@ -523,10 +546,15 @@ def post_status_update( | |
| ) | ||
| # Response code is greater than 399 | ||
| if not job_request: | ||
| error_msg = ( | ||
| "No response received" | ||
| if job_request is None | ||
| else f"HTTP {job_request.status_code}" | ||
| ) | ||
| logger.error( | ||
| "Unable to post status updates to: %s (error: %d)", | ||
| "Unable to post status updates to: %s (error: %s)", | ||
| status_update_uri, | ||
| job_request.status_code, | ||
| error_msg, | ||
| ) | ||
| except requests.exceptions.RequestException as exc: | ||
| logger.error( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding tests for the new
Nonebranch, but could you please also add tests for these otherelsebranches where the responses have status codes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!