suborbital / subo

The Suborbital CLI
Apache License 2.0
81 stars 24 forks source link

feat: Compute -> E2Core Storage Migration #398

Closed rnpridgeon closed 1 year ago

rnpridgeon commented 1 year ago

Testing:

Manually tested against minio (s3 compatible), gcs (thanks dylan) and a temporary directory.

Setup

  1. Build subo 5.4, start compute creates some functions in the repl shut it down - storage root "./old"
  2. Install subo 6, start compute, create some function in the repl shut it down - storage root "./new"
  3. Build PR branch exec se2 migrate [storage root]
  4. Verify contents

In SCN I wrote some adhoc tests using the storage instances and pointed them at my test storage to confirm i could list tenatnts, find tenants, read the system value etc.

How it works:

  1. Walks storage and marks all assets of interest in a trie a. each asset is placed under a category root (tenant, runnable, bin, src) and points to the underlying resource

  2. Process each module binary so we can obtain the new ref (sha256 digest), create the new directory (ref) and copy the binary to its home. During this time we record the ref and place it in the tree in a new category (digest).

  3. Next we process the drafts, this requires looking up it's associative ref from the tree then creating a new directory, and finally copying the draft contents into that directory.

  4. Next we process all runnables which are translated into "modules" and recorded at the module rot directory.

  5. Next we need to collect all modules we process and record them in a tenant overview which is then placed at the tenant root directory.

  6. Finally we create a somewhat superficial system version number and place it in the system storage root. This mostly just needs to be greater than 0 so e2core can see that there are modules there for it to discover; subsequent deploys will increment this appropriately from there.

I decided to leave clean up as an exercise for the user to ensure they can gracefully recover in the event something terrible happens which didn't reproduce in my tests.