From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C6DCE1FF13A for ; Wed, 15 Apr 2026 11:21:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8B3B6C38F; Wed, 15 Apr 2026 11:21:39 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 15 Apr 2026 11:21:36 +0200 Message-Id: Subject: Re: [PATCH proxmox-backup 3/7] api: add /nodes/localhost/instance-id From: "Lukas Wagner" To: "Christian Ebner" , "Lukas Wagner" , , X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260413121057.371772-1-l.wagner@proxmox.com> <20260413121057.371772-4-l.wagner@proxmox.com> <2eb14fcc-82c2-4541-835d-0fefbf58467a@proxmox.com> In-Reply-To: <2eb14fcc-82c2-4541-835d-0fefbf58467a@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776244818867 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: IK4QP4VFAE76W6AFQTUIHTW55JXEFQI2 X-Message-ID-Hash: IK4QP4VFAE76W6AFQTUIHTW55JXEFQI2 X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Thanks for the feedback, Chris! On Tue Apr 14, 2026 at 4:23 PM CEST, Christian Ebner wrote: > On 4/13/26 2:11 PM, Lukas Wagner wrote: >> } >> =20 >> +/// Static key used for deriving a unique instance id from `/etc/machi= ne-id` using >> +/// [`proxmox_systemd::sd_id128::get_app_specific_id`]. >> +/// >> +/// This key was generated `systemd-id128 new`. > > nit: ... generated by `systemd-id128 new` Fixed for v2, thanks :) > >> +/// >> +const INSTANCE_ID_KEY: [u8; 16] =3D 0xe5415d9999c146399b8bdae1260e19d2_= u128.to_le_bytes(); >> + >> +#[api( >> + protected: false, > > nit: no need to set this explicitly. ack! > >> + input: { >> + properties: { >> + node: { >> + schema: NODE_SCHEMA, >> + optional: true, >> + }, >> + } >> + }, >> + returns: { >> + type: InstanceId, >> + }, >> + access: { >> + permission: &Permission::Anybody, >> + } >> +)] >> +/// Returns a unique ID for this PBS node. The ID is derived from `/etc= /machine-id`. >> +pub fn get_instance_id() -> Result { >> + let machine_id_derived_app_id =3D >> + proxmox_systemd::sd_id128::get_app_specific_id(INSTANCE_ID_KEY)= ?; >> + let machine_id_derived_app_id =3D hex::encode(machine_id_derived_ap= p_id); >> + >> + Ok(InstanceId { >> + instance_id: machine_id_derived_app_id, > > nit: Could make sense to derive `From` for this on the `InstanceId` itsel= f? > > But do not want to pollute the api-types with dependencies on=20 > proxmox-systemd, so this would only cover the plain id to string=20 > conversion... so not sure if worth it. > I created a struct for this response instead of just returning a string so that it's extensible in the future, in case we want to return more information. With that in mind, the `From` impl does not make that much sense to me, if I'm honest. I think I'd prefer this as is, if that is alright with you? I don't think the `From` helps much when it comes to maintainability nor readability here. >> + }) >> +} >> + >> pub const SUBDIRS: SubdirMap =3D &[ >> ("apt", &apt::ROUTER), >> ("certificates", &certificates::ROUTER), >> ("config", &config::ROUTER), >> ("disks", &disks::ROUTER), >> ("dns", &dns::ROUTER), >> + ( >> + "instance-id", >> + &Router::new().get(&API_METHOD_GET_INSTANCE_ID), >> + ), >> ("journal", &journal::ROUTER), >> ("network", &network::ROUTER), >> ("report", &report::ROUTER),