fix: preserve prepare progress during rollback retry

go
codex 3 weeks ago
parent 8d32cdfbd6
commit cc43455191

@ -314,9 +314,11 @@ final class CloudInstanceMigrationWorkflow
$stepStatus = 'pending';
if ($onRollbackPath) {
if ($key === 'prepare') {
$stepStatus = (string) $migration->error_code
=== 'migration_transfer_aborted'
? 'completed' : 'interrupted';
// A transfer job can only be queued after source prepare
// succeeds. Unlike error_code, this durable link is not
// rewritten when rollback itself fails and is retried.
$stepStatus = $migration->target_receive_job_id === null
? 'interrupted' : 'completed';
} elseif ($key === 'transfer') {
$stepStatus = $migration->target_receive_job_id === null
? 'skipped' : 'interrupted';

@ -151,6 +151,20 @@ $assert(($rollbackProjection['status'] ?? null) === 'rolled_back'
=== 'completed',
'Rollback progress hid the interrupted migration stage.');
$retryingRollback = $migration('rollback_running');
$retryingRollback->error_code = 'migration_source_rollback_failed';
$retryingRollback->target_receive_job_id = 2;
$retryProjection = CloudInstanceMigrationWorkflow::progress(
$retryingRollback
);
$assert(($step($retryProjection, 'prepare')['status'] ?? null)
=== 'completed'
&& ($step($retryProjection, 'transfer')['status'] ?? null)
=== 'interrupted'
&& ($step($retryProjection, 'rollback')['status'] ?? null)
=== 'running',
'Retrying rollback rewrote completed source preparation as interrupted.');
$completed = $migration('completed');
$completed->target_receive_job_id = 2;
$completed->activate_job_id = 3;

Loading…
Cancel
Save