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 B41B760A24 for ; Thu, 13 Aug 2020 14:30:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A8A981A4F2 for ; Thu, 13 Aug 2020 14:30:28 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 6ECC91A4DA for ; Thu, 13 Aug 2020 14:30:24 +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 37521445E9 for ; Thu, 13 Aug 2020 14:30:24 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Thu, 13 Aug 2020 14:30:18 +0200 Message-Id: <20200813123019.473-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200813123019.473-1-d.csapak@proxmox.com> References: <20200813123019.473-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.046 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pbs-devel] [PATCH proxmox-backup 2/3] cleanup: replace id from do_sync_job with info from job 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: Thu, 13 Aug 2020 12:30:58 -0000 we already have it inside the job itself Signed-off-by: Dominik Csapak --- src/api2/admin/sync.rs | 2 +- src/api2/pull.rs | 11 +++++------ src/bin/proxmox-backup-proxy.rs | 2 +- src/config/jobstate.rs | 8 ++++++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/api2/admin/sync.rs b/src/api2/admin/sync.rs index aafd808f..0985e26f 100644 --- a/src/api2/admin/sync.rs +++ b/src/api2/admin/sync.rs @@ -90,7 +90,7 @@ fn run_sync_job( let mut job = Job::new("syncjob", &id)?; job.load()?; - let upid_str = do_sync_job(&id, sync_job, &userid, None, job)?; + let upid_str = do_sync_job(job, sync_job, &userid, None)?; Ok(upid_str) } diff --git a/src/api2/pull.rs b/src/api2/pull.rs index e8eb35e1..fc13cf40 100644 --- a/src/api2/pull.rs +++ b/src/api2/pull.rs @@ -66,19 +66,18 @@ pub async fn get_pull_parameters( } pub fn do_sync_job( - id: &str, + mut job: Job, sync_job: SyncJobConfig, userid: &Userid, schedule: Option, - mut job: Job, ) -> Result { - let job_id = id.to_string(); - let worker_type = "syncjob"; + let job_id = job.jobname().to_string(); + let worker_type = job.jobtype().to_string(); let upid_str = WorkerTask::spawn( - worker_type, - Some(id.to_string()), + &worker_type, + Some(job.jobname().to_string()), userid.clone(), false, move |worker| async move { diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index c7f8bc79..1a30bc6f 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -548,7 +548,7 @@ async fn schedule_datastore_sync_jobs() { let userid = Userid::backup_userid().clone(); - if let Err(err) = do_sync_job(&job_id, job_config, &userid, Some(event_str), job) { + if let Err(err) = do_sync_job(job, job_config, &userid, Some(event_str)) { eprintln!("unable to start datastore sync job {} - {}", &job_id, err); } } diff --git a/src/config/jobstate.rs b/src/config/jobstate.rs index 94566bb7..8931563b 100644 --- a/src/config/jobstate.rs +++ b/src/config/jobstate.rs @@ -232,6 +232,14 @@ impl Job { self.write_state() } + pub fn jobtype(&self) -> &str { + &self.jobtype + } + + pub fn jobname(&self) -> &str { + &self.jobname + } + fn write_state(&mut self) -> Result<(), Error> { let serialized = serde_json::to_string(&self.state)?; let path = get_path(&self.jobtype, &self.jobname); -- 2.20.1