Skip to content

box sizes: show droplet sizes available for a snapshot#6

Open
rjbs wants to merge 15 commits intofastmail:mainfrom
rjbs:sizes
Open

box sizes: show droplet sizes available for a snapshot#6
rjbs wants to merge 15 commits intofastmail:mainfrom
rjbs:sizes

Conversation

@rjbs
Copy link
Member

@rjbs rjbs commented Feb 26, 2026

No description provided.

rjbs and others added 4 commits March 5, 2026 10:19
Co-Authored-By: Claude <noreply@anthropic.com>
The size and region attributes on a ProvisionRequest are now sugar for
single-element size_preferences and region_preferences.  These
attributes are new.

You need to provide size_preferences, which is a reference to an ordered
array of size slugs.  You want the first available size in that list.

You *may* provide region_preferences, which lists the region you'd like
the Droplet to be in.  If no region_preferences is given, it's treated
as a randomly-ordered list of all the regions in which the desired
snapshot is present.  Some snapshots (like Digital Ocean's generic
"debian" snapshot) can't be queries for availability, so we assume they
are present in all regions.

When both are provided, better-size trumps better-region.  If you want
to flip that, the new prefer_proximity attribute does so.  (For example,
you might want a low-latency box for interactive work.)

Co-Authored-By: Claude <noreply@anthropic.com>
Dobby::TestClient subclasses Dobby::Client, replacing Net::Async::HTTP
with Test::Async::HTTP and routing requests to per-path handler coderefs,
so tests can exercise the full client stack without network access.

t/resolve-size-region.t covers the single-pref fast path (with and
without a snapshot region constraint), multi-pref fallback, prefer_proximity
priority inversion, no-region-preference derivation from snapshot, and
the no-match error case.
resolve-size-region.t: two new cases covering the multi-pref path where the
snapshot constraint eliminates a candidate region, and the no-region/no-snapshot
path where candidate regions are derived from the sizes list.

provision-request.t: covers BUILDARGS normalization (hashref and flat-list
construction), pass-through of preference arrays, and all three error paths
(both size attrs, neither size attr, both region attrs).

boxmanager.t: covers BoxManager::BUILD rejecting missing and duplicate stream
callbacks, and get_snapshot_for_version returning the most recent match,
filtering by version, and erroring when no match exists.

Co-Authored-By: Claude <noreply@anthropic.com>
rjbs and others added 11 commits March 5, 2026 19:35
* config now can have region and size preferences
* region loses its fallback default, falls back to "whatever region"
* --size and --region can be given multiple times to set preferences
* --any-region overrides a configured preference list, means "whatever"

Co-Authored-By: Claude <noreply@anthropic.com>
When true, regions not in region_preferences are appended as lower-priority
candidates after the preference list is exhausted, allowing a preferred
region to be tried first while still permitting any available region.

The fast path is skipped when fallback_to_anywhere is set, since it always
needs the full sizes list to build the fallback candidate pool.

create.pm: --region and --any-region no longer conflict; combining them
sets fallback_to_anywhere so preferred regions are tried first and any
region is permitted as a fallback.

Co-Authored-By: Claude <noreply@anthropic.com>
Introducing: Dobby::BoxManager::CandidateSet!

This is a result object with candidates (one per size/region pair),
is_empty, and pick_one.  pick_one ranks by preference-list position
first, then price, then random for true ties.  prefer_proximity swaps
the primary sort key from size to region.

find_provisioning_candidates builds a CandidateSet from optional hardware
constraints (max/min price, min cpu/disk/ram), size/region preference
filters, snapshot availability, and fallback_to_anywhere.

_resolve_size_and_region is now a thin wrapper around
find_provisioning_candidates + pick_one.

"box sizes" also now uses find_provisioning_candidates.

Co-Authored-By: Claude <noreply@anthropic.com>
Covers all five hardware constraint filters (max/min price, min cpu/disk/ram),
snapshot region restriction, size and region preference filtering,
fallback_to_anywhere, and pick_one behavior (cheapest wins with no
preferences, preference rank beats price, prefer_proximity selects by region
then price).

Co-Authored-By: Claude <noreply@anthropic.com>
find_provisioning_candidates now separately tracks candidates that were
excluded solely by region_preferences filtering.  These are available via
->region_excluded_candidates on the returned CandidateSet, and are always
empty when there are no region_preferences or when fallback_to_anywhere is
true.

Co-Authored-By: Claude <noreply@anthropic.com>
Passes the size/region preferences and fallback_to_anywhere from
~/.boxmate.toml into find_provisioning_candidates, so the sizes display
reflects what would actually be considered when creating a box.

Co-Authored-By: Claude <noreply@anthropic.com>
When --from-config (or region preferences) excludes a size from certain
regions, those regions now appear in the table marked with 'x' rather than
blank.  Sizes that only appear as excluded also get their own row.

Co-Authored-By: Claude <noreply@anthropic.com>
@rjbs rjbs marked this pull request as ready for review March 6, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant