code/fmt cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
16cdb9563b
commit
e4f5f59eea
@ -14,10 +14,10 @@ use proxmox_backup::api2::types::Userid;
|
|||||||
use proxmox_backup::configdir;
|
use proxmox_backup::configdir;
|
||||||
use proxmox_backup::buildcfg;
|
use proxmox_backup::buildcfg;
|
||||||
use proxmox_backup::server;
|
use proxmox_backup::server;
|
||||||
use proxmox_backup::tools::daemon;
|
|
||||||
use proxmox_backup::server::{ApiConfig, rest::*};
|
use proxmox_backup::server::{ApiConfig, rest::*};
|
||||||
use proxmox_backup::auth_helpers::*;
|
use proxmox_backup::auth_helpers::*;
|
||||||
use proxmox_backup::tools::{
|
use proxmox_backup::tools::{
|
||||||
|
daemon,
|
||||||
disks::{
|
disks::{
|
||||||
DiskManage,
|
DiskManage,
|
||||||
zfs_pool_stats,
|
zfs_pool_stats,
|
||||||
@ -739,10 +739,11 @@ async fn schedule_task_log_rotate() {
|
|||||||
move |worker| {
|
move |worker| {
|
||||||
job.start(&worker.upid().to_string())?;
|
job.start(&worker.upid().to_string())?;
|
||||||
worker.log(format!("starting task log rotation"));
|
worker.log(format!("starting task log rotation"));
|
||||||
// one entry has normally about ~100-150 bytes
|
|
||||||
let max_size = 500000; // at least 5000 entries
|
|
||||||
let max_files = 20; // at least 100000 entries
|
|
||||||
let result = try_block!({
|
let result = try_block!({
|
||||||
|
// rotate task log archive
|
||||||
|
let max_size = 500000; // a normal entry has about 100b, so ~ 5000 entries/file
|
||||||
|
let max_files = 20; // times twenty files gives at least 100000 task entries
|
||||||
let has_rotated = rotate_task_log_archive(max_size, true, Some(max_files))?;
|
let has_rotated = rotate_task_log_archive(max_size, true, Some(max_files))?;
|
||||||
if has_rotated {
|
if has_rotated {
|
||||||
worker.log(format!("task log archive was rotated"));
|
worker.log(format!("task log archive was rotated"));
|
||||||
|
@ -93,22 +93,27 @@ pub fn create_task_control_socket() -> Result<(), Error> {
|
|||||||
"\0{}/proxmox-task-control-{}.sock", PROXMOX_BACKUP_VAR_RUN_DIR, *MY_PID);
|
"\0{}/proxmox-task-control-{}.sock", PROXMOX_BACKUP_VAR_RUN_DIR, *MY_PID);
|
||||||
|
|
||||||
let control_future = super::create_control_socket(socketname, |param| {
|
let control_future = super::create_control_socket(socketname, |param| {
|
||||||
let param = param.as_object()
|
let param = param
|
||||||
|
.as_object()
|
||||||
.ok_or_else(|| format_err!("unable to parse parameters (expected json object)"))?;
|
.ok_or_else(|| format_err!("unable to parse parameters (expected json object)"))?;
|
||||||
if param.keys().count() != 2 { bail!("wrong number of parameters"); }
|
if param.keys().count() != 2 { bail!("wrong number of parameters"); }
|
||||||
|
|
||||||
let command = param["command"].as_str()
|
let command = param["command"]
|
||||||
|
.as_str()
|
||||||
.ok_or_else(|| format_err!("unable to parse parameters (missing command)"))?;
|
.ok_or_else(|| format_err!("unable to parse parameters (missing command)"))?;
|
||||||
|
|
||||||
// we have only two commands for now
|
// we have only two commands for now
|
||||||
if !(command == "abort-task" || command == "status") { bail!("got unknown command '{}'", command); }
|
if !(command == "abort-task" || command == "status") {
|
||||||
|
bail!("got unknown command '{}'", command);
|
||||||
|
}
|
||||||
|
|
||||||
let upid_str = param["upid"].as_str()
|
let upid_str = param["upid"]
|
||||||
|
.as_str()
|
||||||
.ok_or_else(|| format_err!("unable to parse parameters (missing upid)"))?;
|
.ok_or_else(|| format_err!("unable to parse parameters (missing upid)"))?;
|
||||||
|
|
||||||
let upid = upid_str.parse::<UPID>()?;
|
let upid = upid_str.parse::<UPID>()?;
|
||||||
|
|
||||||
if !((upid.pid == *MY_PID) && (upid.pstart == *MY_PID_PSTART)) {
|
if !(upid.pid == *MY_PID && upid.pstart == *MY_PID_PSTART) {
|
||||||
bail!("upid does not belong to this process");
|
bail!("upid does not belong to this process");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +565,8 @@ impl TaskListInfoIterator {
|
|||||||
let archive = if active_only {
|
let archive = if active_only {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let logrotate = LogRotate::new(PROXMOX_BACKUP_ARCHIVE_TASK_FN, true).ok_or_else(|| format_err!("could not get archive file names"))?;
|
let logrotate = LogRotate::new(PROXMOX_BACKUP_ARCHIVE_TASK_FN, true)
|
||||||
|
.ok_or_else(|| format_err!("could not get archive file names"))?;
|
||||||
Some(logrotate.files())
|
Some(logrotate.files())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user