update to proxmox-log 0.2 and proxmox-rest-server 0.7

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2024-07-24 14:34:56 +02:00
parent eb44bdb842
commit 96b7812b6a
10 changed files with 82 additions and 85 deletions

View File

@ -60,17 +60,18 @@ proxmox-auth-api = "0.4"
proxmox-borrow = "1"
proxmox-compression = "0.2"
proxmox-config-digest = "0.1.0"
proxmox-daemon = "0.1.0"
proxmox-fuse = "0.1.3"
proxmox-http = { version = "0.9.0", features = [ "client", "http-helpers", "websocket" ] } # see below
proxmox-human-byte = "0.1"
proxmox-io = "1.0.1" # tools and client use "tokio" feature
proxmox-lang = "1.1"
proxmox-log = "0.1"
proxmox-log = "0.2"
proxmox-ldap = "0.2.1"
proxmox-metrics = "0.3.1"
proxmox-notify = "0.4"
proxmox-openid = "0.10.0"
proxmox-rest-server = { version = "0.6", features = [ "templates" ] }
proxmox-rest-server = { version = "0.7", features = [ "templates" ] }
# some use "cli", some use "cli" and "server", pbs-config uses nothing
proxmox-router = { version = "2.0.0", default-features = false }
proxmox-rrd = { version = "0.2" }
@ -82,6 +83,7 @@ proxmox-shared-memory = "0.3.0"
proxmox-sortable-macro = "0.1.2"
proxmox-subscription = { version = "0.4.2", features = [ "api-types" ] }
proxmox-sys = "0.6"
proxmox-systemd = "0.1"
proxmox-tfa = { version = "5", features = [ "api", "api-types" ] }
proxmox-time = "2"
proxmox-uuid = "1"
@ -214,6 +216,7 @@ proxmox-async.workspace = true
proxmox-auth-api = { workspace = true, features = [ "api", "pam-authenticator" ] }
proxmox-compression.workspace = true
proxmox-config-digest.workspace = true
proxmox-daemon.workspace = true
proxmox-http = { workspace = true, features = [ "client-trait", "proxmox-async", "rate-limited-stream" ] } # pbs-client doesn't use these
proxmox-human-byte.workspace = true
proxmox-io.workspace = true
@ -232,6 +235,7 @@ proxmox-shared-memory.workspace = true
proxmox-sortable-macro.workspace = true
proxmox-subscription.workspace = true
proxmox-sys = { workspace = true, features = [ "timer" ] }
proxmox-systemd.workspace = true
proxmox-tfa.workspace = true
proxmox-time.workspace = true
proxmox-uuid.workspace = true
@ -264,6 +268,7 @@ proxmox-rrd.workspace = true
#proxmox-borrow = { path = "../proxmox/proxmox-borrow" }
#proxmox-compression = { path = "../proxmox/proxmox-compression" }
#proxmox-config-digest = { path = "../proxmox/proxmox-config-digest" }
#proxmox-daemon = { path = "../proxmox/proxmox-daemon" }
#proxmox-fuse = { path = "../proxmox-fuse" }
#proxmox-http = { path = "../proxmox/proxmox-http" }
#proxmox-human-byte = { path = "../proxmox/proxmox-human-byte" }
@ -284,6 +289,7 @@ proxmox-rrd.workspace = true
#proxmox-sortable-macro = { path = "../proxmox/proxmox-sortable-macro" }
#proxmox-subscription = { path = "../proxmox/proxmox-subscription" }
#proxmox-sys = { path = "../proxmox/proxmox-sys" }
#proxmox-systemd = { path = "../proxmox/proxmox-systemd" }
#proxmox-tfa = { path = "../proxmox/proxmox-tfa" }
#proxmox-time = { path = "../proxmox/proxmox-time" }
#proxmox-uuid = { path = "../proxmox/proxmox-uuid" }

8
debian/control vendored
View File

