fix: apply rustfmt to restore transaction changes

This commit is contained in:
2026-09-18 01:12:38 +09:00
parent 20dfc168d5
commit bd47d064b5
6 changed files with 73 additions and 76 deletions
+2 -2
View File
@@ -17,9 +17,9 @@ pub use workspace_api::{
WorkerLaunchProfileCandidate as BackendWorkerLaunchProfileCandidate, WorkerLaunchProfileCandidate as BackendWorkerLaunchProfileCandidate,
WorkerLaunchRuntimeOption as BackendWorkerLaunchRuntimeOption, WorkerLaunchRuntimeOption as BackendWorkerLaunchRuntimeOption,
WorkerOperationState as BackendWorkerOperationState, WorkerOperationState as BackendWorkerOperationState,
WorkerRestoreState as BackendWorkerRestoreState,
WorkerRestoreResponse as BackendWorkerRestoreResponse, WorkerRestoreResponse as BackendWorkerRestoreResponse,
WorkerRestoreResult as BackendWorkerRestoreResult, WorkerSummary as BackendWorkerSummary, WorkerRestoreResult as BackendWorkerRestoreResult,
WorkerRestoreState as BackendWorkerRestoreState, WorkerSummary as BackendWorkerSummary,
WorkerWorkspaceSummary as BackendWorkerWorkspaceSummary, WorkerWorkspaceSummary as BackendWorkerWorkspaceSummary,
WorkingDirectoryCreateRequest as BackendWorkingDirectoryCreateRequest, WorkingDirectoryCreateRequest as BackendWorkingDirectoryCreateRequest,
WorkingDirectoryCreateResponse as BackendWorkingDirectoryCreateResponse, WorkingDirectoryCreateResponse as BackendWorkingDirectoryCreateResponse,
+4 -4
View File
@@ -27,10 +27,10 @@ pub use backend_runtime::{
BackendWorkerCapabilitySummary, BackendWorkerImplementationSummary, BackendWorkerLaunchOptions, BackendWorkerCapabilitySummary, BackendWorkerImplementationSummary, BackendWorkerLaunchOptions,
BackendWorkerLaunchProfileCandidate, BackendWorkerLaunchRuntimeOption, BackendWorkerLaunchProfileCandidate, BackendWorkerLaunchRuntimeOption,
BackendWorkerLaunchTarget, BackendWorkerOperationState, BackendWorkerRestoreResponse, BackendWorkerLaunchTarget, BackendWorkerOperationState, BackendWorkerRestoreResponse,
BackendWorkerRestoreResult, BackendWorkerRestoreState, BackendWorkerSummary, BackendWorkerWorkspaceSummary, BackendWorkerRestoreResult, BackendWorkerRestoreState, BackendWorkerSummary,
BackendWorkingDirectorySummary, connect_backend_runtime, create_backend_worker, BackendWorkerWorkspaceSummary, BackendWorkingDirectorySummary, connect_backend_runtime,
get_backend_worker_launch_options, list_backend_stopped_workers, list_backend_workers, create_backend_worker, get_backend_worker_launch_options, list_backend_stopped_workers,
restore_backend_worker, list_backend_workers, restore_backend_worker,
}; };
pub use backend_workspace::{ pub use backend_workspace::{
BackendWorkspace, BackendWorkspaceCatalogTarget, BackendWorkspaceClientError, BackendWorkspace, BackendWorkspaceCatalogTarget, BackendWorkspaceClientError,
+1 -1
View File
@@ -60,7 +60,6 @@ use protocol::subscription::{
SubscriptionTerminationCode, SubscriptionTerminationCode,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use workspace_api::WorkerRestoreState;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt; use std::fmt;
use std::net::SocketAddr; use std::net::SocketAddr;
@@ -75,6 +74,7 @@ use workdir::{
WorkdirTransportError, WorkdirTransportErrorCode, WorkdirTransportError, WorkdirTransportErrorCode,
}, },
}; };
use workspace_api::WorkerRestoreState;
const DEFAULT_RUNTIME_HTTP_PORT: u16 = 38800; const DEFAULT_RUNTIME_HTTP_PORT: u16 = 38800;
pub const RUNTIME_HTTP_PROTOCOL_MIN_VERSION: u32 = 1; pub const RUNTIME_HTTP_PROTOCOL_MIN_VERSION: u32 = 1;
+13 -9
View File
@@ -1449,7 +1449,8 @@ impl Runtime {
/// converges on its already-installed execution rather than spawning another /// converges on its already-installed execution rather than spawning another
/// controller. /// controller.
pub fn restore_worker(&self, worker_ref: &WorkerRef) -> Result<WorkerDetail, RuntimeError> { pub fn restore_worker(&self, worker_ref: &WorkerRef) -> Result<WorkerDetail, RuntimeError> {
self.restore_worker_operation(worker_ref)?.into_legacy_result() self.restore_worker_operation(worker_ref)?
.into_legacy_result()
} }
pub fn restore_worker_operation( pub fn restore_worker_operation(
@@ -1567,7 +1568,8 @@ impl Runtime {
); );
match commit { match commit {
Ok(worker) => Ok(RuntimeWorkerRestoreResult::accepted(worker)), Ok(worker) => Ok(RuntimeWorkerRestoreResult::accepted(worker)),
Err(error) => match self.cleanup_failed_restore(&backend, worker_ref, &handle) { Err(error) => {
match self.cleanup_failed_restore(&backend, worker_ref, &handle) {
Ok(()) => { Ok(()) => {
tracing::warn!( tracing::warn!(
worker_id = %worker_ref.worker_id, worker_id = %worker_ref.worker_id,
@@ -1605,7 +1607,8 @@ impl Runtime {
"Worker restore result is uncertain; reread or retry the Worker restore", "Worker restore result is uncertain; reread or retry the Worker restore",
)) ))
} }
}, }
}
} }
} }
WorkerExecutionSpawnResult::Rejected(_result) => { WorkerExecutionSpawnResult::Rejected(_result) => {
@@ -1617,8 +1620,7 @@ impl Runtime {
} }
WorkerExecutionSpawnResult::RolledBack(_result) => { WorkerExecutionSpawnResult::RolledBack(_result) => {
#[cfg(feature = "fs-store")] #[cfg(feature = "fs-store")]
self.lock()? self.lock()?.record_restore_failure(worker_ref, _result)?;
.record_restore_failure(worker_ref, _result)?;
Ok(RuntimeWorkerRestoreResult::failed( Ok(RuntimeWorkerRestoreResult::failed(
WorkerRestoreState::RolledBack, WorkerRestoreState::RolledBack,
"worker_restore_rolled_back", "worker_restore_rolled_back",
@@ -7466,12 +7468,14 @@ mod tests {
.unwrap(); .unwrap();
runtime.stop_worker(&created.worker_ref, None).unwrap(); runtime.stop_worker(&created.worker_ref, None).unwrap();
let before = runtime.worker_detail(&created.worker_ref).unwrap(); let before = runtime.worker_detail(&created.worker_ref).unwrap();
backend.preflight_restore_result.lock().unwrap().replace( backend
WorkerExecutionResult::rejected( .preflight_restore_result
.lock()
.unwrap()
.replace(WorkerExecutionResult::rejected(
WorkerExecutionOperation::Restore, WorkerExecutionOperation::Restore,
"profile is no longer permitted", "profile is no longer permitted",
), ));
);
let result = runtime let result = runtime
.restore_worker_operation(&created.worker_ref) .restore_worker_operation(&created.worker_ref)
+9 -14
View File
@@ -1826,21 +1826,13 @@ where
.lock() .lock()
.unwrap_or_else(|poisoned| poisoned.into_inner()); .unwrap_or_else(|poisoned| poisoned.into_inner());
if workers.contains_key(&worker_ref) { if workers.contains_key(&worker_ref) {
let existing_worker_state = workers.get(&worker_ref).and_then(|worker| { let existing_worker_state = workers
worker .get(&worker_ref)
.worker_state .and_then(|worker| worker.worker_state.read().ok().map(|state| state.clone()));
.read()
.ok()
.map(|state| state.clone())
});
let existing_handle = WorkerExecutionHandle::new(worker_ref.clone(), self.backend_id()); let existing_handle = WorkerExecutionHandle::new(worker_ref.clone(), self.backend_id());
drop(workers); drop(workers);
let cleanup = self.cleanup_unconnected_controller( let cleanup =
&handle, self.cleanup_unconnected_controller(&handle, &shutdown, &tasks, &worker_state);
&shutdown,
&tasks,
&worker_state,
);
let result = WorkerExecutionResult::busy( let result = WorkerExecutionResult::busy(
operation, operation,
match &cleanup { match &cleanup {
@@ -2170,7 +2162,10 @@ where
drop(workers); drop(workers);
if let Some(previous) = request.previous_working_directory.as_ref() { if let Some(previous) = request.previous_working_directory.as_ref() {
let materializer = self.working_directory_materializer.as_ref().ok_or_else(|| { let materializer = self
.working_directory_materializer
.as_ref()
.ok_or_else(|| {
WorkerExecutionResult::rejected( WorkerExecutionResult::rejected(
WorkerExecutionOperation::Restore, WorkerExecutionOperation::Restore,
"Persisted Worker Workdir binding cannot be restored by this Runtime", "Persisted Worker Workdir binding cannot be restored by this Runtime",
+7 -9
View File
@@ -52,10 +52,10 @@ use worker_runtime::http_server::{
RuntimeHttpWorkerCompletionsResponse, RuntimeHttpWorkerDeleteResponse, RuntimeHttpWorkerCompletionsResponse, RuntimeHttpWorkerDeleteResponse,
RuntimeHttpWorkerInputResponse, RuntimeHttpWorkerLifecycleRequest, RuntimeHttpWorkerInputResponse, RuntimeHttpWorkerLifecycleRequest,
RuntimeHttpWorkerLifecycleResponse, RuntimeHttpWorkerResponse, RuntimeHttpWorkerLifecycleResponse, RuntimeHttpWorkerResponse,
RuntimeHttpWorkerRestoreResponse, RuntimeHttpWorkerRestoreResponse, RuntimeHttpWorkerWorkspaceApiRequest,
RuntimeHttpWorkerWorkspaceApiRequest, RuntimeHttpWorkersResponse, RuntimeHttpWorkersResponse, RuntimeHttpWorkingDirectoriesResponse,
RuntimeHttpWorkingDirectoriesResponse, RuntimeHttpWorkingDirectoryResponse, RuntimeHttpWorkingDirectoryResponse, RuntimeHttpWorkspacePromptProjectionRequest,
RuntimeHttpWorkspacePromptProjectionRequest, RuntimeHttpWorkspacePromptProjectionResponse, RuntimeHttpWorkspacePromptProjectionResponse,
}; };
use worker_runtime::identity::{ use worker_runtime::identity::{
RuntimeWorkerRef, WorkerId as EmbeddedWorkerId, WorkerRef as EmbeddedWorkerRef, RuntimeWorkerRef, WorkerId as EmbeddedWorkerId, WorkerRef as EmbeddedWorkerRef,
@@ -2350,11 +2350,9 @@ impl WorkspaceWorkerRuntime for EmbeddedWorkerRuntime {
match self.runtime.restore_worker_operation(&worker_ref) { match self.runtime.restore_worker_operation(&worker_ref) {
Ok(result) => { Ok(result) => {
let diagnostics = match (result.reason_code, result.message) { let diagnostics = match (result.reason_code, result.message) {
(Some(code), Some(message)) => vec![diagnostic( (Some(code), Some(message)) => {
code, vec![diagnostic(code, DiagnosticSeverity::Warning, message)]
DiagnosticSeverity::Warning, }
message,
)],
_ => Vec::new(), _ => Vec::new(),
}; };
WorkerRestoreResult { WorkerRestoreResult {