Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 22 additions & 24 deletions nexus/src/app/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use nexus_types::deployment::{
};
use nexus_types::external_api::shared::TufSignedRootRole;
use nexus_types::external_api::views;
use nexus_types::external_api::views::TufRepoUploadStatus;
use nexus_types::internal_api::views as internal_views;
use nexus_types::inventory::RotSlot;
use omicron_common::api::external::InternalContext;
Expand Down Expand Up @@ -93,29 +92,28 @@ impl super::Nexus {
.await
.map_err(HttpError::from)?;

// If we inserted a new repository, move the `ArtifactsWithPlan` (which
// carries with it the `Utf8TempDir`s storing the artifacts) into the
// artifact replication background task, then immediately activate the
// task.
if response.status == TufRepoUploadStatus::Inserted {
self.tuf_artifact_replication_tx
.send(artifacts_with_plan)
.await
.map_err(|err| {
// In theory this should never happen; `Sender::send`
// returns an error only if the receiver has hung up, and
// the receiver should live for as long as Nexus does (it
// belongs to the background task driver).
//
// If this _does_ happen, the impact is that the database
// has recorded a repository for which we no longer have
// the artifacts.
Error::internal_error(&format!(
"failed to send artifacts for replication: {err}"
))
})?;
self.background_tasks.task_tuf_artifact_replication.activate();
}
// Move the `ArtifactsWithPlan` (which carries with it the
// `Utf8TempDir`s storing the artifacts) into the artifact replication
// background task, then immediately activate the task. (If this repo
// was already uploaded, the artifacts should immediately be dropped by
// the task.)
self.tuf_artifact_replication_tx
.send(artifacts_with_plan)
.await
.map_err(|err| {
// In theory this should never happen; `Sender::send`
// returns an error only if the receiver has hung up, and
// the receiver should live for as long as Nexus does (it
// belongs to the background task driver).
Copy link
Contributor

Choose a reason for hiding this comment

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

(This can happen during shutdown, where the order Tokio tasks are torn down in is undefined)

Copy link
Contributor

Choose a reason for hiding this comment

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

How about changing it to:

This error can only happen while Nexus's Tokio runtime is shutting down; Sender::send returns an error only if the receiver has hung up, and the receiver should live for as long as Nexus does (it belongs to the background task driver.)

In the unlikely event that it does happen within this narrow window, the impact is that the database has recorded a repository for which we no longer have the artifacts. The fix would be to reupload the repository.

//
// If this _does_ happen, the impact is that the database
// has recorded a repository for which we no longer have
// the artifacts.
Error::internal_error(&format!(
"failed to send artifacts for replication: {err}"
))
})?;
self.background_tasks.task_tuf_artifact_replication.activate();

Ok(response)
}
Expand Down
Loading