public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/3] cleanup: replace id from do_sync_job with info from job
Date: Thu, 13 Aug 2020 14:30:18 +0200	[thread overview]
Message-ID: <20200813123019.473-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20200813123019.473-1-d.csapak@proxmox.com>

we already have it inside the job itself

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 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<String>,
-    mut job: Job,
 ) -> Result<String, Error> {
 
-    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





  reply	other threads:[~2020-08-13 12:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 12:30 [pbs-devel] [PATCH proxmox-backup 1/3] cleanup: merge endtime into TaskState Dominik Csapak
2020-08-13 12:30 ` Dominik Csapak [this message]
2020-08-13 12:30 ` [pbs-devel] [PATCH proxmox-backup 3/3] config/jobstate: replace Job:load with create_state_file Dominik Csapak
2020-08-14  4:38 ` [pbs-devel] applied: [PATCH proxmox-backup 1/3] cleanup: merge endtime into TaskState Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200813123019.473-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal