public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Shan Shaji" <s.shaji@proxmox.com>
To: "Lukas Wagner" <l.wagner@proxmox.com>, <pdm-devel@lists.proxmox.com>
Subject: Re: [PATCH datacenter-manager v2 1/4] cli: admin: make cli handling async
Date: Fri, 06 Feb 2026 13:56:40 +0100	[thread overview]
Message-ID: <DG7W972KEQIK.WTA8Y9WFXX8P@proxmox.com> (raw)
In-Reply-To: <DG73IX3J3NEI.6QUK9BL7ZA5Q@proxmox.com>

Hi Lukas, thank you so much for the nice feedbacks. I will apply some
of the changes in my v3 and the improvements that you mentioned in
a follow up series. 

some comments inline. 

On Thu Feb 5, 2026 at 3:25 PM CET, Lukas Wagner wrote:
> Hi Shan,
>

[...]

>>      )
>> -    .expect("failed to setup access control config");
>> -
>> +    .context("failed to setup access control config")?;
>>      proxmox_log::Logger::from_env("PDM_LOG", proxmox_log::LevelFilter::INFO)
>>          .stderr()
>>          .init()
>> -        .expect("failed to set up logger");
>> +        .context("failed to set-up logger")?;
>
> The string here changed, the original version seems to be more correct
> to me

I will change it back to "set up". Thank You!

>>  
>> -    server::context::init().expect("could not set up server context");
>> +    server::context::init().context("could not set-up server context")?;
>>  
>>      let cmd_def = CliCommandMap::new()
>>          .insert("remote", remotes::cli())
>> @@ -40,14 +38,33 @@ fn main() {
>>          .insert("support-status", support_status::cli())
>>          .insert("versions", CliCommand::new(&API_METHOD_GET_VERSIONS));
>>  
>> +    let args: Vec<String> = std::env::args().collect();
>> +    let avoid_init = args.len() >= 2 && (args[1] == "bashcomplete" || args[1] == "printdoc");
>
> For what it's worth, this could be
>
>     let avoid_init = matches!(
>         args.get(1).map(String::as_str),
>         Some("bashcomplete") | Some("printdoc")
>     );
> or
>
>     let avoid_init = args
>         .get(1)
>         .is_some_and(|c| c == "bashcomplete" || c == "printdoc");
>
> It's not really shorter, but I think they would be a bit more idiomatic.
>
> The original version relies on the short-circuit behavior of the &&
> operator to avoid the panic when accessing the array element via the
> index operator, which is of course correct, but I think this can be
> written a bit nicer.
>
> no hard feelings, so just pick whichever version you like most.

I would go with the `matches!` macro. Thank you!

>> +
>> +    if !avoid_init {
>> +        let file_opts = CreateOptions::new().owner(api_user.uid).group(api_user.gid);
>> +        proxmox_rest_server::init_worker_tasks(pdm_buildcfg::PDM_LOG_DIR_M!().into(), file_opts)
>> +            .context("failed to initialize worker tasks")?;
>> +
>> +        let mut command_sock = proxmox_daemon::command_socket::CommandSocket::new(api_user.gid);
>> +        proxmox_rest_server::register_task_control_commands(&mut command_sock)
>> +            .context("failed to register task control commands")?;
>> +        command_sock
>> +            .spawn(proxmox_rest_server::last_worker_future())
>> +            .context("failed to activate the socket")?;
>> +    }
>> +
>>      let mut rpcenv = CliEnvironment::new();
>>      rpcenv.set_auth_id(Some("root@pam".into()));
>>  
>> -    run_cli_command(
>> -        cmd_def,
>> -        rpcenv,
>> -        Some(|future| proxmox_async::runtime::main(future)),
>> -    );
>> +    run_async_cli_command(cmd_def, rpcenv).await;
>> +
>> +    Ok(())
>> +}
>> +
>> +fn main() -> Result<(), Error> {
>> +    //pbs_tools::setup_libc_malloc_opts(); // TODO: move from PBS to proxmox-sys and uncomment
>> +    proxmox_async::runtime::main(run())
>>  }
>>  
>>  #[api(




  reply	other threads:[~2026-02-06 12:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 17:50 [PATCH datacenter-manager v2 0/4] fix #7179: expose ACME commands inside admin CLI Shan Shaji
2026-02-03 17:50 ` [PATCH datacenter-manager v2 1/4] cli: admin: make cli handling async Shan Shaji
2026-02-05 14:25   ` Lukas Wagner
2026-02-06 12:56     ` Shan Shaji [this message]
2026-02-03 17:50 ` [PATCH datacenter-manager v1 2/4] api: acme: define API type for ACME registration parameters Shan Shaji
2026-02-05 14:25   ` Lukas Wagner
2026-02-03 17:51 ` [PATCH datacenter-manager v2 3/4] fix #7179: cli: admin: expose acme commands Shan Shaji
2026-02-05 14:26   ` Lukas Wagner
2026-02-03 17:51 ` [PATCH datacenter-manager v2 4/4] chore: update proxmox-acme version to 1 Shan Shaji
2026-02-05 14:25 ` [PATCH datacenter-manager v2 0/4] fix #7179: expose ACME commands inside admin CLI Lukas Wagner

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=DG7W972KEQIK.WTA8Y9WFXX8P@proxmox.com \
    --to=s.shaji@proxmox.com \
    --cc=l.wagner@proxmox.com \
    --cc=pdm-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal