From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 14B951FF13F for ; Thu, 12 Mar 2026 17:17:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BB0041EFCA; Thu, 12 Mar 2026 17:17:51 +0100 (CET) Message-ID: Date: Thu, 12 Mar 2026 17:17:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH proxmox-backup v4 4/7] api: add PUT endpoint for move_group To: Hannes Laimer , pbs-devel@lists.proxmox.com References: <20260311151315.133637-1-h.laimer@proxmox.com> <20260311151315.133637-5-h.laimer@proxmox.com> Content-Language: en-US, de-DE From: Christian Ebner In-Reply-To: <20260311151315.133637-5-h.laimer@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773332227078 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.008 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 RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.408 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.819 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.903 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: UA53NPQ543FVOSXP5KGJJFZVY5FVMNAY X-Message-ID-Hash: UA53NPQ543FVOSXP5KGJJFZVY5FVMNAY X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: One note inline. On 3/11/26 4:13 PM, Hannes Laimer wrote: > Requires DATASTORE_MODIFY on both the source and target namespaces. > > Signed-off-by: Hannes Laimer > --- > src/api2/admin/datastore.rs | 76 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 75 insertions(+), 1 deletion(-) > > diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs > index cca34055..77a88e51 100644 > --- a/src/api2/admin/datastore.rs > +++ b/src/api2/admin/datastore.rs > @@ -69,7 +69,9 @@ use proxmox_rest_server::{formatter, worker_is_active, WorkerTask}; > > use crate::api2::backup::optional_ns_param; > use crate::api2::node::rrd::create_value_from_rrd; > -use crate::backup::{check_ns_privs_full, ListAccessibleBackupGroups, VerifyWorker, NS_PRIVS_OK}; > +use crate::backup::{ > + check_ns_privs, check_ns_privs_full, ListAccessibleBackupGroups, VerifyWorker, NS_PRIVS_OK, > +}; > use crate::server::jobstate::{compute_schedule_status, Job, JobState}; > use crate::tools::{backup_info_to_snapshot_list_item, get_all_snapshot_files, read_backup_index}; > > @@ -278,6 +280,77 @@ pub async fn delete_group( > .await? > } > > +#[api( > + input: { > + properties: { > + store: { schema: DATASTORE_SCHEMA }, > + ns: { > + type: BackupNamespace, > + optional: true, > + }, > + group: { > + type: pbs_api_types::BackupGroup, > + flatten: true, > + }, > + "new-ns": { > + type: BackupNamespace, > + }, > + }, > + }, > + returns: { > + schema: UPID_SCHEMA, > + }, > + access: { > + permission: &Permission::Anybody, > + description: "Requires DATASTORE_MODIFY on both the source and target namespace.", > + }, > +)] > +/// Move a backup group to a different namespace within the same datastore. > +pub fn move_group( > + store: String, > + ns: Option, > + group: pbs_api_types::BackupGroup, > + new_ns: BackupNamespace, > + rpcenv: &mut dyn RpcEnvironment, > +) -> Result { > + let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?; > + let ns = ns.unwrap_or_default(); > + > + check_ns_privs(&store, &ns, &auth_id, PRIV_DATASTORE_MODIFY)?; > + check_ns_privs(&store, &new_ns, &auth_id, PRIV_DATASTORE_MODIFY)?; > + > + let datastore = DataStore::lookup_datastore(&store, Some(Operation::Write))?; Please note that the operation parameter to DataStore::lookup_datastore() has been made non-optional in a very recent change [0] applied after you send the patch series. Please adapt this accordingly for a new version of the patch series, thanks! [0] https://git.proxmox.com/?p=proxmox-backup.git;a=commit;h=c0a9b6513a065ae0a1dc92e4b8c22721db752023 > + > + // Best-effort pre-checks for a fast synchronous error before spawning a worker. > + if ns == new_ns { > + bail!("source and target namespace must be different"); > + } > + if !datastore.namespace_exists(&new_ns) { > + bail!("target namespace '{new_ns}' does not exist"); > + } > + let source_group = datastore.backup_group(ns.clone(), group.clone()); > + if !source_group.exists() { > + bail!("group '{group}' does not exist in namespace '{ns}'"); > + } > + let target_group = datastore.backup_group(new_ns.clone(), group.clone()); > + if target_group.exists() { > + bail!("group '{group}' already exists in target namespace '{new_ns}'"); > + } > + > + let worker_id = format!("{store}:{ns}:{group}"); > + let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI; > + > + let upid_str = WorkerTask::new_thread( > + "move-group", > + Some(worker_id), > + auth_id.to_string(), > + to_stdout, > + move |_worker| datastore.move_group(&ns, &group, &new_ns), > + )?; > + > + Ok(json!(upid_str)) > +} > + > #[api( > input: { > properties: { > @@ -2828,6 +2901,7 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[ > "groups", > &Router::new() > .get(&API_METHOD_LIST_GROUPS) > + .put(&API_METHOD_MOVE_GROUP) > .delete(&API_METHOD_DELETE_GROUP), > ), > ("mount", &Router::new().post(&API_METHOD_MOUNT)),