fix: apply rustfmt to restore transaction changes
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,45 +1568,47 @@ 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) => {
|
||||||
Ok(()) => {
|
match self.cleanup_failed_restore(&backend, worker_ref, &handle) {
|
||||||
tracing::warn!(
|
Ok(()) => {
|
||||||
worker_id = %worker_ref.worker_id,
|
tracing::warn!(
|
||||||
error = %error,
|
worker_id = %worker_ref.worker_id,
|
||||||
"Worker restore commit failed and was rolled back"
|
error = %error,
|
||||||
);
|
"Worker restore commit failed and was rolled back"
|
||||||
Ok(RuntimeWorkerRestoreResult::failed(
|
);
|
||||||
WorkerRestoreState::RolledBack,
|
Ok(RuntimeWorkerRestoreResult::failed(
|
||||||
"worker_restore_commit_rolled_back",
|
WorkerRestoreState::RolledBack,
|
||||||
"Worker restore commit failed and cleanup completed",
|
"worker_restore_commit_rolled_back",
|
||||||
))
|
"Worker restore commit failed and cleanup completed",
|
||||||
}
|
))
|
||||||
Err(cleanup_error) => {
|
}
|
||||||
tracing::error!(
|
Err(cleanup_error) => {
|
||||||
worker_id = %worker_ref.worker_id,
|
|
||||||
error = %error,
|
|
||||||
cleanup_error = %cleanup_error,
|
|
||||||
"Worker restore requires reconciliation after commit and cleanup failures"
|
|
||||||
);
|
|
||||||
if let Err(retain_error) = self.retain_restore_execution_evidence(
|
|
||||||
worker_ref,
|
|
||||||
handle,
|
|
||||||
worker_state,
|
|
||||||
working_directory,
|
|
||||||
) {
|
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
worker_id = %worker_ref.worker_id,
|
worker_id = %worker_ref.worker_id,
|
||||||
error = %retain_error,
|
error = %error,
|
||||||
"failed to persist restore execution evidence; in-process reconciliation remains required"
|
cleanup_error = %cleanup_error,
|
||||||
|
"Worker restore requires reconciliation after commit and cleanup failures"
|
||||||
);
|
);
|
||||||
|
if let Err(retain_error) = self.retain_restore_execution_evidence(
|
||||||
|
worker_ref,
|
||||||
|
handle,
|
||||||
|
worker_state,
|
||||||
|
working_directory,
|
||||||
|
) {
|
||||||
|
tracing::error!(
|
||||||
|
worker_id = %worker_ref.worker_id,
|
||||||
|
error = %retain_error,
|
||||||
|
"failed to persist restore execution evidence; in-process reconciliation remains required"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Ok(RuntimeWorkerRestoreResult::failed(
|
||||||
|
WorkerRestoreState::ReconciliationRequired,
|
||||||
|
"worker_restore_reconciliation_required",
|
||||||
|
"Worker restore result is uncertain; reread or retry the Worker restore",
|
||||||
|
))
|
||||||
}
|
}
|
||||||
Ok(RuntimeWorkerRestoreResult::failed(
|
|
||||||
WorkerRestoreState::ReconciliationRequired,
|
|
||||||
"worker_restore_reconciliation_required",
|
|
||||||
"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)
|
||||||
|
|||||||
@@ -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,12 +2162,15 @@ 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
|
||||||
WorkerExecutionResult::rejected(
|
.working_directory_materializer
|
||||||
WorkerExecutionOperation::Restore,
|
.as_ref()
|
||||||
"Persisted Worker Workdir binding cannot be restored by this Runtime",
|
.ok_or_else(|| {
|
||||||
)
|
WorkerExecutionResult::rejected(
|
||||||
})?;
|
WorkerExecutionOperation::Restore,
|
||||||
|
"Persisted Worker Workdir binding cannot be restored by this Runtime",
|
||||||
|
)
|
||||||
|
})?;
|
||||||
let current = materializer
|
let current = materializer
|
||||||
.working_directory_status(&previous.summary.working_directory_id)
|
.working_directory_status(&previous.summary.working_directory_id)
|
||||||
.map_err(|message| {
|
.map_err(|message| {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user