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 267F21FF13A for ; Wed, 15 Apr 2026 11:26:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EF980C80A; Wed, 15 Apr 2026 11:26:16 +0200 (CEST) Message-ID: <6f05169c-2959-47e0-8e09-252d782d74d8@proxmox.com> Date: Wed, 15 Apr 2026 11:26:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH proxmox-backup 3/7] api: add /nodes/localhost/instance-id To: Lukas Wagner , pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com References: <20260413121057.371772-1-l.wagner@proxmox.com> <20260413121057.371772-4-l.wagner@proxmox.com> <2eb14fcc-82c2-4541-835d-0fefbf58467a@proxmox.com> Content-Language: en-US, de-DE From: Christian Ebner In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776245096398 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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: 4FBKXSZCHLXSAUM3SJXENK2OYNSV5NTC X-Message-ID-Hash: 4FBKXSZCHLXSAUM3SJXENK2OYNSV5NTC X-MailFrom: c.ebner@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: On 4/15/26 11:20 AM, Lukas Wagner wrote: > 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: >>> } >>> >>> +/// Static key used for deriving a unique instance id from `/etc/machine-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] = 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 = >>> + proxmox_systemd::sd_id128::get_app_specific_id(INSTANCE_ID_KEY)?; >>> + let machine_id_derived_app_id = hex::encode(machine_id_derived_app_id); >>> + >>> + Ok(InstanceId { >>> + instance_id: machine_id_derived_app_id, >> >> nit: Could make sense to derive `From` for this on the `InstanceId` itself? >> >> But do not want to pollute the api-types with dependencies on >> proxmox-systemd, so this would only cover the plain id to string >> 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. Yes, fine by me. No hard feelings was just wondering if we do want to protect from creating a unexpected instance id from a plain string.