Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate the unique machine-id from mac address #13061

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kuanyu99
Copy link
Contributor

Why I did it

  1. The machine-id is generated during the building process and will be copied to each installed device. So each device will have the same id.
  2. The machine-id will be different for each different image on the same device.

How I did it

  1. Generate the machine-id from the eth0 MAC address during initializing the ram-file system
  2. Use symbolic files target to the /run/machine-id to replace original /etc/machine-id and /var/lib/dbus/machine-id
  3. Due to the existence of the symbolic files, the SONiC boot up process will be consistent after this commit. If the Linux system detect /etc/machine-id missing, it will trigger its first boot mechanism.

How to verify it

After the change, the behavior will be:

  1. The machine-id will be different for each device with the same version image.
  2. The machine-id will be the same for each different image on the same device.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211

This change can fit to any release which using build_debian.sh to build the SONiC image.

Description for the changelog

  • Originally, the machine-id is generated randomly during the building process. And will be copied to each device during installing.
  • After this, the machine-id will be generated according to mac address which is unique for each device. And will be consistent even installing new image.

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

* Originally, the machine-id is generated randomly during the building
  process. And will be copied to each device during installing.
* After this, the machine-id will be generated according to mac address
  which is unique for each device. And will be consistent even installing
  new image.
@lguohan
Copy link
Collaborator

lguohan commented Dec 16, 2022

it is unclear what the machine id is used for, why unique machine id is needed.

@kuanyu99
Copy link
Contributor Author

From the man page, https://manpages.ubuntu.com/manpages/kinetic/en/man5/machine-id.5.html
It should be unique for the local system.
And it is also a requirement from our users.

@lguohan
Copy link
Collaborator

lguohan commented Dec 17, 2022

i cannot agree with on current approach to use mac address and make it consistent across installation.

check the machine-id here.

https://wiki.debian.org/MachineId

It's intended as an opaque, non-human-meaningful, persistent unique identifier for a machine (or more precisely an OS installation), used as a lookup key in state/configuration storage in the same sorts of places you might be tempted to use a hostname.

generating machine-id during installation makes sense

@kuanyu99
Copy link
Contributor Author

i cannot agree with on current approach to use mac address and make it consistent across installation.

check the machine-id here.

https://wiki.debian.org/MachineId

It's intended as an opaque, non-human-meaningful, persistent unique identifier for a machine (or more precisely an OS installation), used as a lookup key in state/configuration storage in the same sorts of places you might be tempted to use a hostname.

generating machine-id during installation makes sense

Regarding this page, I think the machine-id should be different for each version SONiC on a device.
So, instead of generating from MAC address, using a random 16 bytes id is a preferable way, right?

@CharlieChenEC
Copy link
Contributor

CharlieChenEC commented Dec 27, 2022

Hi @lguohan

i cannot agree with on current approach to use mac address and make it consistent across installation.

check the machine-id here.

https://wiki.debian.org/MachineId

It's intended as an opaque, non-human-meaningful, persistent unique identifier for a machine (or more precisely an >OS installation), used as a lookup key in state/configuration storage in the same sorts of places you might be >tempted to use a hostname.

generating machine-id during installation makes sense

Actually, there is no restriction on the method to generate machine-id and no clear regulation on the life cycle of a machine-id. I think the description in https://wiki.debian.org/MachineId tells you what 'machine-id' is for and when it is generated in general, which can be considered as a guidance but not a regulation.

In https://alexforencich.com/wiki/en/linux/nfs_unique_machineid, it describes the way to generate a unique machine id in 'initramfs' stage on the machine that uses NFS as its root file system.

What is your concern if we generate the machine-id during 'initramfs' stage instead of on the 'installation' stage?

And what is your concern if the machine-id is consistent across installation? Do you have any scenario in your mind that it might cause problems if the machine-id is consistent across installation?

@CharlieChenEC
Copy link
Contributor

Hi @lguohan,

May I have your comment on the solution for machine-id generation on SONiC?

I think it's OK to revise the PR to generate machine-id during the installation stage.

What about the part on the content of 'machine-id'? If you think it should not use 'mac address' to generate 'machine-id'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants