Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an early-return in PythonTask.execute so that when the task callable returns a falsy value (e.g. b"" from a failed curl/auth-denied response in sgcollect's /debug/_pprof capture), no bytes are written to the destination file. Two new tests cover the empty-result path for both add_file_task and make_curl_task.
Changes:
PythonTask.executereturns 0 immediately whenself.callable()produces a falsy result, avoiding the subsequentresult.encode()/fp.write(result)calls.- Adds
test_add_file_task_zero_sizeandtest_make_curl_task_zero_sizeexercising the empty-result path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/tasks.py | Skip writing/encoding when a PythonTask callable returns a falsy result. |
| tools-tests/tasks_test.py | New tests for the zero-size result handling in add_file_task and make_curl_task. |
Comment on lines
+232
to
+233
| if not result: | ||
| return 0 |
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.
CBG-5425 avoid writing zero sized files into sgcollect
When authentication fails some of the output for
/debug/_pprofends up 0 sized. These files aren't useful in sgcollect, and we know why a task failed insync_gateway.log. I find this very confusing when looking at these files.Pre-review checklist
fmt.Print,log.Print, ...)base.UD(docID),base.MD(dbName))docs/api