@ -75,14 +75,14 @@ Build-Depends: bash-completion,
librust-proxmox-io-1+tokio-dev (>= 1.0.1-~~),
librust-proxmox-lang-1+default-dev (>= 1.1-~~),
librust-proxmox-ldap-0.2+default-dev (>= 0.2.1-~~),
librust-proxmox-log-0.1+default-dev,
librust-proxmox-log-0.2+default-dev,
librust-proxmox-metrics-0.3+default-dev (>= 0.3.1-~~),
librust-proxmox-notify-0.4+default-dev,
librust-proxmox-notify-0.4+pbs-context-dev,
librust-proxmox-openid-0.10+default-dev,
librust-proxmox-rest-server-0.6+default-dev,
librust-proxmox-rest-server-0.6+rate-limited-stream-dev,
librust-proxmox-rest-server-0.6+templates-dev,
librust-proxmox-rest-server-0.7+default-dev,
librust-proxmox-rest-server-0.7+rate-limited-stream-dev,
librust-proxmox-rest-server-0.7+templates-dev,
librust-proxmox-router-2+cli-dev,
librust-proxmox-router-2+server-dev,
librust-proxmox-rrd-0.2+default-dev,

View File

@ -3,9 +3,7 @@ use std::str::FromStr;
use anyhow::Error;
use futures::*;
extern crate proxmox_backup;
use pbs_client::{ChunkStream, FixedChunkStream};
use pbs_client::ChunkStream;
use proxmox_human_byte::HumanByte;
// Test Chunker with real data read from a file.

View File

