* [pve-devel] [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths..
@ 2023-04-04 11:21 Fabian Grünbichler
2023-04-04 11:21 ` [pve-devel] [PATCH proxmox-offline-mirror 2/2] fix #4261: allow GC for all configured mirrors Fabian Grünbichler
2023-04-06 11:25 ` [pve-devel] applied: [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths Thomas Lamprecht
0 siblings, 2 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2023-04-04 11:21 UTC (permalink / raw)
To: pve-devel
a Path(Buf)'s Debug formatting already contains double quotes, no need to quote
it a second time..
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
src/pool.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pool.rs b/src/pool.rs
index 7a67087..3da8c08 100644
--- a/src/pool.rs
+++ b/src/pool.rs
@@ -483,12 +483,12 @@ impl PoolLockGuard<'_> {
match actual_link_count.cmp(&expected_link_count) {
std::cmp::Ordering::Less => {
- println!("Something fishy going on with '{path:?}'");
+ println!("Something fishy going on with {path:?}");
false
}
std::cmp::Ordering::Equal => {
// only checksum files remaining
- println!("Removing '{:?}'", &path);
+ println!("Removing {path:?}");
true
}
std::cmp::Ordering::Greater => {
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH proxmox-offline-mirror 2/2] fix #4261: allow GC for all configured mirrors
2023-04-04 11:21 [pve-devel] [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths Fabian Grünbichler
@ 2023-04-04 11:21 ` Fabian Grünbichler
2023-04-06 11:25 ` [pve-devel] applied: " Thomas Lamprecht
2023-04-06 11:25 ` [pve-devel] applied: [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths Thomas Lamprecht
1 sibling, 1 reply; 4+ messages in thread
From: Fabian Grünbichler @ 2023-04-04 11:21 UTC (permalink / raw)
To: pve-devel
by making the --id parameter optional, and structuring the output accordingly.
since pools are per base-dir, GC only needs to run once per base-dir instead of
for each mirror entry.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
src/bin/proxmox_offline_mirror_cmds/mirror.rs | 52 +++++++++++++++++--
1 file changed, 47 insertions(+), 5 deletions(-)
diff --git a/src/bin/proxmox_offline_mirror_cmds/mirror.rs b/src/bin/proxmox_offline_mirror_cmds/mirror.rs
index a3fb258..07db92f 100644
--- a/src/bin/proxmox_offline_mirror_cmds/mirror.rs
+++ b/src/bin/proxmox_offline_mirror_cmds/mirror.rs
@@ -4,7 +4,7 @@ use proxmox_section_config::SectionConfigData;
use proxmox_subscription::SubscriptionStatus;
use serde_json::Value;
use std::{
- collections::{BTreeMap, HashMap},
+ collections::{BTreeMap, HashMap, HashSet},
path::PathBuf,
};
@@ -285,6 +285,7 @@ async fn remove_snapshot(
},
id: {
schema: MIRROR_ID_SCHEMA,
+ optional: true,
},
"output-format": {
schema: OUTPUT_FORMAT,
@@ -293,14 +294,55 @@ async fn remove_snapshot(
}
},
)]
-/// Run Garbage Collection on pool
-async fn garbage_collect(config: Option<String>, id: String, _param: Value) -> Result<(), Error> {
+/// Run Garbage Collection on pool(s). If no `id` is specified, the pools of all configured mirrors
+/// will be GCed.
+async fn garbage_collect(
+ config: Option<String>,
+ id: Option<String>,
+ _param: Value,
+) -> Result<(), Error> {
let config = config.unwrap_or_else(get_config_path);
let (config, _digest) = proxmox_offline_mirror::config::config(&config)?;
- let config: MirrorConfig = config.lookup("mirror", &id)?;
- let (count, size) = mirror::gc(&config)?;
+ let (count, size) = if let Some(id) = id {
+ let config: MirrorConfig = config.lookup("mirror", &id)?;
+ mirror::gc(&config)?
+ } else {
+ let mut total_count = 0;
+ let mut total_size = 0;
+ let mut error_count = 0;
+ let mut base_dirs = HashSet::new();
+
+ for mirror_config in config.convert_to_typed_array::<MirrorConfig>("mirror")? {
+ if base_dirs.insert(mirror_config.base_dir.clone()) {
+ match mirror::gc(&mirror_config) {
+ Ok((count, size)) => {
+ println!(
+ "{}: removed {count} files totalling {size}b",
+ mirror_config.id
+ );
+ total_count += count;
+ total_size += size;
+ }
+ Err(err) => {
+ error_count += 1;
+ eprintln!("{}: failed to run GC - {err}", mirror_config.id);
+ }
+ }
+ } else {
+ println!(
+ "{}: base dir '{}' already GCed",
+ mirror_config.id, mirror_config.base_dir
+ );
+ }
+ println!();
+ }
+ if error_count > 0 {
+ eprintln!("Encountered {error_count} errors, please check log.");
+ }
+ (total_count, total_size)
+ };
println!("Removed {} files totalling {}b", count, size);
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied: [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths..
2023-04-04 11:21 [pve-devel] [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths Fabian Grünbichler
2023-04-04 11:21 ` [pve-devel] [PATCH proxmox-offline-mirror 2/2] fix #4261: allow GC for all configured mirrors Fabian Grünbichler
@ 2023-04-06 11:25 ` Thomas Lamprecht
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2023-04-06 11:25 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Grünbichler
Am 04/04/2023 um 13:21 schrieb Fabian Grünbichler:
> a Path(Buf)'s Debug formatting already contains double quotes, no need to quote
> it a second time..
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> src/pool.rs | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied: [PATCH proxmox-offline-mirror 2/2] fix #4261: allow GC for all configured mirrors
2023-04-04 11:21 ` [pve-devel] [PATCH proxmox-offline-mirror 2/2] fix #4261: allow GC for all configured mirrors Fabian Grünbichler
@ 2023-04-06 11:25 ` Thomas Lamprecht
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2023-04-06 11:25 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Grünbichler
Am 04/04/2023 um 13:21 schrieb Fabian Grünbichler:
> by making the --id parameter optional, and structuring the output accordingly.
> since pools are per base-dir, GC only needs to run once per base-dir instead of
> for each mirror entry.
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> src/bin/proxmox_offline_mirror_cmds/mirror.rs | 52 +++++++++++++++++--
> 1 file changed, 47 insertions(+), 5 deletions(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-06 11:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-04 11:21 [pve-devel] [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths Fabian Grünbichler
2023-04-04 11:21 ` [pve-devel] [PATCH proxmox-offline-mirror 2/2] fix #4261: allow GC for all configured mirrors Fabian Grünbichler
2023-04-06 11:25 ` [pve-devel] applied: " Thomas Lamprecht
2023-04-06 11:25 ` [pve-devel] applied: [PATCH proxmox-offline-mirror 1/2] pool: drop redundant quote for paths Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox