[pdm-devel] [PATCH datacenter-manager 1/3] cli: admin: make cli handling async
Shan Shaji
s.shaji at proxmox.com
Tue Jan 27 12:27:20 CET 2026
On Tue Jan 27, 2026 at 10:17 AM CET, Lukas Wagner wrote:
> Hi Shan, thanks for these patches!
>
> Some comments inline.
>
> On Fri Jan 23, 2026 at 6:29 PM CET, Shan Shaji wrote:
>> worker tasks.
>>
>> Since `init_worker_tasks` needs to be called from an async runtime.
>> Moved the content of the main function to async `run` function and
>> wrapped using `proxmox_async::runtime::main`, which creates a Tokio
>> runtime.
>>
>> Signed-off-by: Shan Shaji <s.shaji at proxmox.com>
>> ---
>> cli/admin/Cargo.toml | 3 +++
[...]
>> mod remotes;
>> mod support_status;
>>
>> -fn main() {
>> - //pbs_tools::setup_libc_malloc_opts(); // TODO: move from PBS to proxmox-sys and uncomment
>> -
>> - let api_user = pdm_config::api_user().expect("cannot get api user");
>> - let priv_user = pdm_config::priv_user().expect("cannot get privileged user");
>> - proxmox_product_config::init(api_user, priv_user);
>> +async fn run() -> Result<(), Error> {
>> + let api_user = pdm_config::api_user()?;
>> + let priv_user = pdm_config::priv_user()?;
>
> if you convert these .expect("...") calls to errors and bubble them up,
> if would be nice if you used .context() from anyhow to preserve the
> error messages. E.g.:
>
>
> let priv_user = pdm_config::priv_user().context("could not get privileged user")?;
Sure will udpate it.
>>
>> + proxmox_product_config::init(api_user.clone(), priv_user);
>> proxmox_access_control::init::init(
>> &pdm_api_types::AccessControlConfig,
>> pdm_buildcfg::configdir!("/access"),
>> - )
>> - .expect("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");
>> + .init()?;
>>
>> - server::context::init().expect("could not set up server context");
>> + server::context::init()?;
>>
>> let cmd_def = CliCommandMap::new()
>> .insert("remote", remotes::cli())
>> @@ -40,14 +36,29 @@ fn main() {
>> .insert("support-status", support_status::cli())
>> .insert("versions", CliCommand::new(&API_METHOD_GET_VERSIONS));
>>
[...]
More information about the pdm-devel
mailing list