jozu-ai / kitops

Tools for easing the handoff between AI/ML and App/SRE teams.
https://KitOps.ml
Apache License 2.0
339 stars 34 forks source link

Add support for resumable downloads; clean up ingest directory; add `--concurrency` flag #408

Closed amisevsk closed 2 months ago

amisevsk commented 2 months ago

Description

Add support for resuming downloads that were cancelled/hit an error in an earlier invocation. Doing this required implementing our own Pull routine, separate from oras.Copy, which is used elsewhere.

If a server responds with header Accept-Ranges: "bytes", treat the download as resumable; otherwise, pull behaves as before. For resumable downloads:

There's some risk of corruption if e.g. two separate kit pulls are pulling the same resumable download simultaneously, though I think the risk is fairly low and I'm not sure we care to support running kit in parallel at this moment.

When a pull is completed, all data in the ingest directory is removed. This is to ensure we don't leave files lying around with no easy path to their removal, which can happen with non-resumable downloads that are e.g. cancelled via ctrl-C. This means that completing a pull effectively cancels all other downloads.

Finally, since I had to add reimplement concurrency for the pull operation, I've added a --concurrency flag to allow configuring it. It's available on all commands that take the standard network options, but is currently only used for pull and push.

Linked issues

Closes #311 Closes #387