[pbs-devel] [PATCH proxmox-backup v12 11/26] bin: manager: add (un)mount command
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Oct 30 11:13:39 CET 2024
Quoting Hannes Laimer (2024-10-29 16:40:22)
> On Mon Oct 14, 2024 at 3:42 PM CEST, Fabian Grünbichler wrote:
> > On September 4, 2024 4:11 pm, Hannes Laimer wrote:
> > > Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> > > ---
> > > pbs-config/src/datastore.rs | 14 ++++
> > > src/bin/proxmox_backup_manager/datastore.rs | 76 ++++++++++++++++++++-
> > > 2 files changed, 89 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/pbs-config/src/datastore.rs b/pbs-config/src/datastore.rs
> > > index dc5bb3da..396dcb37 100644
> > > --- a/pbs-config/src/datastore.rs
> > > +++ b/pbs-config/src/datastore.rs
> > > @@ -62,6 +62,20 @@ pub fn complete_datastore_name(_arg: &str, _param: &HashMap<String, String>) ->
> > > }
> > > }
> > >
> > > +pub fn complete_removable_datastore_name(
> > > + _arg: &str,
> > > + _param: &HashMap<String, String>,
> > > +) -> Vec<String> {
> > > + match config() {
> > > + Ok((data, _digest)) => data
> > > + .sections
> > > + .into_iter()
> > > + .filter_map(|(name, (_, c))| c.get("backing-device").map(|_| name))
> >
> > nit: I'd prefer `.and(Some(name))`` instead of mapping just to throw the
> > value away
> >
> > > + .collect(),
> > > + Err(_) => Vec::new(),
> > > + }
> > > +}
> > > +
> > > pub fn complete_acl_path(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
> > > let mut list = vec![
> > > String::from("/"),
> > > diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs
> > > index 383bcd24..f2795b39 100644
> > > --- a/src/bin/proxmox_backup_manager/datastore.rs
> > > +++ b/src/bin/proxmox_backup_manager/datastore.rs
> > > @@ -1,4 +1,4 @@
> > > -use anyhow::Error;
> > > +use anyhow::{format_err, Error};
> > > use serde_json::Value;
> > >
> > > use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
> > > @@ -40,6 +40,34 @@ fn list_datastores(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Valu
> > > Ok(Value::Null)
> > > }
> > >
> > > +#[api(
> > > + protected: true,
> > > + input: {
> > > + properties: {
> > > + store: {
> > > + schema: DATASTORE_SCHEMA,
> > > + },
> > > + digest: {
> > > + optional: true,
> > > + schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
> > > + },
> > > + },
> > > + },
> > > +)]
> > > +/// Mount a removable datastore.
> > > +async fn mount_datastore(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> {
> >
> > why can't this just delegate directly to the API endpoint? (if there is
> > a reason, it would be nice to mention such things in the commit
> > message..)
> >
>
> The mounting is done by a worker, and this worker has its parent (the CLI bin)
> killed once it started the worker and finished. [1]
>
> [1] https://lore.proxmox.com/pbs-devel/2bcb9be3-b4cf-450b-8cf1-1e74b49a58f2@proxmox.com/#t
ah, we ran into that recently with some other datastore maintenance related
task.
seems like this could/should be fixed in the CLI handler? but in the meantime,
if you need to workaround such limitations note them somewhere please..
More information about the pbs-devel
mailing list