-
Notifications
You must be signed in to change notification settings - Fork 74
Expunge and Decommission disks in planner #7286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
900319b
a78777c
34e1215
31f19c6
14e3d35
af64c4c
5f46bd1
8af63fc
953657e
5178c08
fb4b45f
89596c1
f479f29
e1b7fb1
9825039
729723c
816a5e4
22f9f63
de4a080
1822a2b
7be692d
01cbf78
e2e2cd5
a718ce4
7d67be7
9ca1a2d
55a65f8
b209435
2531105
4bb5048
f256467
a65ac3b
c9b4441
a46493a
ec69035
7ab7957
1b5a681
7999177
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,12 +154,13 @@ impl DataStore { | |
| ) -> Result<(), Error> { | ||
| opctx.authorize(authz::Action::Read, &authz::FLEET).await?; | ||
| use db::schema::physical_disk::dsl; | ||
| let now = Utc::now(); | ||
|
|
||
| diesel::update( | ||
| dsl::physical_disk.filter(dsl::id.eq(to_db_typed_uuid(id))), | ||
| ) | ||
| .filter(dsl::time_deleted.is_null()) | ||
| .set(dsl::disk_policy.eq(policy)) | ||
| .set((dsl::disk_policy.eq(policy), dsl::time_modified.eq(now))) | ||
| .execute_async(&*self.pool_connection_authorized(&opctx).await?) | ||
| .await | ||
| .map_err(|err| public_error_from_diesel(err, ErrorHandler::Server))?; | ||
|
|
@@ -174,12 +175,13 @@ impl DataStore { | |
| ) -> Result<(), Error> { | ||
| opctx.authorize(authz::Action::Read, &authz::FLEET).await?; | ||
| use db::schema::physical_disk::dsl; | ||
| let now = Utc::now(); | ||
|
|
||
| diesel::update( | ||
| dsl::physical_disk.filter(dsl::id.eq(to_db_typed_uuid(id))), | ||
| ) | ||
| .filter(dsl::time_deleted.is_null()) | ||
| .set(dsl::disk_state.eq(state)) | ||
| .set((dsl::disk_state.eq(state), dsl::time_modified.eq(now))) | ||
| .execute_async(&*self.pool_connection_authorized(&opctx).await?) | ||
| .await | ||
| .map_err(|err| public_error_from_diesel(err, ErrorHandler::Server))?; | ||
|
|
@@ -281,19 +283,24 @@ impl DataStore { | |
| .map_err(|e| public_error_from_diesel(e, ErrorHandler::Server)) | ||
| } | ||
|
|
||
| /// Decommissions all expunged disks. | ||
| pub async fn physical_disk_decommission_all_expunged( | ||
| /// Decommissions a single expunged disk. | ||
| pub async fn physical_disk_decommission( | ||
| &self, | ||
| opctx: &OpContext, | ||
| id: PhysicalDiskUuid, | ||
| ) -> Result<(), Error> { | ||
| opctx.authorize(authz::Action::Modify, &authz::FLEET).await?; | ||
| use db::schema::physical_disk::dsl; | ||
|
|
||
| let now = Utc::now(); | ||
| let conn = &*self.pool_connection_authorized(&opctx).await?; | ||
| diesel::update(dsl::physical_disk) | ||
| .filter(dsl::id.eq(to_db_typed_uuid(id))) | ||
| .filter(dsl::time_deleted.is_null()) | ||
| .physical_disk_filter(DiskFilter::ExpungedButActive) | ||
| .set(dsl::disk_state.eq(PhysicalDiskState::Decommissioned)) | ||
| .filter(dsl::disk_policy.eq(PhysicalDiskPolicy::Expunged)) | ||
| .set(( | ||
| dsl::disk_state.eq(PhysicalDiskState::Decommissioned), | ||
| dsl::time_modified.eq(now), | ||
| )) | ||
| .execute_async(conn) | ||
| .await | ||
| .map_err(|e| public_error_from_diesel(e, ErrorHandler::Server))?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two questions:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bump on these questions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooh, great catch. Sorry for not replying earlier. You are correct here. I added a filter for the I also went ahead and added a comment since callers should not care if the disk was actually decommissioned. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.