aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/model/Cargo.toml2
-rw-r--r--src/model/s3/lifecycle_worker.rs20
2 files changed, 11 insertions, 11 deletions
diff --git a/src/model/Cargo.toml b/src/model/Cargo.toml
index 58d9fdb7..3794cc59 100644
--- a/src/model/Cargo.toml
+++ b/src/model/Cargo.toml
@@ -23,7 +23,7 @@ garage_util.workspace = true
async-trait = "0.1.7"
arc-swap = "1.0"
blake2 = "0.10"
-chrono = { version = "0.4", features = ["serde"] }
+chrono = "0.4"
err-derive = "0.3"
hex = "0.4"
base64 = "0.21"
diff --git a/src/model/s3/lifecycle_worker.rs b/src/model/s3/lifecycle_worker.rs
index 5641b093..02374bf0 100644
--- a/src/model/s3/lifecycle_worker.rs
+++ b/src/model/s3/lifecycle_worker.rs
@@ -19,12 +19,11 @@ use crate::s3::object_table::*;
use crate::garage::Garage;
mod v090 {
- use chrono::naive::NaiveDate;
use serde::{Deserialize, Serialize};
- #[derive(Serialize, Deserialize, Default, Clone, Copy)]
+ #[derive(Serialize, Deserialize, Default, Clone)]
pub struct LifecycleWorkerPersisted {
- pub last_completed: Option<NaiveDate>,
+ pub last_completed: Option<String>,
}
impl garage_util::migrate::InitialFormat for LifecycleWorkerPersisted {
@@ -65,18 +64,19 @@ pub fn register_bg_vars(
vars: &mut vars::BgVars,
) {
vars.register_ro(persister, "lifecycle-last-completed", |p| {
- p.get_with(|x| {
- x.last_completed
- .map(|date| date.to_string())
- .unwrap_or("never".to_string())
- })
+ p.get_with(|x| x.last_completed.clone().unwrap_or("never".to_string()))
});
}
impl LifecycleWorker {
pub fn new(garage: Arc<Garage>, persister: PersisterShared<LifecycleWorkerPersisted>) -> Self {
let today = today();
- let state = match persister.get_with(|x| x.last_completed) {
+ let last_completed = persister.get_with(|x| {
+ x.last_completed
+ .as_deref()
+ .and_then(|x| x.parse::<NaiveDate>().ok())
+ });
+ let state = match last_completed {
Some(d) if d >= today => State::Completed(d),
_ => State::Running {
date: today,
@@ -162,7 +162,7 @@ impl Worker for LifecycleWorker {
None => {
info!("Lifecycle worker finished for {}, objects expired: {}, mpu aborted: {}", date, *objects_expired, *mpu_aborted);
self.persister
- .set_with(|x| x.last_completed = Some(*date))?;
+ .set_with(|x| x.last_completed = Some(date.to_string()))?;
self.state = State::Completed(*date);
return Ok(WorkerState::Idle);
}