From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 610CCA8AE for ; Wed, 30 Aug 2023 10:58:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3F2CA11126 for ; Wed, 30 Aug 2023 10:58:05 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 30 Aug 2023 10:58:04 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1A88D4778B for ; Wed, 30 Aug 2023 10:58:04 +0200 (CEST) Message-ID: <503f1220-e0ad-1023-c2e7-524cb2d3c7c6@proxmox.com> Date: Wed, 30 Aug 2023 10:58:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Content-Language: en-US To: pbs-devel@lists.proxmox.com References: <20230829111310.90248-1-g.goller@proxmox.com> <7dd35be8-86a0-bd3d-d489-d3797a1c0271@proxmox.com> From: Gabriel Goller In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.171 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -1.242 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [group.rs, proxmox.com, main.rs] Subject: Re: [pbs-devel] [PATCH proxmox-backup] close #4763: client: added command to forget backup group X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Aug 2023 08:58:35 -0000 On 8/30/23 09:41, Gabriel Goller wrote: > > On 8/30/23 09:37, Fiona Ebner wrote: >> Am 29.08.23 um 13:13 schrieb Gabriel Goller: >>> diff --git a/Cargo.toml b/Cargo.toml >>> index c7773f0e..e0f12806 100644 >>> --- a/Cargo.toml >>> +++ b/Cargo.toml >>> @@ -264,8 +264,8 @@ proxmox-rrd.workspace = true >>>   #proxmox-sortable-macro = { path = >>> "../proxmox/proxmox-sortable-macro" } >>>   #proxmox-human-byte = { path = "../proxmox/proxmox-human-byte" } >>>   -#proxmox-apt = { path = "../proxmox-apt" } >>> -#proxmox-openid = { path = "../proxmox-openid-rs" } >>> +#proxmox-apt = { path = "../proxmox/proxmox-apt" } >>> +#proxmox-openid = { path = "../proxmox/proxmox-openid" } >>>   #pathpatterns = {path = "../pathpatterns" } >> Should be a separate patch. Each patch should do one thing semantically. >> >>>   #pxar = { path = "../pxar" } >>> diff --git a/proxmox-backup-client/src/group.rs >>> b/proxmox-backup-client/src/group.rs >>> new file mode 100644 >>> index 00000000..84b73b67 >>> --- /dev/null >>> +++ b/proxmox-backup-client/src/group.rs >>> @@ -0,0 +1,68 @@ >>> +use anyhow::{bail, Error}; >>> +use pbs_api_types::{BackupGroup, BackupNamespace}; >>> +use pbs_client::tools::{connect, extract_repository_from_value}; >>> +use proxmox_router::cli::{ask_for_confirmation, CliCommand, >>> CliCommandMap}; >>> +use proxmox_schema::api; >>> +use serde_json::Value; >>> + >> Nit: I think we usually group proxmox includes, pbs includes and other >> includes separately. >> >>> +use crate::{ >>> +    complete_backup_group, complete_namespace, complete_repository, >>> merge_group_into, >>> +    REPO_URL_SCHEMA, >>> +}; >>> + >>> +pub fn group_mgtm_cli() -> CliCommandMap { >> typo: mgtm -> mgmt >> >> (...) >> >>> +    let path = format!("api2/json/admin/datastore/{}/snapshots", >>> repo.store()); >>> +    let result = client.get(&path, Some(api_params.clone())).await?; >>> +    let snapshots = result["data"].as_array().unwrap().len(); >>> +    if snapshots == 0 { >>> +        bail!("Backup group doesn't exist."); >>> +    } >> A group being empty doesn't necessarily mean that it doesn't exist. >> Removing an empty group could also be considered valid, to get rid of >> the owner, right? > > IIRC the group gets automatically deleted if there are no snapshots left > (at least it vanishes from the UI)... > So a group with no snapshots means the group doesn't exist. Correction: no it doesn't. I discussed this with Stefan Sterz and we came to the solution to just try and delete the group even if there are no snapshots in it. This will currently fail because there is this bug open: #3336 (https://bugzilla.proxmox.com/show_bug.cgi?id=3336) (TLDR: locking the OWNER file is difficult). > >>> + >>> +    ask_for_confirmation(format!( >>> +        "Delete group \"{}\" with {} snapshots?", >> Nit: using "snapshot(s)" would also read correctly when it's just 1 >> snapshot >> >>> +        backup_group, snapshots >>> +    ))?; >> The second patch you sent should be sorted first, because it is a >> prerequisite. Please mention that a dependency bump is needed below the >> "---" below the commit message. >> >>> + >>> +    let path = format!("api2/json/admin/datastore/{}/groups", >>> repo.store()); >>> +    let _ = client.delete(&path, Some(api_params)).await?; >>> + >>> +    println!("Successfully deleted group!"); >>> +    Ok(Value::Null) >>> +} >>> diff --git a/proxmox-backup-client/src/main.rs >>> b/proxmox-backup-client/src/main.rs >>> index 1a13291a..76d45b84 100644 >>> --- a/proxmox-backup-client/src/main.rs >>> +++ b/proxmox-backup-client/src/main.rs >>> @@ -72,6 +72,8 @@ mod catalog; >>>   pub use catalog::*; >>>   mod snapshot; >>>   pub use snapshot::*; >>> +mod group; >>> +pub use group::*; >>>   pub mod key; >>>   pub mod namespace; >>>   @@ -1606,7 +1608,6 @@ async fn prune( >>>       } >>>         format_and_print_result_full(&mut data, return_type, >>> &output_format, &options); >>> - >>>       Ok(Value::Null) >>>   } >> This hunk does not belong in this patch either. > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel > >