[pbs-devel] [PATCH proxmox-backup 4/6] move worker_task.rs into proxmox-rest-server crate
Dietmar Maurer
dietmar at proxmox.com
Thu Sep 23 12:13:27 CEST 2021
Also moved pbs-datastore/src/task.rs to pbs-tools, which now depends on 'log'.
---
pbs-datastore/src/chunk_store.rs | 5 +-
pbs-datastore/src/lib.rs | 1 -
pbs-tools/Cargo.toml | 1 +
pbs-tools/src/lib.rs | 1 +
{pbs-datastore => pbs-tools}/src/task.rs | 0
proxmox-rest-server/Cargo.toml | 1 +
proxmox-rest-server/src/lib.rs | 40 ++++++++++++++++
.../src}/worker_task.rs | 40 ++++------------
src/acme/plugin.rs | 2 +-
src/api2/admin/datastore.rs | 4 +-
src/api2/backup/environment.rs | 4 +-
src/api2/backup/mod.rs | 3 +-
src/api2/config/acme.rs | 2 +-
src/api2/config/datastore.rs | 5 +-
src/api2/node/apt.rs | 2 +-
src/api2/node/certificates.rs | 2 +-
src/api2/node/disks/directory.rs | 2 +-
src/api2/node/disks/mod.rs | 2 +-
src/api2/node/disks/zfs.rs | 2 +-
src/api2/node/mod.rs | 2 +-
src/api2/node/network.rs | 2 +-
src/api2/node/services.rs | 2 +-
src/api2/node/tasks.rs | 32 ++++++++++---
src/api2/pull.rs | 3 +-
src/api2/reader/environment.rs | 2 +-
src/api2/reader/mod.rs | 2 +-
src/api2/tape/backup.rs | 6 +--
src/api2/tape/drive.rs | 4 +-
src/api2/tape/restore.rs | 10 ++--
src/backup/datastore.rs | 3 +-
src/backup/verify.rs | 4 +-
src/bin/proxmox-backup-api.rs | 17 +++----
src/bin/proxmox-backup-manager.rs | 3 +-
src/bin/proxmox-backup-proxy.rs | 24 +++++-----
src/bin/proxmox-daily-update.rs | 2 +-
src/bin/proxmox_backup_debug/api.rs | 4 +-
src/server/gc_job.rs | 2 +-
src/server/h2service.rs | 4 +-
src/server/jobstate.rs | 6 +--
src/server/mod.rs | 48 ++-----------------
src/server/prune_job.rs | 6 +--
src/server/pull.rs | 5 +-
src/server/verify_job.rs | 4 +-
src/tape/drive/mod.rs | 9 ++--
src/tape/pool_writer/mod.rs | 4 +-
45 files changed, 159 insertions(+), 170 deletions(-)
rename {pbs-datastore => pbs-tools}/src/task.rs (100%)
rename {src/server => proxmox-rest-server/src}/worker_task.rs (95%)
diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index 361cc9a2..5c50e4fc 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -9,10 +9,9 @@ use proxmox::tools::fs::{CreateOptions, create_path, create_dir};
use pbs_api_types::GarbageCollectionStatus;
use pbs_tools::process_locker::{self, ProcessLocker};
+use pbs_tools::{task_log, task::TaskState};
use crate::DataBlob;
-use crate::task_log;
-use crate::task::TaskState;
/// File system based chunk store
pub struct ChunkStore {
@@ -306,7 +305,7 @@ impl ChunkStore {
for (entry, percentage, bad) in self.get_chunk_iterator()? {
if last_percentage != percentage {
last_percentage = percentage;
- crate::task_log!(
+ task_log!(
worker,
"processed {}% ({} chunks)",
percentage,
diff --git a/pbs-datastore/src/lib.rs b/pbs-datastore/src/lib.rs
index cfe39921..5a09666b 100644
--- a/pbs-datastore/src/lib.rs
+++ b/pbs-datastore/src/lib.rs
@@ -179,7 +179,6 @@ pub mod paperkey;
pub mod prune;
pub mod read_chunk;
pub mod store_progress;
-pub mod task;
pub mod dynamic_index;
pub mod fixed_index;
diff --git a/pbs-tools/Cargo.toml b/pbs-tools/Cargo.toml
index f20a315e..d37ef865 100644
--- a/pbs-tools/Cargo.toml
+++ b/pbs-tools/Cargo.toml
@@ -17,6 +17,7 @@ foreign-types = "0.3"
futures = "0.3"
lazy_static = "1.4"
libc = "0.2"
+log = "0.4"
nix = "0.19.1"
nom = "5.1"
openssl = "0.10"
diff --git a/pbs-tools/src/lib.rs b/pbs-tools/src/lib.rs
index 000591c3..6c2f0ff5 100644
--- a/pbs-tools/src/lib.rs
+++ b/pbs-tools/src/lib.rs
@@ -24,6 +24,7 @@ pub mod str;
pub mod stream;
pub mod sync;
pub mod sys;
+pub mod task;
pub mod ticket;
pub mod tokio;
pub mod xattr;
diff --git a/pbs-datastore/src/task.rs b/pbs-tools/src/task.rs
similarity index 100%
rename from pbs-datastore/src/task.rs
rename to pbs-tools/src/task.rs
diff --git a/proxmox-rest-server/Cargo.toml b/proxmox-rest-server/Cargo.toml
index b02c20db..afaf40e1 100644
--- a/proxmox-rest-server/Cargo.toml
+++ b/proxmox-rest-server/Cargo.toml
@@ -15,6 +15,7 @@ lazy_static = "1.4"
libc = "0.2"
log = "0.4"
nix = "0.19.1"
+once_cell = "1.3.1"
percent-encoding = "2.1"
regex = "1.2"
serde = { version = "1.0", features = [] }
diff --git a/proxmox-rest-server/src/lib.rs b/proxmox-rest-server/src/lib.rs
index 2f29f9cd..9acdb3fd 100644
--- a/proxmox-rest-server/src/lib.rs
+++ b/proxmox-rest-server/src/lib.rs
@@ -1,9 +1,12 @@
use std::os::unix::io::RawFd;
use anyhow::{bail, format_err, Error};
+use nix::unistd::Pid;
use proxmox::tools::fd::Fd;
+use proxmox::sys::linux::procfs::PidStat;
use proxmox::api::UserInformation;
+use proxmox::tools::fs::CreateOptions;
mod compression;
pub use compression::*;
@@ -29,6 +32,9 @@ pub use api_config::ApiConfig;
mod rest;
pub use rest::{RestServer, handle_api_request};
+mod worker_task;
+pub use worker_task::*;
+
pub enum AuthError {
Generic(Error),
NoData,
@@ -48,6 +54,40 @@ pub trait ApiAuth {
) -> Result<(String, Box<dyn UserInformation + Sync + Send>), AuthError>;
}
+lazy_static::lazy_static!{
+ static ref PID: i32 = unsafe { libc::getpid() };
+ static ref PSTART: u64 = PidStat::read_from_pid(Pid::from_raw(*PID)).unwrap().starttime;
+}
+
+pub fn pid() -> i32 {
+ *PID
+}
+
+pub fn pstart() -> u64 {
+ *PSTART
+}
+
+pub fn write_pid(pid_fn: &str) -> Result<(), Error> {
+ let pid_str = format!("{}\n", *PID);
+ proxmox::tools::fs::replace_file(pid_fn, pid_str.as_bytes(), CreateOptions::new())
+}
+
+pub fn read_pid(pid_fn: &str) -> Result<i32, Error> {
+ let pid = proxmox::tools::fs::file_get_contents(pid_fn)?;
+ let pid = std::str::from_utf8(&pid)?.trim();
+ pid.parse().map_err(|err| format_err!("could not parse pid - {}", err))
+}
+
+pub fn ctrl_sock_from_pid(pid: i32) -> String {
+ // Note: The control socket always uses @/run/proxmox-backup/ as prefix
+ // for historc reason.
+ format!("\0{}/control-{}.sock", "/run/proxmox-backup", pid)
+}
+
+pub fn our_ctrl_sock() -> String {
+ ctrl_sock_from_pid(*PID)
+}
+
static mut SHUTDOWN_REQUESTED: bool = false;
pub fn request_shutdown() {
diff --git a/src/server/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
similarity index 95%
rename from src/server/worker_task.rs
rename to proxmox-rest-server/src/worker_task.rs
index 94ffbeb0..b6ed6862 100644
--- a/src/server/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -21,7 +21,8 @@ use proxmox::tools::fs::{create_path, replace_file, atomic_open_or_create_file,
use proxmox::api::upid::UPID;
use pbs_tools::logrotate::{LogRotate, LogRotateFiles};
-use proxmox_rest_server::{CommandoSocket, FileLogger, FileLogOptions};
+
+use crate::{CommandoSocket, FileLogger, FileLogOptions};
struct TaskListLockGuard(File);
@@ -280,7 +281,7 @@ lazy_static! {
/// checks if the task UPID refers to a worker from this process
fn is_local_worker(upid: &UPID) -> bool {
- upid.pid == crate::server::pid() && upid.pstart == crate::server::pstart()
+ upid.pid == crate::pid() && upid.pstart == crate::pstart()
}
/// Test if the task is still running
@@ -293,14 +294,14 @@ pub async fn worker_is_active(upid: &UPID) -> Result<bool, Error> {
return Ok(false);
}
- let sock = crate::server::ctrl_sock_from_pid(upid.pid);
+ let sock = crate::ctrl_sock_from_pid(upid.pid);
let cmd = json!({
"command": "worker-task-status",
"args": {
"upid": upid.to_string(),
},
});
- let status = proxmox_rest_server::send_command(sock, &cmd).await?;
+ let status = crate::send_command(sock, &cmd).await?;
if let Some(active) = status.as_bool() {
Ok(active)
@@ -366,14 +367,14 @@ pub fn abort_worker_async(upid: UPID) {
pub async fn abort_worker(upid: UPID) -> Result<(), Error> {
- let sock = crate::server::ctrl_sock_from_pid(upid.pid);
+ let sock = crate::ctrl_sock_from_pid(upid.pid);
let cmd = json!({
"command": "worker-task-abort",
"args": {
"upid": upid.to_string(),
},
});
- proxmox_rest_server::send_command(sock, &cmd).map_ok(|_| ()).await
+ crate::send_command(sock, &cmd).map_ok(|_| ()).await
}
fn parse_worker_status_line(line: &str) -> Result<(String, UPID, Option<TaskState>), Error> {
@@ -476,27 +477,6 @@ pub struct TaskListInfo {
pub state: Option<TaskState>, // endtime, status
}
-impl Into<pbs_api_types::TaskListItem> for TaskListInfo {
- fn into(self) -> pbs_api_types::TaskListItem {
- let (endtime, status) = self
- .state
- .map_or_else(|| (None, None), |a| (Some(a.endtime()), Some(a.to_string())));
-
- pbs_api_types::TaskListItem {
- upid: self.upid_str,
- node: "localhost".to_string(),
- pid: self.upid.pid as i64,
- pstart: self.upid.pstart,
- starttime: self.upid.starttime,
- worker_type: self.upid.worker_type,
- worker_id: self.upid.worker_id,
- user: self.upid.auth_id,
- endtime,
- status,
- }
- }
-}
-
fn render_task_line(info: &TaskListInfo) -> String {
let mut raw = String::new();
if let Some(status) = &info.state {
@@ -715,7 +695,7 @@ impl WorkerTask {
{
let mut hash = WORKER_TASK_LIST.lock().unwrap();
hash.insert(task_id, worker.clone());
- proxmox_rest_server::set_worker_count(hash.len());
+ crate::set_worker_count(hash.len());
}
setup.update_active_workers(Some(&upid))?;
@@ -802,7 +782,7 @@ impl WorkerTask {
WORKER_TASK_LIST.lock().unwrap().remove(&self.upid.task_id);
let _ = self.setup.update_active_workers(None);
- proxmox_rest_server::set_worker_count(WORKER_TASK_LIST.lock().unwrap().len());
+ crate::set_worker_count(WORKER_TASK_LIST.lock().unwrap().len());
}
/// Log a message.
@@ -879,7 +859,7 @@ impl WorkerTask {
}
}
-impl pbs_datastore::task::TaskState for WorkerTask {
+impl pbs_tools::task::TaskState for WorkerTask {
fn check_abort(&self) -> Result<(), Error> {
self.fail_on_abort()
}
diff --git a/src/acme/plugin.rs b/src/acme/plugin.rs
index 7593aaa4..cb7de082 100644
--- a/src/acme/plugin.rs
+++ b/src/acme/plugin.rs
@@ -13,7 +13,7 @@ use proxmox_acme_rs::{Authorization, Challenge};
use crate::acme::AcmeClient;
use crate::api2::types::AcmeDomain;
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
use crate::config::acme::plugin::{DnsPlugin, PluginData};
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index fbb93f35..154a2e84 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -54,7 +54,7 @@ use pbs_tools::blocking::WrappedReaderStream;
use pbs_tools::stream::{AsyncReaderStream, AsyncChannelWriter};
use pbs_tools::json::{required_integer_param, required_string_param};
use pbs_config::CachedUserInfo;
-use proxmox_rest_server::formatter;
+use proxmox_rest_server::{WorkerTask, formatter};
use crate::api2::node::rrd::create_value_from_rrd;
use crate::backup::{
@@ -62,7 +62,7 @@ use crate::backup::{
DataStore, LocalChunkReader,
};
-use crate::server::{jobstate::Job, WorkerTask};
+use crate::server::jobstate::Job;
const GROUP_NOTES_FILE_NAME: &str = "notes";
diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs
index 306f91ee..8112737e 100644
--- a/src/api2/backup/environment.rs
+++ b/src/api2/backup/environment.rs
@@ -15,10 +15,10 @@ use pbs_datastore::backup_info::{BackupDir, BackupInfo};
use pbs_datastore::dynamic_index::DynamicIndexWriter;
use pbs_datastore::fixed_index::FixedIndexWriter;
use pbs_api_types::Authid;
-use proxmox_rest_server::formatter::*;
+use proxmox_rest_server::{WorkerTask, formatter::*};
use crate::backup::{verify_backup_dir_with_lock, DataStore};
-use crate::server::WorkerTask;
+
use hyper::{Body, Response};
#[derive(Copy, Clone, Serialize)]
diff --git a/src/api2/backup/mod.rs b/src/api2/backup/mod.rs
index c14f19a4..4333be17 100644
--- a/src/api2/backup/mod.rs
+++ b/src/api2/backup/mod.rs
@@ -23,8 +23,9 @@ use pbs_datastore::PROXMOX_BACKUP_PROTOCOL_ID_V1;
use pbs_datastore::backup_info::{BackupDir, BackupGroup, BackupInfo};
use pbs_datastore::index::IndexFile;
use pbs_datastore::manifest::{archive_type, ArchiveType};
+use proxmox_rest_server::WorkerTask;
-use crate::server::{WorkerTask, H2Service};
+use crate::server::H2Service;
use crate::backup::DataStore;
use pbs_config::CachedUserInfo;
diff --git a/src/api2/config/acme.rs b/src/api2/config/acme.rs
index 564cafae..8593acac 100644
--- a/src/api2/config/acme.rs
+++ b/src/api2/config/acme.rs
@@ -24,7 +24,7 @@ use crate::api2::types::{AcmeAccountName, AcmeChallengeSchema, KnownAcmeDirector
use crate::config::acme::plugin::{
self, DnsPlugin, DnsPluginCore, DnsPluginCoreUpdater, PLUGIN_ID_SCHEMA,
};
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
pub(crate) const ROUTER: Router = Router::new()
.get(&list_subdirs_api_method!(SUBDIRS))
diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index 0e6529f8..0f9234ca 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -9,7 +9,6 @@ use proxmox::api::section_config::SectionConfigData;
use proxmox::api::schema::{ApiType, parse_property_string};
use pbs_datastore::chunk_store::ChunkStore;
-use pbs_datastore::task::TaskState;
use pbs_config::BackupLockGuard;
use pbs_api_types::{
Authid, DatastoreNotify,
@@ -17,6 +16,7 @@ use pbs_api_types::{
PRIV_DATASTORE_ALLOCATE, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_MODIFY,
DataStoreConfig, DataStoreConfigUpdater,
};
+use pbs_tools::task::TaskState;
use crate::api2::config::sync::delete_sync_job;
use crate::api2::config::verify::delete_verification_job;
@@ -26,8 +26,9 @@ use crate::api2::admin::{
verify::list_verification_jobs,
};
use pbs_config::CachedUserInfo;
+use proxmox_rest_server::WorkerTask;
-use crate::server::{jobstate, WorkerTask};
+use crate::server::jobstate;
#[api(
input: {
diff --git a/src/api2/node/apt.rs b/src/api2/node/apt.rs
index f02920c0..4fd81592 100644
--- a/src/api2/node/apt.rs
+++ b/src/api2/node/apt.rs
@@ -19,7 +19,7 @@ use pbs_api_types::{
};
use crate::config::node;
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
use crate::tools::{
apt,
pbs_simple_http,
diff --git a/src/api2/node/certificates.rs b/src/api2/node/certificates.rs
index 7b31861e..80733fe9 100644
--- a/src/api2/node/certificates.rs
+++ b/src/api2/node/certificates.rs
@@ -18,7 +18,7 @@ use pbs_tools::cert;
use crate::acme::AcmeClient;
use crate::api2::types::AcmeDomain;
use crate::config::node::NodeConfig;
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
pub const ROUTER: Router = Router::new()
.get(&list_subdirs_api_method!(SUBDIRS))
diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
index 49127586..91369643 100644
--- a/src/api2/node/disks/directory.rs
+++ b/src/api2/node/disks/directory.rs
@@ -17,7 +17,7 @@ use crate::tools::disks::{
};
use crate::tools::systemd::{self, types::*};
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
const BASE_MOUNT_DIR: &str = "/mnt/datastore/";
diff --git a/src/api2/node/disks/mod.rs b/src/api2/node/disks/mod.rs
index b4001a54..f08c340b 100644
--- a/src/api2/node/disks/mod.rs
+++ b/src/api2/node/disks/mod.rs
@@ -15,7 +15,7 @@ use crate::tools::disks::{
DiskUsageInfo, DiskUsageType, DiskManage, SmartData,
get_disks, get_smart_data, get_disk_usage_info, inititialize_gpt_disk,
};
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
pub mod directory;
pub mod zfs;
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index 8a6cb708..efea9b70 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -19,7 +19,7 @@ use crate::tools::disks::{
DiskUsageType,
};
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
#[api(
diff --git a/src/api2/node/mod.rs b/src/api2/node/mod.rs
index 8e357311..7a5bb64e 100644
--- a/src/api2/node/mod.rs
+++ b/src/api2/node/mod.rs
@@ -24,7 +24,7 @@ use pbs_api_types::{Authid, NODE_SCHEMA, PRIV_SYS_CONSOLE};
use pbs_tools::auth::private_auth_key;
use pbs_tools::ticket::{self, Empty, Ticket};
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
use crate::tools;
pub mod apt;
diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs
index 0fde9f2a..d496b5f8 100644
--- a/src/api2/node/network.rs
+++ b/src/api2/node/network.rs
@@ -13,7 +13,7 @@ use pbs_api_types::{
};
use pbs_config::network::{self, NetworkConfig};
-use crate::server::{WorkerTask};
+use proxmox_rest_server::WorkerTask;
fn split_interface_list(list: &str) -> Result<Vec<String>, Error> {
let value = parse_property_string(&list, &NETWORK_INTERFACE_ARRAY_SCHEMA)?;
diff --git a/src/api2/node/services.rs b/src/api2/node/services.rs
index 6c757f43..8df0fb24 100644
--- a/src/api2/node/services.rs
+++ b/src/api2/node/services.rs
@@ -9,7 +9,7 @@ use proxmox::api::router::SubdirMap;
use pbs_api_types::{Authid, NODE_SCHEMA, SERVICE_ID_SCHEMA, PRIV_SYS_AUDIT, PRIV_SYS_MODIFY};
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
static SERVICE_NAME_LIST: [&str; 7] = [
"proxmox-backup",
diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs
index df4673a1..0d2b456c 100644
--- a/src/api2/node/tasks.rs
+++ b/src/api2/node/tasks.rs
@@ -16,7 +16,8 @@ use pbs_api_types::{
};
use crate::api2::pull::check_pull_privs;
-use crate::server::{self, upid_log_path, upid_read_status, TaskState, TaskListInfoIterator};
+
+use proxmox_rest_server::{upid_log_path, upid_read_status, TaskState, TaskListInfoIterator};
use pbs_config::CachedUserInfo;
// matches respective job execution privileges
@@ -125,6 +126,25 @@ pub fn tasktype(state: &TaskState) -> TaskStateType {
}
}
+fn into_task_list_item(info: proxmox_rest_server::TaskListInfo) -> pbs_api_types::TaskListItem {
+ let (endtime, status) = info
+ .state
+ .map_or_else(|| (None, None), |a| (Some(a.endtime()), Some(a.to_string())));
+
+ pbs_api_types::TaskListItem {
+ upid: info.upid_str,
+ node: "localhost".to_string(),
+ pid: info.upid.pid as i64,
+ pstart: info.upid.pstart,
+ starttime: info.upid.starttime,
+ worker_type: info.upid.worker_type,
+ worker_id: info.upid.worker_id,
+ user: info.upid.auth_id,
+ endtime,
+ status,
+ }
+}
+
#[api(
input: {
properties: {
@@ -217,7 +237,7 @@ async fn get_task_status(
result["tokenid"] = Value::from(task_auth_id.tokenname().unwrap().as_str());
}
- if crate::server::worker_is_active(&upid).await? {
+ if proxmox_rest_server::worker_is_active(&upid).await? {
result["status"] = Value::from("running");
} else {
let exitstatus = upid_read_status(&upid).unwrap_or(TaskState::Unknown { endtime: 0 });
@@ -314,7 +334,7 @@ async fn read_task_log(
rpcenv["total"] = Value::from(count);
if test_status {
- let active = crate::server::worker_is_active(&upid).await?;
+ let active = proxmox_rest_server::worker_is_active(&upid).await?;
rpcenv["active"] = Value::from(active);
}
@@ -354,7 +374,7 @@ fn stop_task(
user_info.check_privs(&auth_id, &["system", "tasks"], PRIV_SYS_MODIFY, false)?;
}
- server::abort_worker_async(upid);
+ proxmox_rest_server::abort_worker_async(upid);
Ok(Value::Null)
}
@@ -502,7 +522,7 @@ pub fn list_tasks(
match (&info.state, &statusfilter) {
(Some(_), _) if running => continue,
- (Some(crate::server::TaskState::OK { .. }), _) if errors => continue,
+ (Some(TaskState::OK { .. }), _) if errors => continue,
(Some(state), Some(filters)) => {
if !filters.contains(&tasktype(state)) {
continue;
@@ -517,7 +537,7 @@ pub fn list_tasks(
continue;
}
- result.push(info.into());
+ result.push(into_task_list_item(info));
if result.len() >= limit {
break;
diff --git a/src/api2/pull.rs b/src/api2/pull.rs
index e631920f..0240098d 100644
--- a/src/api2/pull.rs
+++ b/src/api2/pull.rs
@@ -13,8 +13,9 @@ use pbs_api_types::{
DATASTORE_SCHEMA, REMOTE_ID_SCHEMA, REMOVE_VANISHED_BACKUPS_SCHEMA,
PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_PRUNE, PRIV_REMOTE_READ,
};
+use proxmox_rest_server::WorkerTask;
-use crate::server::{WorkerTask, jobstate::Job, pull::pull_store};
+use crate::server::{jobstate::Job, pull::pull_store};
use crate::backup::DataStore;
use pbs_config::CachedUserInfo;
diff --git a/src/api2/reader/environment.rs b/src/api2/reader/environment.rs
index f7d79072..c85ec069 100644
--- a/src/api2/reader/environment.rs
+++ b/src/api2/reader/environment.rs
@@ -10,7 +10,7 @@ use pbs_api_types::Authid;
use proxmox_rest_server::formatter::*;
use crate::backup::DataStore;
-use crate::server::WorkerTask;
+use proxmox_rest_server::WorkerTask;
//use proxmox::tools;
diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs
index fada952c..c663e9ae 100644
--- a/src/api2/reader/mod.rs
+++ b/src/api2/reader/mod.rs
@@ -39,12 +39,12 @@ use pbs_datastore::backup_info::BackupDir;
use pbs_datastore::index::IndexFile;
use pbs_datastore::manifest::{archive_type, ArchiveType};
use pbs_config::CachedUserInfo;
+use proxmox_rest_server::WorkerTask;
use crate::{
api2::helpers,
backup::DataStore,
server::{
- WorkerTask,
H2Service,
},
};
diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs
index fadbfa3d..5effa99d 100644
--- a/src/api2/tape/backup.rs
+++ b/src/api2/tape/backup.rs
@@ -20,10 +20,11 @@ use pbs_api_types::{
UPID_SCHEMA, JOB_ID_SCHEMA, PRIV_DATASTORE_READ, PRIV_TAPE_AUDIT, PRIV_TAPE_WRITE,
};
-use pbs_datastore::{task_log, task_warn, StoreProgress};
+use pbs_datastore::StoreProgress;
use pbs_datastore::backup_info::{BackupDir, BackupInfo};
-use pbs_datastore::task::TaskState;
+use pbs_tools::{task_log, task_warn, task::TaskState};
use pbs_config::CachedUserInfo;
+use proxmox_rest_server::WorkerTask;
use crate::{
server::{
@@ -36,7 +37,6 @@ use crate::{
},
},
backup::{DataStore, SnapshotReader},
- server::WorkerTask,
tape::{
TAPE_STATUS_DIR,
Inventory,
diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs
index 10aa6842..8227f659 100644
--- a/src/api2/tape/drive.rs
+++ b/src/api2/tape/drive.rs
@@ -28,7 +28,6 @@ use pbs_api_types::{
LtoDriveAndMediaStatus, Lp17VolumeStatistics,
};
-use pbs_datastore::task_log;
use pbs_api_types::{PRIV_TAPE_AUDIT, PRIV_TAPE_READ, PRIV_TAPE_WRITE};
use pbs_config::CachedUserInfo;
use pbs_tape::{
@@ -36,13 +35,14 @@ use pbs_tape::{
sg_tape::tape_alert_flags_critical,
linux_list_drives::{lto_tape_device_list, lookup_device_identification, open_lto_tape_device},
};
+use pbs_tools::task_log;
+use proxmox_rest_server::WorkerTask;
use crate::{
api2::tape::restore::{
fast_catalog_restore,
restore_media,
},
- server::WorkerTask,
tape::{
TAPE_STATUS_DIR,
Inventory,
diff --git a/src/api2/tape/restore.rs b/src/api2/tape/restore.rs
index 7739d1a4..045d8d6c 100644
--- a/src/api2/tape/restore.rs
+++ b/src/api2/tape/restore.rs
@@ -34,26 +34,24 @@ use pbs_api_types::{
UPID_SCHEMA, TAPE_RESTORE_SNAPSHOT_SCHEMA,
PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, PRIV_TAPE_READ,
};
-use pbs_datastore::{task_log, task_warn, DataBlob};
+use pbs_datastore::DataBlob;
use pbs_datastore::backup_info::BackupDir;
use pbs_datastore::dynamic_index::DynamicIndexReader;
use pbs_datastore::fixed_index::FixedIndexReader;
use pbs_datastore::index::IndexFile;
use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, MANIFEST_BLOB_NAME};
-use pbs_datastore::task::TaskState;
use pbs_config::CachedUserInfo;
use pbs_tape::{
TapeRead, BlockReadError, MediaContentHeader,
PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0,
};
+use pbs_tools::{task_log, task_warn, task::TaskState};
+use proxmox_rest_server::WorkerTask;
use crate::{
tools::ParallelHandler,
backup::DataStore,
- server::{
- lookup_user_email,
- WorkerTask,
- },
+ server::lookup_user_email,
tape::{
TAPE_STATUS_DIR,
MediaId,
diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs
index df8d46b6..fcef2d39 100644
--- a/src/backup/datastore.rs
+++ b/src/backup/datastore.rs
@@ -12,7 +12,6 @@ use lazy_static::lazy_static;
use proxmox::tools::fs::{replace_file, file_read_optional_string, CreateOptions};
use pbs_api_types::{UPID, DataStoreConfig, Authid, GarbageCollectionStatus};
-use pbs_datastore::{task_log, task_warn};
use pbs_datastore::DataBlob;
use pbs_datastore::backup_info::{BackupGroup, BackupDir};
use pbs_datastore::chunk_store::ChunkStore;
@@ -24,10 +23,10 @@ use pbs_datastore::manifest::{
ArchiveType, BackupManifest,
archive_type,
};
-use pbs_datastore::task::TaskState;
use pbs_tools::format::HumanByte;
use pbs_tools::fs::{lock_dir_noblock, DirLockGuard};
use pbs_tools::process_locker::ProcessLockSharedGuard;
+use pbs_tools::{task_log, task_warn, task::TaskState};
use pbs_config::{open_backup_lockfile, BackupLockGuard};
use proxmox_rest_server::fail_on_shutdown;
diff --git a/src/backup/verify.rs b/src/backup/verify.rs
index b8d2b2f3..051d6918 100644
--- a/src/backup/verify.rs
+++ b/src/backup/verify.rs
@@ -7,12 +7,12 @@ use std::time::Instant;
use anyhow::{bail, format_err, Error};
use pbs_api_types::{Authid, CryptMode, VerifyState, UPID, SnapshotVerifyState};
-use pbs_datastore::{task_log, DataBlob, StoreProgress};
+use pbs_datastore::{DataBlob, StoreProgress};
use pbs_datastore::backup_info::{BackupGroup, BackupDir, BackupInfo};
use pbs_datastore::index::IndexFile;
use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, FileInfo};
-use pbs_datastore::task::TaskState;
use pbs_tools::fs::lock_dir_noblock_shared;
+use pbs_tools::{task_log, task::TaskState};
use crate::{
backup::DataStore,
diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs
index 9901b85d..86650de6 100644
--- a/src/bin/proxmox-backup-api.rs
+++ b/src/bin/proxmox-backup-api.rs
@@ -10,14 +10,9 @@ use proxmox::api::RpcEnvironmentType;
use proxmox::tools::fs::CreateOptions;
use pbs_tools::auth::private_auth_key;
-use proxmox_rest_server::{ApiConfig, RestServer};
-
-use proxmox_backup::server::{
- self,
- auth::default_api_auth,
-};
-use proxmox_rest_server::daemon;
+use proxmox_rest_server::{daemon, ApiConfig, RestServer};
+use proxmox_backup::server::auth::default_api_auth;
use proxmox_backup::auth_helpers::*;
use proxmox_backup::config;
@@ -86,7 +81,7 @@ async fn run() -> Result<(), Error> {
)?;
let backup_user = pbs_config::backup_user()?;
- let mut commando_sock = proxmox_rest_server::CommandoSocket::new(crate::server::our_ctrl_sock(), backup_user.gid);
+ let mut commando_sock = proxmox_rest_server::CommandoSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid);
let dir_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid);
let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid);
@@ -107,7 +102,7 @@ async fn run() -> Result<(), Error> {
let rest_server = RestServer::new(config);
- proxmox_backup::server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?;
+ proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?;
// http server future:
let server = daemon::create_daemon(
@@ -130,11 +125,11 @@ async fn run() -> Result<(), Error> {
"proxmox-backup.service",
);
- server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
+ proxmox_rest_server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
let init_result: Result<(), Error> = try_block!({
- server::register_task_control_commands(&mut commando_sock)?;
+ proxmox_rest_server::register_task_control_commands(&mut commando_sock)?;
commando_sock.spawn()?;
proxmox_rest_server::server_state_init()?;
Ok(())
diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs
index 689f44db..b9e4e2ff 100644
--- a/src/bin/proxmox-backup-manager.rs
+++ b/src/bin/proxmox-backup-manager.rs
@@ -14,9 +14,10 @@ use pbs_api_types::{
IGNORE_VERIFIED_BACKUPS_SCHEMA, VERIFICATION_OUTDATED_AFTER_SCHEMA,
};
+use proxmox_rest_server::wait_for_local_worker;
+
use proxmox_backup::config;
use proxmox_backup::api2;
-use proxmox_backup::server::wait_for_local_worker;
mod proxmox_backup_manager;
use proxmox_backup_manager::*;
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 5d8ed189..ec4da15b 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -19,18 +19,16 @@ use proxmox::api::RpcEnvironmentType;
use proxmox::sys::linux::socket::set_tcp_keepalive;
use proxmox::tools::fs::CreateOptions;
-use proxmox_rest_server::{ApiConfig, RestServer};
+use proxmox_rest_server::{rotate_task_log_archive, ApiConfig, RestServer, WorkerTask};
use proxmox_backup::{
backup::DataStore,
server::{
auth::default_api_auth,
- WorkerTask,
jobstate::{
self,
Job,
},
- rotate_task_log_archive,
},
};
@@ -188,7 +186,7 @@ async fn run() -> Result<(), Error> {
config.register_template("console", "/usr/share/pve-xtermjs/index.html.hbs")?;
let backup_user = pbs_config::backup_user()?;
- let mut commando_sock = proxmox_rest_server::CommandoSocket::new(crate::server::our_ctrl_sock(), backup_user.gid);
+ let mut commando_sock = proxmox_rest_server::CommandoSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid);
let dir_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid);
let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid);
@@ -208,7 +206,7 @@ async fn run() -> Result<(), Error> {
)?;
let rest_server = RestServer::new(config);
- proxmox_backup::server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?;
+ proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?;
//openssl req -x509 -newkey rsa:4096 -keyout /etc/proxmox-backup/proxy.key -out /etc/proxmox-backup/proxy.pem -nodes
@@ -266,11 +264,11 @@ async fn run() -> Result<(), Error> {
"proxmox-backup-proxy.service",
);
- server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
+ proxmox_rest_server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
let init_result: Result<(), Error> = try_block!({
- server::register_task_control_commands(&mut commando_sock)?;
+ proxmox_rest_server::register_task_control_commands(&mut commando_sock)?;
commando_sock.spawn()?;
proxmox_rest_server::server_state_init()?;
Ok(())
@@ -806,11 +804,11 @@ async fn schedule_task_log_rotate() {
async fn command_reopen_access_logfiles() -> Result<(), Error> {
// only care about the most recent daemon instance for each, proxy & api, as other older ones
// should not respond to new requests anyway, but only finish their current one and then exit.
- let sock = crate::server::our_ctrl_sock();
+ let sock = proxmox_rest_server::our_ctrl_sock();
let f1 = proxmox_rest_server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
- let pid = crate::server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
- let sock = crate::server::ctrl_sock_from_pid(pid);
+ let pid = proxmox_rest_server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
+ let sock = proxmox_rest_server::ctrl_sock_from_pid(pid);
let f2 = proxmox_rest_server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
match futures::join!(f1, f2) {
@@ -824,11 +822,11 @@ async fn command_reopen_access_logfiles() -> Result<(), Error> {
async fn command_reopen_auth_logfiles() -> Result<(), Error> {
// only care about the most recent daemon instance for each, proxy & api, as other older ones
// should not respond to new requests anyway, but only finish their current one and then exit.
- let sock = crate::server::our_ctrl_sock();
+ let sock = proxmox_rest_server::our_ctrl_sock();
let f1 = proxmox_rest_server::send_command(sock, "{\"command\":\"api-auth-log-reopen\"}\n");
- let pid = crate::server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
- let sock = crate::server::ctrl_sock_from_pid(pid);
+ let pid = proxmox_rest_server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
+ let sock = proxmox_rest_server::ctrl_sock_from_pid(pid);
let f2 = proxmox_rest_server::send_command(sock, "{\"command\":\"api-auth-log-reopen\"}\n");
match futures::join!(f1, f2) {
diff --git a/src/bin/proxmox-daily-update.rs b/src/bin/proxmox-daily-update.rs
index c1580b97..09a768b1 100644
--- a/src/bin/proxmox-daily-update.rs
+++ b/src/bin/proxmox-daily-update.rs
@@ -11,7 +11,7 @@ async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> {
let sleep_duration = core::time::Duration::new(0, 100_000_000);
loop {
- if !proxmox_backup::server::worker_is_active_local(&upid) {
+ if !proxmox_rest_server::worker_is_active_local(&upid) {
break;
}
tokio::time::sleep(sleep_duration).await;
diff --git a/src/bin/proxmox_backup_debug/api.rs b/src/bin/proxmox_backup_debug/api.rs
index bebe9ddc..003f6677 100644
--- a/src/bin/proxmox_backup_debug/api.rs
+++ b/src/bin/proxmox_backup_debug/api.rs
@@ -235,12 +235,12 @@ async fn handle_worker(upid_str: &str) -> Result<(), Error> {
let abort_future = async move {
while signal_stream.recv().await.is_some() {
println!("got shutdown request (SIGINT)");
- proxmox_backup::server::abort_local_worker(upid.clone());
+ proxmox_rest_server::abort_local_worker(upid.clone());
}
Ok::<_, Error>(())
};
- let result_future = proxmox_backup::server::wait_for_local_worker(upid_str);
+ let result_future = proxmox_rest_server::wait_for_local_worker(upid_str);
futures::select! {
result = result_future.fuse() => result?,
diff --git a/src/server/gc_job.rs b/src/server/gc_job.rs
index 317f4a36..608b5831 100644
--- a/src/server/gc_job.rs
+++ b/src/server/gc_job.rs
@@ -2,9 +2,9 @@ use std::sync::Arc;
use anyhow::Error;
use pbs_api_types::Authid;
+use proxmox_rest_server::WorkerTask;
use crate::{
- server::WorkerTask,
server::jobstate::Job,
backup::DataStore,
};
diff --git a/src/server/h2service.rs b/src/server/h2service.rs
index 41d628be..0b51a710 100644
--- a/src/server/h2service.rs
+++ b/src/server/h2service.rs
@@ -11,11 +11,9 @@ use hyper::{Body, Request, Response, StatusCode};
use proxmox::api::{ApiResponseFuture, HttpError, Router, RpcEnvironment};
use proxmox::http_err;
-use proxmox_rest_server::normalize_uri_path;
+use proxmox_rest_server::{normalize_uri_path, WorkerTask};
use proxmox_rest_server::formatter::*;
-use crate::server::WorkerTask;
-
/// Hyper Service implementation to handle stateful H2 connections.
///
/// We use this kind of service to handle backup protocol
diff --git a/src/server/jobstate.rs b/src/server/jobstate.rs
index 74224f33..ed71ec71 100644
--- a/src/server/jobstate.rs
+++ b/src/server/jobstate.rs
@@ -50,11 +50,7 @@ use proxmox_systemd::time::{compute_next_event, parse_calendar_event};
use pbs_config::{open_backup_lockfile, BackupLockGuard};
use pbs_api_types::{UPID, JobScheduleStatus};
-use crate::server::{
- TaskState,
- upid_read_status,
- worker_is_active_local,
-};
+use proxmox_rest_server::{upid_read_status, worker_is_active_local, TaskState};
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
diff --git a/src/server/mod.rs b/src/server/mod.rs
index 77320da6..96d57bd4 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -4,51 +4,13 @@
//! services. We want async IO, so this is built on top of
//! tokio/hyper.
-use anyhow::{format_err, Error};
-use lazy_static::lazy_static;
-use nix::unistd::Pid;
+use anyhow::Error;
use serde_json::Value;
-use proxmox::sys::linux::procfs::PidStat;
use proxmox::tools::fs::{create_path, CreateOptions};
use pbs_buildcfg;
-lazy_static! {
- static ref PID: i32 = unsafe { libc::getpid() };
- static ref PSTART: u64 = PidStat::read_from_pid(Pid::from_raw(*PID)).unwrap().starttime;
-}
-
-pub fn pid() -> i32 {
- *PID
-}
-
-pub fn pstart() -> u64 {
- *PSTART
-}
-
-pub fn write_pid(pid_fn: &str) -> Result<(), Error> {
- let pid_str = format!("{}\n", *PID);
- proxmox::tools::fs::replace_file(pid_fn, pid_str.as_bytes(), CreateOptions::new())
-}
-
-pub fn read_pid(pid_fn: &str) -> Result<i32, Error> {
- let pid = proxmox::tools::fs::file_get_contents(pid_fn)?;
- let pid = std::str::from_utf8(&pid)?.trim();
- pid.parse().map_err(|err| format_err!("could not parse pid - {}", err))
-}
-
-pub fn ctrl_sock_from_pid(pid: i32) -> String {
- format!("\0{}/control-{}.sock", pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, pid)
-}
-
-pub fn our_ctrl_sock() -> String {
- ctrl_sock_from_pid(*PID)
-}
-
-mod worker_task;
-pub use worker_task::*;
-
mod h2service;
pub use h2service::*;
@@ -76,16 +38,16 @@ pub mod auth;
pub mod pull;
pub(crate) async fn reload_proxy_certificate() -> Result<(), Error> {
- let proxy_pid = crate::server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
- let sock = crate::server::ctrl_sock_from_pid(proxy_pid);
+ let proxy_pid = proxmox_rest_server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
+ let sock = proxmox_rest_server::ctrl_sock_from_pid(proxy_pid);
let _: Value = proxmox_rest_server::send_raw_command(sock, "{\"command\":\"reload-certificate\"}\n")
.await?;
Ok(())
}
pub(crate) async fn notify_datastore_removed() -> Result<(), Error> {
- let proxy_pid = crate::server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
- let sock = crate::server::ctrl_sock_from_pid(proxy_pid);
+ let proxy_pid = proxmox_rest_server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
+ let sock = proxmox_rest_server::ctrl_sock_from_pid(proxy_pid);
let _: Value = proxmox_rest_server::send_raw_command(sock, "{\"command\":\"datastore-removed\"}\n")
.await?;
Ok(())
diff --git a/src/server/prune_job.rs b/src/server/prune_job.rs
index 8d971a1c..53740187 100644
--- a/src/server/prune_job.rs
+++ b/src/server/prune_job.rs
@@ -2,17 +2,17 @@ use std::sync::Arc;
use anyhow::Error;
-use pbs_datastore::{task_log, task_warn};
use pbs_datastore::backup_info::BackupInfo;
use pbs_datastore::prune::compute_prune_info;
use pbs_api_types::{Authid, PRIV_DATASTORE_MODIFY, PruneOptions};
use pbs_config::CachedUserInfo;
+use pbs_tools::{task_log, task_warn};
+use proxmox_rest_server::WorkerTask;
use crate::{
backup::DataStore,
server::jobstate::Job,
- server::WorkerTask,
-};
+ };
pub fn prune_datastore(
worker: Arc<WorkerTask>,
diff --git a/src/server/pull.rs b/src/server/pull.rs
index 5214a218..f913ac8a 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -13,7 +13,7 @@ use serde_json::json;
use proxmox::api::error::{HttpError, StatusCode};
use pbs_api_types::{Authid, SnapshotListItem, GroupListItem};
-use pbs_datastore::{task_log, BackupInfo, BackupDir, BackupGroup, StoreProgress};
+use pbs_datastore::{BackupInfo, BackupDir, BackupGroup, StoreProgress};
use pbs_datastore::data_blob::DataBlob;
use pbs_datastore::dynamic_index::DynamicIndexReader;
use pbs_datastore::fixed_index::FixedIndexReader;
@@ -22,11 +22,12 @@ use pbs_datastore::manifest::{
CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME, ArchiveType, BackupManifest, FileInfo, archive_type
};
use pbs_tools::sha::sha256;
+use pbs_tools::task_log;
use pbs_client::{BackupReader, BackupRepository, HttpClient, HttpClientOptions, RemoteChunkReader};
+use proxmox_rest_server::WorkerTask;
use crate::{
backup::DataStore,
- server::WorkerTask,
tools::ParallelHandler,
};
diff --git a/src/server/verify_job.rs b/src/server/verify_job.rs
index 6005b706..62fa6fa8 100644
--- a/src/server/verify_job.rs
+++ b/src/server/verify_job.rs
@@ -1,10 +1,10 @@
use anyhow::{format_err, Error};
-use pbs_datastore::task_log;
+use pbs_tools::task_log;
use pbs_api_types::{Authid, VerificationJobConfig};
+use proxmox_rest_server::WorkerTask;
use crate::{
- server::WorkerTask,
server::jobstate::Job,
backup::{
DataStore,
diff --git a/src/tape/drive/mod.rs b/src/tape/drive/mod.rs
index ef5ffdbf..e8e60d19 100644
--- a/src/tape/drive/mod.rs
+++ b/src/tape/drive/mod.rs
@@ -30,19 +30,16 @@ use proxmox::{
use pbs_api_types::{VirtualTapeDrive, LtoTapeDrive, Fingerprint};
use pbs_config::key_config::KeyConfig;
-use pbs_datastore::task::TaskState;
-use pbs_datastore::task_log;
+use pbs_tools::{task_log, task::TaskState};
use pbs_tape::{
TapeWrite, TapeRead, BlockReadError, MediaContentHeader,
sg_tape::TapeAlertFlags,
};
+use proxmox_rest_server::WorkerTask;
use crate::{
- server::{
- send_load_media_email,
- WorkerTask,
- },
+ server::send_load_media_email,
tape::{
MediaId,
drive::{
diff --git a/src/tape/pool_writer/mod.rs b/src/tape/pool_writer/mod.rs
index 8042de9e..2984173f 100644
--- a/src/tape/pool_writer/mod.rs
+++ b/src/tape/pool_writer/mod.rs
@@ -13,16 +13,16 @@ use anyhow::{bail, Error};
use proxmox::tools::Uuid;
-use pbs_datastore::task_log;
+use pbs_tools::task_log;
use pbs_config::tape_encryption_keys::load_key_configs;
use pbs_tape::{
TapeWrite,
sg_tape::tape_alert_flags_critical,
};
+use proxmox_rest_server::WorkerTask;
use crate::{
backup::{DataStore, SnapshotReader},
- server::WorkerTask,
tape::{
TAPE_STATUS_DIR,
MAX_CHUNK_ARCHIVE_SIZE,
--
2.30.2
More information about the pbs-devel
mailing list