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

Wait for TFTP downloads #886

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Feb 12, 2024

The /fetch_boot_file API is used to download TFTP files. The HttpDownload task is implemented as a thread. Previously it was fired off and there was no way to see the result. This implements code that waits for some time before telling the client the task is still running. There is no way for the client to find out if it really did finish.

Currently untested, but this at least shows the principle.

The /fetch_boot_file API is used to download TFTP files. The
HttpDownload task is implemented as a thread. Previously it was fired
off and there was no way to see the result. This implements code that
waits for some time before telling the client the task is still running.
There is no way for the client to find out if it really did finish.
@ekohl
Copy link
Member Author

ekohl commented Feb 12, 2024

Related: #472 implemented a mechanism to poll the status. Probably worth looking at that downloader implementation even if we continue to wrap curl.

# This waits for a bit before telling the client we've accepted it
# TODO: implement a mechanism to poll for completion
if result.respond_to(:join)
202 unless result.join(5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming webrick is single threaded, does this mean that this will block for up to five seconds, preventing any other requests from being processed during that time?

Copy link
Member Author

Choose a reason for hiding this comment

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

Certainly a concern. I was debating this, how to make it configurable. But I also assumed we at least had some threads in Webrick. Yet I can't find proof for it. That may invalidate the whole approach.

Perhaps a mechanism similar to #472 to return a HTTP 202 with a task ID to poll for is a better approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

For an unrelated item I looked into this. Webrick has a single thread to accept clients, but then starts a thread for every client.

https://github.com/ruby/webrick/blob/cd0b1dd2286492287876773e719bb50a533d2698/lib/webrick/server.rb#L173-L194

So that would mean this just runs a sleep in its own thread, I don't see how it would be a problem.

Still, a proper task ID that can be monitored is a much better API. Both approaches aren't mutually exclusive though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants