aboutsummaryrefslogtreecommitdiff
path: root/src/model/s3
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-08-30 23:46:15 +0200
committerAlex Auvolat <alex@adnab.me>2023-08-30 23:46:15 +0200
commit01c327a07a6045055fef6f923848fe6046e937c4 (patch)
tree4f0aad6f785ea7411f9a5c4537eb94eb5a7a0183 /src/model/s3
parentf0a395e2e5db977caff0ea46e17061e02929178a (diff)
downloadgarage-01c327a07a6045055fef6f923848fe6046e937c4.tar.gz
garage-01c327a07a6045055fef6f923848fe6046e937c4.zip
lifecycle worker: avoid building chrono's serde feature
Diffstat (limited to 'src/model/s3')
-rw-r--r--src/model/s3/lifecycle_worker.rs20
1 files changed, 10 insertions, 10 deletions
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);
}