[pbs-devel] [RFC proxmox 1/3] new proxmox-server-config crate

Dominik Csapak d.csapak at proxmox.com
Mon Oct 30 12:05:58 CET 2023

On 10/25/23 18:38, Thomas Lamprecht wrote:
> Would name it "proxmox-rest-server-config" or "proxmox-api-config", and here
> I'm asking myself (without really trying to answer it myself): why isn't
> this part of proxmox-rest-server, it's only relevant when used in combination
> of there, simply to allow use-sites that do not depend on the rest of that
> crates code?

you're right that it's currently only used together with the 
rest-server, but i though it might bite us in the future if we put that 
together. We might want to have some daemons that does not have a rest
part in the future?
e.g. like we now have a few of them in PVE (pvestatd, qmeventd, spiceproxy)

also having more smaller crates does improve compile time for boxes
with many cores (not really an argument for or against, just a side effect)

> Also, mostly important for  the other two crates: did you check the history
> of the files you mode? If there's anything relevant, I'd favor isolating that
> and then merging it in, like I did when splitting out rest-server, but it can
> sometimes be a bit of a PITA, so  can be decided case-by-case for those new
> crates..

i'll look into it. I did not spend much time on such things for the RFC.
just wanted to see how others feel about the general approach

> Am 18/10/2023 um 12:39 schrieb Dominik Csapak:
>> diff --git a/proxmox-server-config/src/lib.rs b/proxmox-server-config/src/lib.rs
>> new file mode 100644
>> index 0000000..8377978
>> --- /dev/null
>> +++ b/proxmox-server-config/src/lib.rs
>> @@ -0,0 +1,302 @@
>> +//! A generic server config abstraction
>> +//!
>> +//! Used for proxmox daemons to have a central point for configuring things
> "Used for API daemons of Proxmox projects as a central point for configuring their
> base environment, like ..."
> (Proxmox is our TM and is not a project itself)

yes, of course

>> +//! like base/log/task/certificate directories, user for creating files, etc.
>> +
>> +use std::os::linux::fs::MetadataExt;
>> +use std::path::{Path, PathBuf};
>> +use std::sync::OnceLock;
>> +
>> +use anyhow::{format_err, Context, Error};
>> +use nix::unistd::User;
>> +
>> +use proxmox_sys::fs::{create_path, CreateOptions};
> this alone here is probably causing 90% compile time ^^
> we really need to split proxmox-sys more, but that's orthogonal to this
> series
true, IMHO at least the 'fs' part would warrant it's own crate

>> +
>> +pub struct ServerConfig {
> Lacks doc comments for members, please add some even if they're
> private.


>> +    name: String,
>> +    base_dir: PathBuf,
>> +    user: User,
>> +    privileged_user: OnceLock<User>,
>> +
>> +    task_dir: OnceLock<PathBuf>,
> not sure if this should be an option, e.g., for simple CRUD
> API daemons there might not be any worker tasks at all.

that's one reason i used OnceLock, since it's only created when either
one sets it manually, or access it the first time

but Option would work too ofc if that's preferred

>> +    log_dir: OnceLock<PathBuf>,
> maybe: access_log_dir (as this is the api access log that other

if we move it to rest server i agree, but otherwise i'd leave it more
generic (other daemons might have logging needs besides the access log)

>> +    cert_dir: OnceLock<PathBuf>,
>> +    state_dir: OnceLock<PathBuf>,
>> +    run_dir: OnceLock<PathBuf>,
>> +    config_dir: OnceLock<PathBuf>,
>> +}
>> +

More information about the pbs-devel mailing list