Skip to content

[reconfigurator] database support for PendingMgsUpdate for RoT#8588

Merged
karencfv merged 10 commits intooxidecomputer:mainfrom
karencfv:db-support-rot-update
Jul 20, 2025
Merged

[reconfigurator] database support for PendingMgsUpdate for RoT#8588
karencfv merged 10 commits intooxidecomputer:mainfrom
karencfv:db-support-rot-update

Conversation

@karencfv
Copy link
Copy Markdown
Contributor

@karencfv karencfv commented Jul 14, 2025

Equivalent of #8291 for RoT

Comment thread nexus/db-queries/src/db/datastore/deployment.rs
Comment on lines +1416 to 1452
// Load all pending RoT updates.
//
// Pagination is a little silly here because we will only allow one at a
// time in practice for a while, but it's easy enough to do.
let mut pending_updates_rot = Vec::new();
{
use nexus_db_schema::schema::bp_pending_mgs_update_rot::dsl;

let mut paginator = Paginator::new(
SQL_BATCH_SIZE,
dropshot::PaginationOrder::Ascending,
);
while let Some(p) = paginator.next() {
let batch = paginated(
dsl::bp_pending_mgs_update_rot,
dsl::hw_baseboard_id,
&p.current_pagparams(),
)
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id)))
.select(BpPendingMgsUpdateRot::as_select())
.load_async(&*conn)
.await
.map_err(|e| {
public_error_from_diesel(e, ErrorHandler::Server)
})?;

paginator = p.found_batch(&batch, &|d| d.hw_baseboard_id);
for row in batch {
pending_updates_rot.push(row);
}
}
}

// Load all pending SP updates.
let mut pending_updates_sp = Vec::new();
{
use nexus_db_schema::schema::bp_pending_mgs_update_sp::dsl;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only allow one of PendingMgsUpdate at a time, so I think it should be OK to have these two one after the other in this manner.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd get a double check on this from someone else, maybe @jgallagher. Everything else looks great to me!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll be on stand-by then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this looks fine!

Copy link
Copy Markdown
Contributor

@andrewjstone andrewjstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment on lines +1416 to 1452
// Load all pending RoT updates.
//
// Pagination is a little silly here because we will only allow one at a
// time in practice for a while, but it's easy enough to do.
let mut pending_updates_rot = Vec::new();
{
use nexus_db_schema::schema::bp_pending_mgs_update_rot::dsl;

let mut paginator = Paginator::new(
SQL_BATCH_SIZE,
dropshot::PaginationOrder::Ascending,
);
while let Some(p) = paginator.next() {
let batch = paginated(
dsl::bp_pending_mgs_update_rot,
dsl::hw_baseboard_id,
&p.current_pagparams(),
)
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id)))
.select(BpPendingMgsUpdateRot::as_select())
.load_async(&*conn)
.await
.map_err(|e| {
public_error_from_diesel(e, ErrorHandler::Server)
})?;

paginator = p.found_batch(&batch, &|d| d.hw_baseboard_id);
for row in batch {
pending_updates_rot.push(row);
}
}
}

// Load all pending SP updates.
let mut pending_updates_sp = Vec::new();
{
use nexus_db_schema::schema::bp_pending_mgs_update_sp::dsl;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd get a double check on this from someone else, maybe @jgallagher. Everything else looks great to me!

@karencfv karencfv enabled auto-merge (squash) July 20, 2025 22:11
@karencfv karencfv merged commit 39672a4 into oxidecomputer:main Jul 20, 2025
17 checks passed
@karencfv karencfv deleted the db-support-rot-update branch July 21, 2025 00:46
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.

3 participants