public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup 1/2] server/jobstate: improve name of 'try_update_state_file'
@ 2021-04-26  8:21 Dominik Csapak
  2021-04-26  8:21 ` [pbs-devel] [PATCH proxmox-backup 2/2] api2/config/datastore: use update_job_last_run_time for schedules Dominik Csapak
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2021-04-26  8:21 UTC (permalink / raw)
  To: pbs-devel

and improve comment

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/config/sync.rs            | 2 +-
 src/api2/config/tape_backup_job.rs | 2 +-
 src/api2/config/verify.rs          | 2 +-
 src/server/jobstate.rs             | 5 +++--
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs
index aa8369fd..e784029a 100644
--- a/src/api2/config/sync.rs
+++ b/src/api2/config/sync.rs
@@ -346,7 +346,7 @@ pub fn update_sync_job(
     sync::save_config(&config)?;
 
     if schedule_changed {
-        crate::server::jobstate::try_update_state_file("syncjob", &id)?;
+        crate::server::jobstate::update_job_last_run_time("syncjob", &id)?;
     }
 
     Ok(())
diff --git a/src/api2/config/tape_backup_job.rs b/src/api2/config/tape_backup_job.rs
index 776b89e4..22afeb6d 100644
--- a/src/api2/config/tape_backup_job.rs
+++ b/src/api2/config/tape_backup_job.rs
@@ -283,7 +283,7 @@ pub fn update_tape_backup_job(
     config::tape_job::save_config(&config)?;
 
     if schedule_changed {
-        crate::server::jobstate::try_update_state_file("tape-backup-job", &id)?;
+        crate::server::jobstate::update_job_last_run_time("tape-backup-job", &id)?;
     }
 
     Ok(())
diff --git a/src/api2/config/verify.rs b/src/api2/config/verify.rs
index dee4c669..477cda89 100644
--- a/src/api2/config/verify.rs
+++ b/src/api2/config/verify.rs
@@ -282,7 +282,7 @@ pub fn update_verification_job(
     verify::save_config(&config)?;
 
     if schedule_changed {
-        crate::server::jobstate::try_update_state_file("verificationjob", &id)?;
+        crate::server::jobstate::update_job_last_run_time("verificationjob", &id)?;
     }
 
     Ok(())
diff --git a/src/server/jobstate.rs b/src/server/jobstate.rs
index c62e58a2..30029bfd 100644
--- a/src/server/jobstate.rs
+++ b/src/server/jobstate.rs
@@ -152,8 +152,9 @@ pub fn create_state_file(jobtype: &str, jobname: &str) -> Result<(), Error> {
 }
 
 /// Tries to update the state file with the current time
-/// if the job is currently running, does nothing,
-pub fn try_update_state_file(jobtype: &str, jobname: &str) -> Result<(), Error> {
+/// if the job is currently running, does nothing.
+/// Intended for use when the schedule changes.
+pub fn update_job_last_run_time(jobtype: &str, jobname: &str) -> Result<(), Error> {
     let mut job = match Job::new(jobtype, jobname) {
         Ok(job) => job,
         Err(_) => return Ok(()), // was locked (running), so do not update
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/2] api2/config/datastore: use update_job_last_run_time for schedules
  2021-04-26  8:21 [pbs-devel] [PATCH proxmox-backup 1/2] server/jobstate: improve name of 'try_update_state_file' Dominik Csapak
@ 2021-04-26  8:21 ` Dominik Csapak
  0 siblings, 0 replies; 2+ messages in thread
From: Dominik Csapak @ 2021-04-26  8:21 UTC (permalink / raw)
  To: pbs-devel

this way, the api call does not error out when the file is locked
currently (which means that job is running and we do not need
to update the time)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/config/datastore.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index 3a3dc176..6ca98b53 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -375,11 +375,11 @@ pub fn update_datastore(
     // we want to reset the statefiles, to avoid an immediate action in some cases
     // (e.g. going from monthly to weekly in the second week of the month)
     if gc_schedule_changed {
-        jobstate::create_state_file("garbage_collection", &name)?;
+        jobstate::update_job_last_run_time("garbage_collection", &name)?;
     }
 
     if prune_schedule_changed {
-        jobstate::create_state_file("prune", &name)?;
+        jobstate::update_job_last_run_time("prune", &name)?;
     }
 
     Ok(())
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-26  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26  8:21 [pbs-devel] [PATCH proxmox-backup 1/2] server/jobstate: improve name of 'try_update_state_file' Dominik Csapak
2021-04-26  8:21 ` [pbs-devel] [PATCH proxmox-backup 2/2] api2/config/datastore: use update_job_last_run_time for schedules Dominik Csapak

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