Skip to content

[4/5] User data export: background task and sagas#10330

Open
jmpesp wants to merge 3 commits intooxidecomputer:mainfrom
jmpesp:user_data_export_04_task_and_sagas
Open

[4/5] User data export: background task and sagas#10330
jmpesp wants to merge 3 commits intooxidecomputer:mainfrom
jmpesp:user_data_export_04_task_and_sagas

Conversation

@jmpesp
Copy link
Copy Markdown
Contributor

@jmpesp jmpesp commented Apr 27, 2026

The determination in RFD 563 was to attach all read-only resources to a Pantry for export. This is implemented by a new "user data export coordinator" background task that will read the contents of the changeset (added in PR 1 in this set), and create user data export objects in their initial "Requested" state.

This commit also adds create and delete sagas for these objects - a saga is required for the safe locking and unlocking pattern that was used, along with the correct behaviour for interacting with a Pantry. The new background task invokes these sagas based on the contents of the computed changeset.

The last thing that the background task will do is query for a list of in-service Pantry addresses, and use that to mark any user data export objects that reference an expunged Pantry.

This commit also fixes a previously committed bug: do not return user data export objects in the "delete required" part of the changeset if it was already deleted!

The determination in RFD 563 was to attach _all_ read-only resources to
a Pantry for export. This is implemented by a new "user data export
coordinator" background task that will read the contents of the
changeset (added in PR 1 in this set), and create user data export
objects in their initial "Requested" state.

This commit also adds create and delete sagas for these objects - a saga
is required for the safe locking and unlocking pattern that was used,
along with the correct behaviour for interacting with a Pantry. The new
background task invokes these sagas based on the contents of the
computed changeset.

The last thing that the background task will do is query for a list of
in-service Pantry addresses, and use that to mark any user data export
objects that reference an expunged Pantry.

This commit also fixes a previously committed bug: do not return user
data export objects in the "delete required" part of the changeset if it
was already deleted!
@jmpesp jmpesp requested a review from leftwo April 27, 2026 19:44
Copy link
Copy Markdown
Contributor

@leftwo leftwo left a comment

Choose a reason for hiding this comment

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

Some minor questions before we talk live later.

UserDataExportState::Deleted => {
// We shouldn't ever get here: the changeset shouldn't
// include a record that needs deletion but is already
// deleted.
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.

We should at least log an error here?

}
};

error!(&log, "changeset is {changeset:?}");
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.

Should this be info!?

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.

yes! changed in f768f55

let result: UserDataExportCoordinatorStatus =
serde_json::from_value(task.activate(&opctx).await).unwrap();

eprintln!("{result:?}");
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.

There is no race here, right? when the await above returns the task will have done what we are checking for?

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.

task.activate should actually run the background task yeah - this isn't the same as the integration test's use of the lockstep API to trigger tasks, which won't wait until the activation is done

}

/// Detach the volume from the Pantry, and it's ok if the Pantry bounced and
/// lost the attachment.
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.

If a pantry goes away and comes back, it does not automatically re-attach all the things that were attached to it before it departed, correct?

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.

correct, that's up to Nexus - as of this PR Nexus does not know when a Pantry bounces, but if there's an attempted read sent to a pantry by Nexus that returns 404, that user data object is marked as deleted, and a new object will be created.

audit_log_cleanup.period_secs = 600
audit_log_cleanup.retention_days = 90
audit_log_cleanup.max_deleted_per_activation = 10000
user_data_export_coordinator.period_secs = 240
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.

Where did the 240 come from? :)

error, details
),

Ok(status) => {
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.

How hard would it be to make this cumulative instead of just showing the values
from the last run?

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.

not much work :) 9ac0abc only sets deleted for non-deleted records, meaning the background task will now only show the latest number of affected records

@AlejandroME AlejandroME added this to the 20 milestone Apr 29, 2026
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