public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications
@ 2021-03-11  8:24 Dominik Csapak
  2021-03-11  8:24 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] server/worker_task: improve endtime for unknown tasks Dominik Csapak
  2021-03-11  8:58 ` [pbs-devel] applied: [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Dominik Csapak @ 2021-03-11  8:24 UTC (permalink / raw)
  To: pbs-devel

and reuse 'send_job_status_mail' there so that we get consistent
formatted mails from pbs (e.g. html part and author)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* better commit subject/message
* move code to email related module
* do not make send_job_status_mail pub

 src/server/email_notifications.rs | 24 +++++++++++++++++++++
 src/tape/changer/email.rs         | 36 -------------------------------
 src/tape/changer/mod.rs           |  3 ---
 src/tape/drive/mod.rs             |  6 ++++--
 4 files changed, 28 insertions(+), 41 deletions(-)
 delete mode 100644 src/tape/changer/email.rs

diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
index 306e84d0..229443f6 100644
--- a/src/server/email_notifications.rs
+++ b/src/server/email_notifications.rs
@@ -448,6 +448,30 @@ pub fn send_tape_backup_status(
     Ok(())
 }
 
+/// Send email to a person to request a manual media change
+pub fn send_load_media_email(
+    drive: &str,
+    label_text: &str,
+    to: &str,
+    reason: Option<String>,
+) -> Result<(), Error> {
+
+    let subject = format!("Load Media '{}' request for drive '{}'", label_text, drive);
+
+    let mut text = String::new();
+
+    if let Some(reason) = reason {
+        text.push_str(&format!("The drive has the wrong or no tape inserted. Error:\n{}\n\n", reason));
+    }
+
+    text.push_str("Please insert the requested media into the backup drive.\n\n");
+
+    text.push_str(&format!("Drive: {}\n", drive));
+    text.push_str(&format!("Media: {}\n", label_text));
+
+    send_job_status_mail(to, &subject, &text)
+}
+
 fn get_server_url() -> (String, usize) {
 
     // user will surely request that they can change this
diff --git a/src/tape/changer/email.rs b/src/tape/changer/email.rs
deleted file mode 100644
index abd7ead8..00000000
--- a/src/tape/changer/email.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use anyhow::Error;
-
-use proxmox::tools::email::sendmail;
-
-/// Send email to a person to request a manual media change
-pub fn send_load_media_email(
-    drive: &str,
-    label_text: &str,
-    to: &str,
-    reason: Option<String>,
-) -> Result<(), Error> {
-
-    let subject = format!("Load Media '{}' request for drive '{}'", label_text, drive);
-
-    let mut text = String::new();
-
-    if let Some(reason) = reason {
-        text.push_str(&format!("The drive has the wrong or no tape inserted. Error:\n{}\n\n", reason));
-    }
-
-    text.push_str("Please insert the requested media into the backup drive.\n\n");
-
-    text.push_str(&format!("Drive: {}\n", drive));
-    text.push_str(&format!("Media: {}\n", label_text));
-
-    sendmail(
-        &[to],
-        &subject,
-        Some(&text),
-        None,
-        None,
-        None,
-    )?;
-
-    Ok(())
-}
diff --git a/src/tape/changer/mod.rs b/src/tape/changer/mod.rs
index 1e58a437..a25df49b 100644
--- a/src/tape/changer/mod.rs
+++ b/src/tape/changer/mod.rs
@@ -1,8 +1,5 @@
 //! Media changer implementation (SCSI media changer)
 
-mod email;
-pub use email::*;
-
 pub mod sg_pt_changer;
 
 pub mod mtx;
diff --git a/src/tape/drive/mod.rs b/src/tape/drive/mod.rs
index a386abf8..1267a481 100644
--- a/src/tape/drive/mod.rs
+++ b/src/tape/drive/mod.rs
@@ -51,7 +51,10 @@ use crate::{
         VirtualTapeDrive,
         LinuxTapeDrive,
     },
-    server::WorkerTask,
+    server::{
+        send_load_media_email,
+        WorkerTask,
+    },
     tape::{
         TapeWrite,
         TapeRead,
@@ -66,7 +69,6 @@ use crate::{
         changer::{
             MediaChange,
             MtxMediaChanger,
-            send_load_media_email,
         },
     },
 };
-- 
2.20.1





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

* [pbs-devel] [PATCH proxmox-backup v2 2/2] server/worker_task: improve endtime for unknown tasks
  2021-03-11  8:24 [pbs-devel] [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications Dominik Csapak
@ 2021-03-11  8:24 ` Dominik Csapak
  2021-03-11  8:58   ` [pbs-devel] applied: " Thomas Lamprecht
  2021-03-11  8:58 ` [pbs-devel] applied: [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications Thomas Lamprecht
  1 sibling, 1 reply; 4+ messages in thread
From: Dominik Csapak @ 2021-03-11  8:24 UTC (permalink / raw)
  To: pbs-devel

instead of always using the starttime, use the last timestamp from the log
this way, one can see when the task was aborted without having to read
the log

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

diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs
index 1e8e009f..6c5456c9 100644
--- a/src/server/worker_task.rs
+++ b/src/server/worker_task.rs
@@ -207,6 +207,8 @@ pub fn upid_read_status(upid: &UPID) -> Result<TaskState, Error> {
     let mut iter = last_line.splitn(2, ": ");
     if let Some(time_str) = iter.next() {
         if let Ok(endtime) = proxmox::tools::time::parse_rfc3339(time_str) {
+            // set the endtime even if we cannot parse the state
+            status = TaskState::Unknown { endtime };
             if let Some(rest) = iter.next().and_then(|rest| rest.strip_prefix("TASK ")) {
                 if let Ok(state) = TaskState::from_endtime_and_message(endtime, rest) {
                     status = state;
-- 
2.20.1





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

* [pbs-devel] applied: [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications
  2021-03-11  8:24 [pbs-devel] [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications Dominik Csapak
  2021-03-11  8:24 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] server/worker_task: improve endtime for unknown tasks Dominik Csapak
@ 2021-03-11  8:58 ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-03-11  8:58 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 11.03.21 09:24, Dominik Csapak wrote:
> and reuse 'send_job_status_mail' there so that we get consistent
> formatted mails from pbs (e.g. html part and author)
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> changes from v1:
> * better commit subject/message
> * move code to email related module
> * do not make send_job_status_mail pub
> 
>  src/server/email_notifications.rs | 24 +++++++++++++++++++++
>  src/tape/changer/email.rs         | 36 -------------------------------
>  src/tape/changer/mod.rs           |  3 ---
>  src/tape/drive/mod.rs             |  6 ++++--
>  4 files changed, 28 insertions(+), 41 deletions(-)
>  delete mode 100644 src/tape/changer/email.rs
> 
>

applied, thanks!




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

* [pbs-devel] applied: [PATCH proxmox-backup v2 2/2] server/worker_task: improve endtime for unknown tasks
  2021-03-11  8:24 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] server/worker_task: improve endtime for unknown tasks Dominik Csapak
@ 2021-03-11  8:58   ` Thomas Lamprecht
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-03-11  8:58 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 11.03.21 09:24, Dominik Csapak wrote:
> instead of always using the starttime, use the last timestamp from the log
> this way, one can see when the task was aborted without having to read
> the log
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/server/worker_task.rs | 2 ++
>  1 file changed, 2 insertions(+)
> 
>

applied, thanks!




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

end of thread, other threads:[~2021-03-11  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11  8:24 [pbs-devel] [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications Dominik Csapak
2021-03-11  8:24 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] server/worker_task: improve endtime for unknown tasks Dominik Csapak
2021-03-11  8:58   ` [pbs-devel] applied: " Thomas Lamprecht
2021-03-11  8:58 ` [pbs-devel] applied: [PATCH proxmox-backup v2 1/2] tape/send_load_media_email: move to server/email_notifications Thomas Lamprecht

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