From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: [pbs-devel] applied: [PATCH proxmox-backup] fix #5801: backup_manager: make api call on datastore update
Date: Fri, 22 Nov 2024 09:17:14 +0100 [thread overview]
Message-ID: <173226343400.2118190.5167435132897081016@yuna.proxmox.com> (raw)
In-Reply-To: <20241018100122.206452-1-g.goller@proxmox.com>
thanks!
Quoting Gabriel Goller (2024-10-18 12:01:22)
> When updating the datastore config using `proxmox-backup-manager` we
> need to make an api-call, because the api-route starts a tokio task to
> update the proxy-cache and the client will kill the task if we don't
> wait. With an api-call the tokio task will be executed on the api
> process and runs in the background while the endpoint handler has
> already returned.
>
> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
>
> Note: this is not so nice, ideally we would like to call every endpoint
> handler directly, but I'm afraid we don't have another choice here.
>
> src/bin/proxmox_backup_manager/datastore.rs | 63 ++++++++++++++++++---
> 1 file changed, 56 insertions(+), 7 deletions(-)
>
> diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs
> index 383bcd242955..3a349451f62a 100644
> --- a/src/bin/proxmox_backup_manager/datastore.rs
> +++ b/src/bin/proxmox_backup_manager/datastore.rs
> @@ -1,15 +1,17 @@
> -use anyhow::Error;
> -use serde_json::Value;
> -
> +use pbs_api_types::{
> + DataStoreConfig, DataStoreConfigUpdater, DATASTORE_SCHEMA, PROXMOX_CONFIG_DIGEST_SCHEMA,
> +};
> +use pbs_client::view_task_result;
> use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
> use proxmox_schema::api;
>
> -use pbs_api_types::{DataStoreConfig, DATASTORE_SCHEMA, PROXMOX_CONFIG_DIGEST_SCHEMA};
> -use pbs_client::view_task_result;
> -
> use proxmox_backup::api2;
> +use proxmox_backup::api2::config::datastore::DeletableProperty;
> use proxmox_backup::client_helpers::connect_to_localhost;
>
> +use anyhow::Error;
> +use serde_json::Value;
> +
> #[api(
> input: {
> properties: {
> @@ -139,6 +141,53 @@ async fn delete_datastore(mut param: Value, rpcenv: &mut dyn RpcEnvironment) ->
> Ok(())
> }
>
> +#[api(
> + protected: true,
> + input: {
> + properties: {
> + name: {
> + schema: DATASTORE_SCHEMA,
> + },
> + update: {
> + type: DataStoreConfigUpdater,
> + flatten: true,
> + },
> + delete: {
> + description: "List of properties to delete.",
> + type: Array,
> + optional: true,
> + items: {
> + type: DeletableProperty,
> + }
> + },
> + digest: {
> + optional: true,
> + schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
> + },
> + "output-format": {
> + schema: OUTPUT_FORMAT,
> + optional: true,
> + },
> + },
> + },
> +)]
> +/// Update datastore configuration.
> +async fn update_datastore(name: String, mut param: Value) -> Result<(), Error> {
> + let output_format = extract_output_format(&mut param);
> + let client = connect_to_localhost()?;
> +
> + let result = client
> + .put(
> + format!("api2/json/config/datastore/{name}").as_str(),
> + Some(param),
> + )
> + .await?;
> +
> + view_task_result(&client, result, &output_format).await?;
> +
> + Ok(())
> +}
> +
> pub fn datastore_commands() -> CommandLineInterface {
> let cmd_def = CliCommandMap::new()
> .insert("list", CliCommand::new(&API_METHOD_LIST_DATASTORES))
> @@ -154,7 +203,7 @@ pub fn datastore_commands() -> CommandLineInterface {
> )
> .insert(
> "update",
> - CliCommand::new(&api2::config::datastore::API_METHOD_UPDATE_DATASTORE)
> + CliCommand::new(&API_METHOD_UPDATE_DATASTORE)
> .arg_param(&["name"])
> .completion_cb("name", pbs_config::datastore::complete_datastore_name)
> .completion_cb(
> --
> 2.39.5
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
prev parent reply other threads:[~2024-11-22 8:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 10:01 [pbs-devel] " Gabriel Goller
2024-11-22 8:17 ` Fabian Grünbichler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=173226343400.2118190.5167435132897081016@yuna.proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.