Skip to content

Commit

Permalink
fix sled-agent sim panicking when unsetting migration
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jun 7, 2024
1 parent 631ba0f commit 1aecc88
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions sled-agent/src/sim/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,24 @@ impl SimInstanceInner {
}

self.state.set_migration_ids(ids, Utc::now());
let role = self

// If we set migration IDs and are the migration source, ensure that we
// will perform the correct state transitions to simulate a successful
// migration.
if ids.is_some() {
let role = self
.state
.migration()
.expect("we just got a `put_migration_ids` request, so we should have a migration")
.expect(
"we just got a `put_migration_ids` request with `Some` IDs, \
so we should have a migration"
)
.role;
if role == MigrationRole::Source {
self.queue_successful_migration(MigrationRole::Target)
if role == MigrationRole::Source {
self.queue_successful_migration(MigrationRole::Target)
}
}

Ok(self.state.sled_instance_state())
}
}
Expand Down

0 comments on commit 1aecc88

Please sign in to comment.