@ -425,8 +425,8 @@ pub fn update_datastore(
if let Ok(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 _ = proxmox_rest_server::send_raw_command(
let sock = proxmox_daemon::command_socket::path_from_pid(proxy_pid);
let _ = proxmox_daemon::command_socket::send_raw(
sock,
&format!(
"{{\"command\":\"update-datastore-cache\",\"args\":\"{}\"}}\n",

View File

@ -1,5 +1,5 @@
use std::future::Future;
use std::pin::Pin;
use std::pin::{pin, Pin};
use anyhow::{bail, Error};
use futures::*;
@ -9,7 +9,7 @@ use tracing::level_filters::LevelFilter;
use proxmox_lang::try_block;
use proxmox_log::init_logger;
use proxmox_rest_server::{daemon, ApiConfig, RestServer};
use proxmox_rest_server::{ApiConfig, RestServer};
use proxmox_router::RpcEnvironmentType;
use proxmox_sys::fs::CreateOptions;
@ -41,7 +41,7 @@ fn get_index() -> Pin<Box<dyn Future<Output = Response<Body>> + Send>> {
}
async fn run() -> Result<(), Error> {
init_logger("PBS_LOG", LevelFilter::INFO, "proxmox-backup-api")?;
init_logger("PBS_LOG", LevelFilter::INFO)?;
config::create_configdir()?;
@ -71,10 +71,7 @@ async fn run() -> Result<(), Error> {
proxmox_backup::server::notifications::init()?;
let backup_user = pbs_config::backup_user()?;
let mut command_sock = proxmox_rest_server::CommandSocket::new(
proxmox_rest_server::our_ctrl_sock(),
backup_user.gid,
);
let mut command_sock = proxmox_daemon::command_socket::CommandSocket::new(backup_user.gid);
let dir_opts = CreateOptions::new()
.owner(backup_user.uid)
@ -107,17 +104,17 @@ async fn run() -> Result<(), Error> {
)?;
// http server future:
let server = daemon::create_daemon(
let server = proxmox_daemon::server::create_daemon(
([127, 0, 0, 1], 82).into(),
move |listener| {
let incoming = hyper::server::conn::AddrIncoming::from_listener(listener)?;
Ok(async {
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
proxmox_systemd::notify::SystemdNotify::Ready.notify()?;
hyper::Server::builder(incoming)
.serve(rest_server)
.with_graceful_shutdown(proxmox_rest_server::shutdown_future())
.with_graceful_shutdown(proxmox_daemon::shutdown_future())
.map_err(Error::from)
.await
})
@ -129,9 +126,9 @@ async fn run() -> Result<(), Error> {
let init_result: Result<(), Error> = try_block!({
proxmox_rest_server::register_task_control_commands(&mut command_sock)?;
command_sock.spawn()?;
proxmox_rest_server::catch_shutdown_signal()?;
proxmox_rest_server::catch_reload_signal()?;
command_sock.spawn(proxmox_rest_server::last_worker_future())?;
proxmox_daemon::catch_shutdown_signal(proxmox_rest_server::last_worker_future())?;
proxmox_daemon::catch_reload_signal(proxmox_rest_server::last_worker_future())?;
Ok(())
});
@ -154,7 +151,7 @@ async fn run() -> Result<(), Error> {
server.await?;
log::info!("server shutting down, waiting for active workers to complete");
proxmox_rest_server::last_worker_future().await?;
proxmox_rest_server::last_worker_future().await;
log::info!("done - exit server");
@ -162,8 +159,11 @@ async fn run() -> Result<(), Error> {
}
fn start_notification_worker() {
let abort_future = proxmox_rest_server::shutdown_future();
let future = Box::pin(proxmox_backup::server::notifications::notification_worker());
let task = futures::future::select(future, abort_future);
tokio::spawn(task);
let future = proxmox_backup::server::notifications::notification_worker();
let abort_future = proxmox_daemon::shutdown_future();
tokio::spawn(async move {
let future = pin!(future);
let abort_future = pin!(abort_future);
futures::future::select(future, abort_future).await;
});
}

View File

@ -553,12 +553,9 @@ async fn run() -> Result<(), Error> {
file_opts,
)?;
let mut command_sock = proxmox_rest_server::CommandSocket::new(
proxmox_rest_server::our_ctrl_sock(),
backup_user.gid,
);
let mut command_sock = proxmox_daemon::command_socket::CommandSocket::new(backup_user.gid);
proxmox_rest_server::register_task_control_commands(&mut command_sock)?;
command_sock.spawn()?;
command_sock.spawn(proxmox_rest_server::last_worker_future())?;
}
let mut rpcenv = CliEnvironment::new();

View File

@ -1,4 +1,5 @@
use std::path::{Path, PathBuf};
use std::pin::pin;
use std::sync::{Arc, Mutex};
use anyhow::{bail, format_err, Context, Error};
@ -49,8 +50,6 @@ use pbs_api_types::{
VerificationJobConfig,
};
use proxmox_rest_server::daemon;
use proxmox_backup::auth_helpers::*;
use proxmox_backup::server;
use proxmox_backup::tools::{
@ -183,7 +182,7 @@ async fn get_index_future(env: RestEnvironment, parts: Parts) -> Response<Body>
}
async fn run() -> Result<(), Error> {
init_logger("PBS_LOG", LevelFilter::INFO, "proxmox-backup-proxy")?;
init_logger("PBS_LOG", LevelFilter::INFO)?;
proxmox_backup::auth_helpers::setup_auth_context(false);
proxmox_backup::server::notifications::init()?;
@ -215,10 +214,7 @@ async fn run() -> Result<(), Error> {
]);
let backup_user = pbs_config::backup_user()?;
let mut command_sock = proxmox_rest_server::CommandSocket::new(
proxmox_rest_server::our_ctrl_sock(),
backup_user.gid,
);
let mut command_sock = proxmox_daemon::command_socket::CommandSocket::new(backup_user.gid);
let dir_opts = CreateOptions::new()
.owner(backup_user.uid)
@ -293,23 +289,23 @@ async fn run() -> Result<(), Error> {
.rate_limiter_lookup(Arc::new(lookup_rate_limiter))
.tcp_keepalive_time(PROXMOX_BACKUP_TCP_KEEPALIVE_TIME);
let server = daemon::create_daemon(
let server = proxmox_daemon::server::create_daemon(
([0, 0, 0, 0, 0, 0, 0, 0], 8007).into(),
move |listener| {
let (secure_connections, insecure_connections) =
connections.accept_tls_optional(listener, acceptor);
Ok(async {
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
proxmox_systemd::notify::SystemdNotify::Ready.notify()?;
let secure_server = hyper::Server::builder(secure_connections)
.serve(rest_server)
.with_graceful_shutdown(proxmox_rest_server::shutdown_future())
.with_graceful_shutdown(proxmox_daemon::shutdown_future())
.map_err(Error::from);
let insecure_server = hyper::Server::builder(insecure_connections)
.serve(redirector)
.with_graceful_shutdown(proxmox_rest_server::shutdown_future())
.with_graceful_shutdown(proxmox_daemon::shutdown_future())
.map_err(Error::from);
let (secure_res, insecure_res) =
@ -338,9 +334,9 @@ async fn run() -> Result<(), Error> {
let init_result: Result<(), Error> = try_block!({
proxmox_rest_server::register_task_control_commands(&mut command_sock)?;
command_sock.spawn()?;
proxmox_rest_server::catch_shutdown_signal()?;
proxmox_rest_server::catch_reload_signal()?;
command_sock.spawn(proxmox_rest_server::last_worker_future())?;
proxmox_daemon::catch_shutdown_signal(proxmox_rest_server::last_worker_future())?;
proxmox_daemon::catch_reload_signal(proxmox_rest_server::last_worker_future())?;
Ok(())
});
@ -365,7 +361,7 @@ async fn run() -> Result<(), Error> {
server.await?;
log::info!("server shutting down, waiting for active workers to complete");
proxmox_rest_server::last_worker_future().await?;
proxmox_rest_server::last_worker_future().await;
log::info!("done - exit server");
Ok(())
@ -394,24 +390,27 @@ fn make_tls_acceptor() -> Result<SslAcceptor, Error> {
}
fn start_stat_generator() {
let abort_future = proxmox_rest_server::shutdown_future();
let future = Box::pin(run_stat_generator());
let task = futures::future::select(future, abort_future);
tokio::spawn(task.map(|_| ()));
tokio::spawn(async {
let abort_future = pin!(proxmox_daemon::shutdown_future());
let future = pin!(run_stat_generator());
futures::future::select(future, abort_future).await;
});
}
fn start_task_scheduler() {
let abort_future = proxmox_rest_server::shutdown_future();
let future = Box::pin(run_task_scheduler());
let task = futures::future::select(future, abort_future);
tokio::spawn(task.map(|_| ()));
tokio::spawn(async {
let abort_future = pin!(proxmox_daemon::shutdown_future());
let future = pin!(run_task_scheduler());
futures::future::select(future, abort_future).await;
});
}
fn start_traffic_control_updater() {
let abort_future = proxmox_rest_server::shutdown_future();
let future = Box::pin(run_traffic_control_updater());
let task = futures::future::select(future, abort_future);
tokio::spawn(task.map(|_| ()));
tokio::spawn(async {
let abort_future = pin!(proxmox_daemon::shutdown_future());
let future = pin!(run_traffic_control_updater());
futures::future::select(future, abort_future).await;
});
}
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
@ -827,14 +826,14 @@ 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 = proxmox_rest_server::our_ctrl_sock();
let sock = proxmox_daemon::command_socket::this_path();
let f1 =
proxmox_rest_server::send_raw_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
proxmox_daemon::command_socket::send_raw(sock, "{\"command\":\"api-access-log-reopen\"}\n");
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 sock = proxmox_daemon::command_socket::path_from_pid(pid);
let f2 =
proxmox_rest_server::send_raw_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
proxmox_daemon::command_socket::send_raw(sock, "{\"command\":\"api-access-log-reopen\"}\n");
match futures::join!(f1, f2) {
(Err(e1), Err(e2)) => Err(format_err!(
@ -849,12 +848,14 @@ 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 = proxmox_rest_server::our_ctrl_sock();
let f1 = proxmox_rest_server::send_raw_command(sock, "{\"command\":\"api-auth-log-reopen\"}\n");
let sock = proxmox_daemon::command_socket::this_path();
let f1 =
proxmox_daemon::command_socket::send_raw(sock, "{\"command\":\"api-auth-log-reopen\"}\n");
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_raw_command(sock, "{\"command\":\"api-auth-log-reopen\"}\n");
let sock = proxmox_daemon::command_socket::path_from_pid(pid);
let f2 =
proxmox_daemon::command_socket::send_raw(sock, "{\"command\":\"api-auth-log-reopen\"}\n");
match futures::join!(f1, f2) {
(Err(e1), Err(e2)) => Err(format_err!(

View File

@ -97,12 +97,9 @@ async fn run(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
file_opts.clone(),
)?;
let mut command_sock = proxmox_rest_server::CommandSocket::new(
proxmox_rest_server::our_ctrl_sock(),
backup_user.gid,
);
let mut command_sock = proxmox_daemon::command_socket::CommandSocket::new(backup_user.gid);
proxmox_rest_server::register_task_control_commands(&mut command_sock)?;
command_sock.spawn()?;
command_sock.spawn(proxmox_rest_server::last_worker_future())?;
do_update(rpcenv).await
}

View File

@ -37,18 +37,18 @@ pub(crate) mod pull;
pub(crate) async fn reload_proxy_certificate() -> Result<(), Error> {
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 sock = proxmox_daemon::command_socket::path_from_pid(proxy_pid);
let _: Value =
proxmox_rest_server::send_raw_command(sock, "{\"command\":\"reload-certificate\"}\n")
proxmox_daemon::command_socket::send_raw(sock, "{\"command\":\"reload-certificate\"}\n")
.await?;
Ok(())
}
pub(crate) async fn notify_datastore_removed() -> Result<(), Error> {
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 sock = proxmox_daemon::command_socket::path_from_pid(proxy_pid);
let _: Value =
proxmox_rest_server::send_raw_command(sock, "{\"command\":\"datastore-removed\"}\n")
proxmox_daemon::command_socket::send_raw(sock, "{\"command\":\"datastore-removed\"}\n")
.await?;
Ok(())
}

View File

@ -2,7 +2,7 @@ use anyhow::{bail, Error};
use tracing::info;
use proxmox_lang::try_block;
use proxmox_rest_server::{CommandSocket, WorkerTask};
use proxmox_rest_server::WorkerTask;
use proxmox_sys::fs::CreateOptions;
use proxmox_worker_task::WorkerTaskContext;
@ -40,10 +40,8 @@ fn worker_task_abort() -> Result<(), Error> {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move {
let mut commando_sock = CommandSocket::new(
proxmox_rest_server::our_ctrl_sock(),
nix::unistd::Gid::current(),
);
let mut commando_sock =
proxmox_daemon::command_socket::CommandSocket::new(nix::unistd::Gid::current());
let init_result: Result<(), Error> = try_block!({
proxmox_rest_server::register_task_control_commands(&mut commando_sock)?;
@ -55,7 +53,7 @@ fn worker_task_abort() -> Result<(), Error> {
return;
}
if let Err(err) = commando_sock.spawn() {
if let Err(err) = commando_sock.spawn(proxmox_rest_server::last_worker_future()) {
eprintln!("unable to spawn command socket - {}", err);
return;
}
@ -70,7 +68,7 @@ fn worker_task_abort() -> Result<(), Error> {
println!("WORKER {}", worker);
let result = garbage_collection(&worker);
proxmox_rest_server::request_shutdown();
proxmox_daemon::request_shutdown();
if let Err(err) = result {
println!("got expected error: {}", err);