From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B2A8869695 for ; Mon, 13 Sep 2021 16:51:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A41EC2BE9A for ; Mon, 13 Sep 2021 16:51:10 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CB32C2BE91 for ; Mon, 13 Sep 2021 16:51:09 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9BD174477A for ; Mon, 13 Sep 2021 16:51:09 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Mon, 13 Sep 2021 16:51:07 +0200 Message-Id: <20210913145107.2627341-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210913141829.2171301-9-d.csapak@proxmox.com> References: <20210913141829.2171301-9-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.388 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup v3] api2: make some workers log on CLI X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2021 14:51:40 -0000 some workers did not log when called via cli Signed-off-by: Dominik Csapak --- chnages from v2: * add missing hunk src/api2/admin/datastore.rs | 4 +++- src/api2/admin/sync.rs | 6 ++++-- src/api2/admin/verify.rs | 5 +++-- src/api2/config/datastore.rs | 5 +++-- src/api2/pull.rs | 3 ++- src/api2/tape/backup.rs | 7 +++++-- src/bin/proxmox-backup-proxy.rs | 6 +++--- src/server/verify_job.rs | 3 ++- 8 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 33700a90..b42de25d 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -951,11 +951,13 @@ pub fn prune_datastore( let datastore = DataStore::lookup_datastore(&store)?; + let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI; + let upid_str = WorkerTask::new_thread( "prune", Some(store.clone()), auth_id.clone(), - false, + to_stdout, move |worker| crate::server::prune_datastore( worker.clone(), auth_id, diff --git a/src/api2/admin/sync.rs b/src/api2/admin/sync.rs index 07f268b5..94990adb 100644 --- a/src/api2/admin/sync.rs +++ b/src/api2/admin/sync.rs @@ -3,7 +3,7 @@ use anyhow::{bail, format_err, Error}; use serde_json::Value; -use proxmox::api::{api, ApiMethod, Permission, Router, RpcEnvironment}; +use proxmox::api::{api, ApiMethod, Permission, Router, RpcEnvironment, RpcEnvironmentType}; use proxmox::api::router::SubdirMap; use proxmox::{list_subdirs_api_method, sortable}; @@ -120,7 +120,9 @@ pub fn run_sync_job( let job = Job::new("syncjob", &id)?; - let upid_str = do_sync_job(job, sync_job, &auth_id, None)?; + let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI; + + let upid_str = do_sync_job(job, sync_job, &auth_id, None, to_stdout)?; Ok(upid_str) } diff --git a/src/api2/admin/verify.rs b/src/api2/admin/verify.rs index a5e5c83f..6bdfdede 100644 --- a/src/api2/admin/verify.rs +++ b/src/api2/admin/verify.rs @@ -5,7 +5,7 @@ use serde_json::Value; use proxmox::api::router::SubdirMap; use proxmox::{list_subdirs_api_method, sortable}; -use proxmox::api::{api, ApiMethod, Permission, Router, RpcEnvironment}; +use proxmox::api::{api, ApiMethod, Permission, Router, RpcEnvironment, RpcEnvironmentType}; use pbs_api_types::{ VerificationJobConfig, VerificationJobStatus, JOB_ID_SCHEMA, Authid, @@ -117,8 +117,9 @@ pub fn run_verification_job( user_info.check_privs(&auth_id, &["datastore", &verification_job.store], PRIV_DATASTORE_VERIFY, true)?; let job = Job::new("verificationjob", &id)?; + let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI; - let upid_str = do_verification_job(job, verification_job, &auth_id, None)?; + let upid_str = do_verification_job(job, verification_job, &auth_id, None, to_stdout)?; Ok(upid_str) } diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index 6301ffaa..c6036fc3 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -4,7 +4,7 @@ use anyhow::{bail, Error}; use serde_json::Value; use ::serde::{Deserialize, Serialize}; -use proxmox::api::{api, Router, RpcEnvironment, Permission}; +use proxmox::api::{api, Router, RpcEnvironment, RpcEnvironmentType, Permission}; use proxmox::api::section_config::SectionConfigData; use proxmox::api::schema::{ApiType, parse_property_string}; @@ -114,12 +114,13 @@ pub fn create_datastore( } let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; + let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI; WorkerTask::new_thread( "create-datastore", Some(config.name.to_string()), auth_id, - false, + to_stdout, move |worker| do_create_datastore(lock, section_config, config, Some(&worker)), ) } diff --git a/src/api2/pull.rs b/src/api2/pull.rs index d7b155a1..1eb86ea3 100644 --- a/src/api2/pull.rs +++ b/src/api2/pull.rs @@ -66,6 +66,7 @@ pub fn do_sync_job( sync_job: SyncJobConfig, auth_id: &Authid, schedule: Option, + to_stdout: bool, ) -> Result { let job_id = format!("{}:{}:{}:{}", @@ -81,7 +82,7 @@ pub fn do_sync_job( &worker_type, Some(job_id.clone()), auth_id.clone(), - false, + to_stdout, move |worker| async move { job.start(&worker.upid().to_string())?; diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs index 39e5feea..808fccfd 100644 --- a/src/api2/tape/backup.rs +++ b/src/api2/tape/backup.rs @@ -165,6 +165,7 @@ pub fn do_tape_backup_job( setup: TapeBackupJobSetup, auth_id: &Authid, schedule: Option, + to_stdout: bool, ) -> Result { let job_id = format!("{}:{}:{}:{}", @@ -196,7 +197,7 @@ pub fn do_tape_backup_job( &worker_type, Some(job_id.clone()), auth_id.clone(), - false, + to_stdout, move |worker| { job.start(&worker.upid().to_string())?; let mut drive_lock = drive_lock; @@ -308,7 +309,9 @@ pub fn run_tape_backup_job( let job = Job::new("tape-backup-job", &id)?; - let upid_str = do_tape_backup_job(job, backup_job.setup, &auth_id, None)?; + let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI; + + let upid_str = do_tape_backup_job(job, backup_job.setup, &auth_id, None, to_stdout)?; Ok(upid_str) } diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 4240711f..3f60d348 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -541,7 +541,7 @@ async fn schedule_datastore_sync_jobs() { }; let auth_id = Authid::root_auth_id().clone(); - if let Err(err) = do_sync_job(job, job_config, &auth_id, Some(event_str)) { + if let Err(err) = do_sync_job(job, job_config, &auth_id, Some(event_str), false) { eprintln!("unable to start datastore sync job {} - {}", &job_id, err); } }; @@ -577,7 +577,7 @@ async fn schedule_datastore_verify_jobs() { Ok(job) => job, Err(_) => continue, // could not get lock }; - if let Err(err) = do_verification_job(job, job_config, &auth_id, Some(event_str)) { + if let Err(err) = do_verification_job(job, job_config, &auth_id, Some(event_str), false) { eprintln!("unable to start datastore verification job {} - {}", &job_id, err); } }; @@ -613,7 +613,7 @@ async fn schedule_tape_backup_jobs() { Ok(job) => job, Err(_) => continue, // could not get lock }; - if let Err(err) = do_tape_backup_job(job, job_config.setup, &auth_id, Some(event_str)) { + if let Err(err) = do_tape_backup_job(job, job_config.setup, &auth_id, Some(event_str), false) { eprintln!("unable to start tape backup job {} - {}", &job_id, err); } }; diff --git a/src/server/verify_job.rs b/src/server/verify_job.rs index 968e6bd4..7f6d73ff 100644 --- a/src/server/verify_job.rs +++ b/src/server/verify_job.rs @@ -19,6 +19,7 @@ pub fn do_verification_job( verification_job: VerificationJobConfig, auth_id: &Authid, schedule: Option, + to_stdout: bool, ) -> Result { let datastore = DataStore::lookup_datastore(&verification_job.store)?; @@ -36,7 +37,7 @@ pub fn do_verification_job( &worker_type, Some(job_id.clone()), auth_id.clone(), - false, + to_stdout, move |worker| { job.start(&worker.upid().to_string())?; -- 2.30.2