Skip to content
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

fix: Handle accept result and download result errors #416

Merged
merged 4 commits into from
Oct 31, 2024

Conversation

bgins
Copy link
Contributor

@bgins bgins commented Oct 24, 2024

Summary

This pull request makes the following changes:

  • Handle acceptResult errors
  • Handle downloadResult errors
  • Check for existing downloads before downloading results
  • Update error channel to non-blocking buffered channel

We would like to handle these errors to avoid silently failing when running jobs from the CLI. Error reporting also supports observing this information in traces.

The unbuffered error channel blocks on the receiver which does not get set up before the send. The buffered channel will hold the message until the receiver is available to receive the message.

Task/Issue reference

Closes: #414

Test plan

Run a few jobs. Check that everything still works.

Running more than one job exercises the download check. If we attempt to download again, we would observe a file exists error.

To test the error cases, return a temporary error from the downloadResult and acceptResult functions.

Details (optional)

The new downloads check determines if we have already downloaded the results for a job. If the download path already exists, we skip the download. This check is necessary because our control loop checks for any completed deals and re-downloads the results. The solver may report completed deals for jobs whose results we already have.

@cla-bot cla-bot bot added the cla-signed label Oct 24, 2024
@github-actions github-actions bot added the fix label Oct 24, 2024
@bgins bgins force-pushed the bgins/fix-accept-and-download-errors branch from 34eb0a9 to f46c781 Compare October 24, 2024 22:13
// we have already downloaded. Check the download path and download
// if results do not exist.
downloadPath := solver.GetDownloadsFilePath(dealContainer.ID)
if _, err := os.Stat(downloadPath); errors.Is(err, fs.ErrNotExist) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common advice online recommends using os.IsNotExist, but the docs for this function recommend that new code should use errors.Is(err, fs.ErrNotExist): https://pkg.go.dev/os#IsNotExist

@bgins bgins marked this pull request as ready for review October 24, 2024 22:26
@bgins bgins requested a review from a team as a code owner October 24, 2024 22:26
@bgins bgins force-pushed the bgins/fix-accept-and-download-errors branch from f46c781 to 7124b34 Compare October 25, 2024 21:19
The unbuffered error channel blocks on the receiver which does not
get set up in time. The buffered channel will hold the message until
the receiver is available.
@bgins bgins mentioned this pull request Oct 28, 2024
2 tasks
Copy link
Collaborator

@walkah walkah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@@ -161,7 +164,7 @@ func (controller *JobCreatorController) subscribeToWeb3() error {
}

func (controller *JobCreatorController) Start(ctx context.Context, cm *system.CleanupManager) chan error {
errorChan := make(chan error)
errorChan := make(chan error, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch on this! 🙏

@bgins bgins merged commit c2c4a11 into main Oct 31, 2024
5 checks passed
@bgins bgins deleted the bgins/fix-accept-and-download-errors branch October 31, 2024 20:35
walkah pushed a commit that referenced this pull request Dec 10, 2024
* fix: Add accept result error handling

* fix: Add download result error handling

* fix: Check download path before downloading

If the path exists, we have already attempted to download the results.

* fix: Unblock error channel

The unbuffered error channel blocks on the receiver which does not
get set up in time. The buffered channel will hold the message until
the receiver is available.
@bgins bgins self-assigned this Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle accept result and download result errors
2 participants