From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 2E8671FF168
	for <inbox@lore.proxmox.com>; Tue,  4 Feb 2025 15:42:12 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 6DED319504;
	Tue,  4 Feb 2025 15:42:11 +0100 (CET)
Message-ID: <07521ee7-c6ea-4b83-a09c-21d22400155e@proxmox.com>
Date: Tue, 4 Feb 2025 15:41:37 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>, Hannes Laimer <h.laimer@proxmox.com>
References: <20250116064543.74619-1-h.laimer@proxmox.com>
 <20250116064543.74619-6-h.laimer@proxmox.com>
Content-Language: en-US, de-DE
From: Christian Ebner <c.ebner@proxmox.com>
In-Reply-To: <20250116064543.74619-6-h.laimer@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.031 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_VALIDITY_CERTIFIED_BLOCKED 0.001 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.001 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.001 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
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [datastore.rs]
Subject: Re: [pbs-devel] [PATCH proxmox-backup 5/7] bin: manager: run
 uuid_mount/mount tasks on the proxy
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

comments inline

On 1/16/25 07:45, Hannes Laimer wrote:
> Use the API instead of running uuid_mount/mount directly in the CLI binary.
> This ensures that all triggered tasks are handled by the proxy process.
> 
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
>   src/bin/proxmox_backup_manager/datastore.rs | 42 +++++++++++++--------
>   1 file changed, 27 insertions(+), 15 deletions(-)
> 
> diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs
> index 1922a55a2..50a07c03a 100644
> --- a/src/bin/proxmox_backup_manager/datastore.rs
> +++ b/src/bin/proxmox_backup_manager/datastore.rs
> @@ -49,24 +49,31 @@ fn list_datastores(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
>               store: {
>                   schema: DATASTORE_SCHEMA,
>               },
> -            digest: {

Why is digest removed here? This parameter should stay as otherwise it 
is a breaking api change. If this has to be removed, the reason should 
be mentioned in the commit message.

> +            "output-format": {
> +                schema: OUTPUT_FORMAT,
>                   optional: true,
> -                schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
>               },
>           },
>       },
>   )]
>   /// Mount a removable datastore.
> -async fn mount_datastore(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
> -    param["node"] = "localhost".into();
> +async fn mount_datastore(
> +    store: String,
> +    mut param: Value,
> +    _rpcenv: &mut dyn RpcEnvironment,
> +) -> Result<(), Error> {
> +    let output_format = extract_output_format(&mut param);
>   
> -    let info = &api2::admin::datastore::API_METHOD_MOUNT;
> -    let result = match info.handler {
> -        ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
> -        _ => unreachable!(),
> -    };
> +    let client = connect_to_localhost()?;
> +    let result = client
> +        .post(
> +            format!("api2/json/admin/datastore/{}/mount", store).as_str(),

nit: store can be in-lined into the format string

> +            None,
> +        )
> +        .await?;
> +
> +    view_task_result(&client, result, &output_format).await?;
>   
> -    crate::wait_for_local_worker(result.as_str().unwrap()).await?;
>       Ok(())
>   }
>   
> @@ -252,10 +259,6 @@ async fn update_datastore(name: String, mut param: Value) -> Result<(), Error> {
>                   type: String,
>                   description: "The UUID of the device that should be mounted",
>               },
> -            "output-format": {

Breaking change, can be avoided?

> -                schema: OUTPUT_FORMAT,
> -                optional: true,
> -            },
>           },
>       },
>   )]
> @@ -282,7 +285,16 @@ async fn uuid_mount(param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result<Va
>       }
>   
>       if let Some(store) = matching_stores.first() {
> -        api2::admin::datastore::do_mount_device(store.clone())?;
> +        let client = connect_to_localhost()?;
> +        let result = client
> +            .post(
> +                format!("api2/json/admin/datastore/{}/mount", store.name).as_str(),
> +                None,
> +            )
> +            .await?;
> +
> +        view_task_result(&client, result, "json").await?;

this could get the output format as obtained via the get_output_format 
helper instead of being json only? Analog to the other api endpoints.

> +        return Ok(Value::Null);
>       }
>   
>       // we don't want to fail for UUIDs that are not associated with datastores, as that produces



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel