InABox: Check snapshot regions before creating box#222
InABox: Check snapshot regions before creating box#222Davis-A merged 2 commits intofastmail:mainfrom
Conversation
|
The functionality is there. But i need to update the test suite before merging. |
cc805ba to
1f90f99
Compare
|
Tests fixed so i think this is good to go |
|
|
||
| if ($compatible_regions) { | ||
| return await $event->reply( | ||
| "Unable to create snapshot in region '$region. Available compatible regions are $compatible_regions." |
There was a problem hiding this comment.
nit: missing closing quote after '$region
Same below
|
Nice, though you aren't testing for the new error conditions? Would be nice to! |
rjbs
left a comment
There was a problem hiding this comment.
You're going to have to change this when you rebase after the big test improvements, but it should be easy.
But also, I thing you've got more API requests than are needed for this? And testing the failure mode is probably a good idea, as Matthew said.
|
|
||
| # check snapshot is available in the users region | ||
| my %snapshot_regions = map {; $_ => 1 } | ||
| await $self->_get_snapshot_regions($snapshot->{id}); |
There was a problem hiding this comment.
This seems off to me. Above, with this line…
my $snapshot = await $self->_get_snapshot($version);…it seems like we should have a snapshot already retrieved. Then, _get_snapshot_regions goes and fetches it again. Meanwhile, the API reference suggests that the objects returned from _get_snapshot should already have the region data. That would mean that this branch is adding another round trip and another place for things to fail.
Can you, instead, look at $snapshot->{regions} without making another request?
There was a problem hiding this comment.
I am indeed an idiot. For some reason my brain decided that $snapshot was just an id, but clearly it's a hash because i'm getting the id from it 🤦
There was a problem hiding this comment.
If this is the worst mistake you make all week, you'll be doing great. 😄
When a snapshot is unavailable in the users datacentre it's much nicer to reply with a better response than "Something weird happened..."
d964dd3 to
290ffff
Compare
This adds the required data to the existing tests, And adds two tests for checking the snapshot region
290ffff to
dc6c6c2
Compare
|
Okie dokie. Re-done without my 🤦 error. Also added tests for the snapshot check too. |
When a snapshot is unavailable in the users datacentre it's much nicer to reply with a better response than "Something weird happened..."