Automattic / hostmgr

A tool for managing macOS VM hosts
Mozilla Public License 2.0
8 stars 3 forks source link

Support resuming of aborted uploads during `vm publish` #89

Closed AliSoftware closed 3 months ago

AliSoftware commented 3 months ago

Quick implementation of a resume mechanism for hostmgr vm publish.

Closes https://github.com/Automattic/hostmgr/issues/86

Note: This PR sits on top of https://github.com/Automattic/hostmgr/pull/88 and targets the vm-list-cleanup branch, to avoid conflicts while working on those different features of the codebase.

How it works

AliSoftware commented 3 months ago

I ran it locally and there's no indication from the logs that we're resuming, so I wonder if we'd be able to tell if it weren't?

Yeah I considered adding logs, then realized that from within tinys3 library we're not really supposed to print into STDOUT (i.e. every reporting is done via the progressCallback, and the caller of tinys3 (<- libhostmgr <- hostmgr CLI) are the ones providing the entry points into the Terminal output…

So while I initially added a print there, I figured the right way to do it would instead be to provide some logCallback entry point in tinys3 then libhostmgr that would be fed and provided by the hostmgr client / executable. This can certainly be done, but was adding a lot of cruft to the various API layers for little benefit, so I figured it wasn't worth it just for that simple log info.


PS: Besides, since parts are uploaded in parallel, and thus it can be possible that when the upload got interrupted only part 2 and 3 were uploaded but not part 1 for example, that means that during resume the progress would start and upload part 1, calling progressCallback and printing the new % values to the terminal… and then in the middle of it we'd print some logs in a new line about parts 2 and 3; meaning that the ProgressBar would then resume counting % on the line after (if not overriding the log, depending on \n vs \r…). Not the end of the world, but would make the ProgressBar output in the Terminal look a big ugly due to being interrupted by those logs randomly 🤔

AliSoftware commented 3 months ago

I ran it locally and there's no indication from the logs that we're resuming, so I wonder if we'd be able to tell if it weren't?

btw FWIW the way I tested this was: