@@ -20,7 +20,6 @@ use nexus_types::deployment::{
2020} ;
2121use nexus_types:: external_api:: shared:: TufSignedRootRole ;
2222use nexus_types:: external_api:: views;
23- use nexus_types:: external_api:: views:: TufRepoUploadStatus ;
2423use nexus_types:: identity:: Asset ;
2524use nexus_types:: internal_api:: views as internal_views;
2625use nexus_types:: inventory:: BaseboardId ;
@@ -95,29 +94,30 @@ impl super::Nexus {
9594 . await
9695 . map_err ( HttpError :: from) ?;
9796
98- // If we inserted a new repository, move the `ArtifactsWithPlan` (which
99- // carries with it the `Utf8TempDir`s storing the artifacts) into the
100- // artifact replication background task, then immediately activate the
101- // task.
102- if response. status == TufRepoUploadStatus :: Inserted {
103- self . tuf_artifact_replication_tx
104- . send ( artifacts_with_plan)
105- . await
106- . map_err ( |err| {
107- // In theory this should never happen; `Sender::send`
108- // returns an error only if the receiver has hung up, and
109- // the receiver should live for as long as Nexus does (it
110- // belongs to the background task driver).
111- //
112- // If this _does_ happen, the impact is that the database
113- // has recorded a repository for which we no longer have
114- // the artifacts.
115- Error :: internal_error ( & format ! (
116- "failed to send artifacts for replication: {err}"
117- ) )
118- } ) ?;
119- self . background_tasks . task_tuf_artifact_replication . activate ( ) ;
120- }
97+ // Move the `ArtifactsWithPlan` (which carries with it the
98+ // `Utf8TempDir`s storing the artifacts) into the artifact replication
99+ // background task, then immediately activate the task. (If this repo
100+ // was already uploaded, the artifacts should immediately be dropped by
101+ // the task.)
102+ self . tuf_artifact_replication_tx
103+ . send ( artifacts_with_plan)
104+ . await
105+ . map_err ( |err| {
106+ // This error can only happen while Nexus's Tokio runtime is
107+ // shutting down; Sender::send returns an error only if the
108+ // receiver has hung up, and the receiver should live for
109+ // as long as Nexus does (it belongs to the background task
110+ // driver.)
111+ //
112+ // In the unlikely event that it does happen within this narrow
113+ // window, the impact is that the database has recorded a
114+ // repository for which we no longer have the artifacts. The fix
115+ // would be to reupload the repository.
116+ Error :: internal_error ( & format ! (
117+ "failed to send artifacts for replication: {err}"
118+ ) )
119+ } ) ?;
120+ self . background_tasks . task_tuf_artifact_replication . activate ( ) ;
121121
122122 Ok ( response)
123123 }
0 commit comments