From f0717dd169d49cef2fb9caa091117f9d7eb152aa Mon Sep 17 00:00:00 2001 From: teutat3s <10206665+teutat3s@users.noreply.github.com> Date: Tue, 28 Feb 2023 16:06:43 +0100 Subject: Bump pnet_datalink 0.28 -> 0.33 Motivation: building garage on illumos is only possible since pnet_datalink version 0.30 Changelog: https://github.com/libpnet/libpnet/compare/v0.28.0...v0.33.0 --- src/rpc/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/rpc/Cargo.toml b/src/rpc/Cargo.toml index 87ae15ac..2c1260a9 100644 --- a/src/rpc/Cargo.toml +++ b/src/rpc/Cargo.toml @@ -37,8 +37,7 @@ k8s-openapi = { version = "0.16", features = ["v1_22"], optional = true } schemars = { version = "0.8", optional = true } reqwest = { version = "0.11", optional = true, default-features = false, features = ["rustls-tls-manual-roots", "json"] } -# newer version requires rust edition 2021 -pnet_datalink = "0.28" +pnet_datalink = "0.33" futures = "0.3" futures-util = "0.3" -- cgit v1.2.3 From b70cc0a94087bfd70931ff6741299823b48ad291 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Thu, 9 Mar 2023 15:34:14 +0000 Subject: block/repair.rs: Added migration for ScrubWorkerPersisted's time_next_run_scrub. Fixes: #520. --- src/block/repair.rs | 54 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/block/repair.rs b/src/block/repair.rs index 10d46291..006cc866 100644 --- a/src/block/repair.rs +++ b/src/block/repair.rs @@ -5,7 +5,6 @@ use std::time::Duration; use async_trait::async_trait; use rand::Rng; -use serde::{Deserialize, Serialize}; use tokio::fs; use tokio::select; use tokio::sync::mpsc; @@ -162,6 +161,50 @@ impl Worker for RepairWorker { // and whose parameter (esp. speed) can be controlled at runtime. // ---- ---- ---- +mod v081 { + use serde::{Deserialize, Serialize}; + + #[derive(Serialize, Deserialize)] + pub struct ScrubWorkerPersisted { + pub tranquility: u32, + pub(crate) time_last_complete_scrub: u64, + pub(crate) corruptions_detected: u64, + } + + impl garage_util::migrate::InitialFormat for ScrubWorkerPersisted {} +} + +mod v082 { + use serde::{Deserialize, Serialize}; + + use super::v081; + + #[derive(Serialize, Deserialize)] + pub struct ScrubWorkerPersisted { + pub tranquility: u32, + pub(crate) time_last_complete_scrub: u64, + pub(crate) time_next_run_scrub: u64, + pub(crate) corruptions_detected: u64, + } + + impl garage_util::migrate::Migrate for ScrubWorkerPersisted { + type Previous = v081::ScrubWorkerPersisted; + + fn migrate(old: v081::ScrubWorkerPersisted) -> ScrubWorkerPersisted { + use crate::repair::randomize_next_scrub_run_time; + + ScrubWorkerPersisted { + tranquility: old.tranquility, + time_last_complete_scrub: old.time_last_complete_scrub, + time_next_run_scrub: randomize_next_scrub_run_time(), + corruptions_detected: old.corruptions_detected, + } + } + } +} + +pub use v082::*; + pub struct ScrubWorker { manager: Arc, rx_cmd: mpsc::Receiver, @@ -172,14 +215,6 @@ pub struct ScrubWorker { persister: PersisterShared, } -#[derive(Serialize, Deserialize)] -pub struct ScrubWorkerPersisted { - pub tranquility: u32, - pub(crate) time_last_complete_scrub: u64, - pub(crate) time_next_run_scrub: u64, - pub(crate) corruptions_detected: u64, -} - fn randomize_next_scrub_run_time() -> u64 { // Take SCRUB_INTERVAL and mix in a random interval of 10 days to attempt to // balance scrub load across different cluster nodes. @@ -194,7 +229,6 @@ fn randomize_next_scrub_run_time() -> u64 { next_run_timestamp } -impl garage_util::migrate::InitialFormat for ScrubWorkerPersisted {} impl Default for ScrubWorkerPersisted { fn default() -> Self { ScrubWorkerPersisted { -- cgit v1.2.3 From 7b65dd24e2bacc20afa747dc2b1f3fb81249f688 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Thu, 9 Mar 2023 16:32:22 +0000 Subject: block/repair.rs: Added a timestamp argument to randomize_next_scrub_run_time(). --- src/block/repair.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/block/repair.rs b/src/block/repair.rs index 006cc866..5476bf8a 100644 --- a/src/block/repair.rs +++ b/src/block/repair.rs @@ -196,7 +196,7 @@ mod v082 { ScrubWorkerPersisted { tranquility: old.tranquility, time_last_complete_scrub: old.time_last_complete_scrub, - time_next_run_scrub: randomize_next_scrub_run_time(), + time_next_run_scrub: randomize_next_scrub_run_time(old.time_last_complete_scrub), corruptions_detected: old.corruptions_detected, } } @@ -215,11 +215,11 @@ pub struct ScrubWorker { persister: PersisterShared, } -fn randomize_next_scrub_run_time() -> u64 { +fn randomize_next_scrub_run_time(timestamp: u64) -> u64 { // Take SCRUB_INTERVAL and mix in a random interval of 10 days to attempt to // balance scrub load across different cluster nodes. - let next_run_timestamp = now_msec() + let next_run_timestamp = timestamp + SCRUB_INTERVAL .saturating_add(Duration::from_secs( rand::thread_rng().gen_range(0..3600 * 24 * 10), @@ -233,7 +233,7 @@ impl Default for ScrubWorkerPersisted { fn default() -> Self { ScrubWorkerPersisted { time_last_complete_scrub: 0, - time_next_run_scrub: randomize_next_scrub_run_time(), + time_next_run_scrub: randomize_next_scrub_run_time(now_msec()), tranquility: INITIAL_SCRUB_TRANQUILITY, corruptions_detected: 0, } @@ -395,7 +395,7 @@ impl Worker for ScrubWorker { } else { self.persister.set_with(|p| { p.time_last_complete_scrub = now_msec(); - p.time_next_run_scrub = randomize_next_scrub_run_time(); + p.time_next_run_scrub = randomize_next_scrub_run_time(now_msec()); })?; self.work = ScrubWorkerState::Finished; self.tranquilizer.clear(); -- cgit v1.2.3 From d218f475cbe6450f0402424e01b99c4630cb8a2f Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Thu, 9 Mar 2023 17:08:47 +0000 Subject: block/manager.rs: Set defaults for scrub_persister. --- src/block/manager.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/block/manager.rs b/src/block/manager.rs index bfa66069..26278974 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -152,6 +152,7 @@ impl BlockManager { tx_scrub_command: ArcSwapOption::new(None), }); block_manager.endpoint.set_handler(block_manager.clone()); + block_manager.scrub_persister.set_with(|_| ()).unwrap(); block_manager } -- cgit v1.2.3