-
Notifications
You must be signed in to change notification settings - Fork 63
Closed
Labels
Update SystemReplacing old bits with newer, cooler bitsReplacing old bits with newer, cooler bitscleanupCode cleanlinessCode cleanlinessnexusRelated to nexusRelated to nexus
Description
omicron/nexus/src/db/datastore.rs
Lines 3194 to 3228 in 6f6aba6
| pub async fn update_available_artifact_upsert( | |
| &self, | |
| artifact: UpdateAvailableArtifact, | |
| ) -> CreateResult<UpdateAvailableArtifact> { | |
| use db::schema::update_available_artifact::dsl; | |
| diesel::insert_into(dsl::update_available_artifact) | |
| .values(artifact.clone()) | |
| .on_conflict((dsl::name, dsl::version, dsl::kind)) | |
| .do_update() | |
| .set(artifact.clone()) | |
| .returning(UpdateAvailableArtifact::as_returning()) | |
| .get_result_async(self.pool()) | |
| .await | |
| .map_err(|e| public_error_from_diesel_pool(e, ErrorHandler::Server)) | |
| } | |
| pub async fn update_available_artifact_hard_delete_outdated( | |
| &self, | |
| current_targets_role_version: i64, | |
| ) -> DeleteResult { | |
| // We use the `targets_role_version` column in the table to delete any old rows, keeping | |
| // the table in sync with the current copy of artifacts.json. | |
| use db::schema::update_available_artifact::dsl; | |
| diesel::delete(dsl::update_available_artifact) | |
| .filter(dsl::targets_role_version.lt(current_targets_role_version)) | |
| .execute_async(self.pool()) | |
| .await | |
| .map(|_rows_deleted| ()) | |
| .map_err(|e| { | |
| Error::internal_error(&format!( | |
| "error deleting outdated available artifacts: {:?}", | |
| e | |
| )) | |
| }) | |
| } |
These are two separate datastore methods, but are always called together. Combine these into one method and use a transaction to ensure the list of artifacts in the database remains consistent.
(From #717)
Metadata
Metadata
Assignees
Labels
Update SystemReplacing old bits with newer, cooler bitsReplacing old bits with newer, cooler bitscleanupCode cleanlinessCode cleanlinessnexusRelated to nexusRelated to nexus