public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Lukas Wagner" <l.wagner@proxmox.com>
To: "Christian Ebner" <c.ebner@proxmox.com>,
	"Lukas Wagner" <l.wagner@proxmox.com>,
	<pbs-devel@lists.proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH proxmox-backup 3/7] api: add /nodes/localhost/instance-id
Date: Wed, 15 Apr 2026 11:21:36 +0200	[thread overview]
Message-ID: <DHTM9KA2BYHV.269ZKEHEQV7SF@proxmox.com> (raw)
In-Reply-To: <2eb14fcc-82c2-4541-835d-0fefbf58467a@proxmox.com>

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<InstanceId, Error> {
>> +    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.

>> +    })
>> +}
>> +
>>   pub const SUBDIRS: SubdirMap = &[
>>       ("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),





  reply	other threads:[~2026-04-15  9:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 12:10 [RFC common/proxmox{,-backup}/storage 0/7] establish unique instance-id for PBS nodes Lukas Wagner
2026-04-13 12:10 ` [PATCH proxmox 1/7] pbs-api-types: add InstanceId response type Lukas Wagner
2026-04-13 12:10 ` [PATCH proxmox 2/7] systemd: add support for machine-id generation Lukas Wagner
2026-04-13 12:10 ` [PATCH proxmox-backup 3/7] api: add /nodes/localhost/instance-id Lukas Wagner
2026-04-14 14:23   ` Christian Ebner
2026-04-15  9:21     ` Lukas Wagner [this message]
2026-04-15  9:26       ` Christian Ebner
2026-04-13 12:10 ` [PATCH proxmox-backup 4/7] client: add 'instance-id' sub-command Lukas Wagner
2026-04-13 13:26   ` Shannon Sterz
2026-04-13 13:39     ` Lukas Wagner
2026-04-14 14:30   ` Christian Ebner
2026-04-13 12:10 ` [PATCH proxmox-backup 5/7] manager: add instance-id subcommand Lukas Wagner
2026-04-13 13:26   ` Shannon Sterz
2026-04-13 13:38     ` Lukas Wagner
2026-04-13 12:10 ` [PATCH common 6/7] pbs-client: add support for the 'instance id' command Lukas Wagner
2026-04-13 12:10 ` [PATCH pve-storage 7/7] api: add /nodes/<node>/storage/<storage>/instance-id route Lukas Wagner
2026-04-13 13:26   ` Shannon Sterz
2026-04-13 13:37     ` Lukas Wagner
2026-04-14 14:38   ` Christian Ebner
2026-04-15  8:41     ` Lukas Wagner
2026-04-15  8:44       ` Christian Ebner
2026-04-14 14:45 ` [RFC common/proxmox{,-backup}/storage 0/7] establish unique instance-id for PBS nodes Christian Ebner

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=DHTM9KA2BYHV.269ZKEHEQV7SF@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=pve-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