diff --git a/nexus/src/app/update.rs b/nexus/src/app/update.rs index 1550fee767..479f36ba71 100644 --- a/nexus/src/app/update.rs +++ b/nexus/src/app/update.rs @@ -20,7 +20,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::identity::Asset; use nexus_types::internal_api::views as internal_views; use nexus_types::inventory::BaseboardId; @@ -95,29 +94,30 @@ 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| { + // 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. + Error::internal_error(&format!( + "failed to send artifacts for replication: {err}" + )) + })?; + self.background_tasks.task_tuf_artifact_replication.activate(); Ok(response) }