Skip to content

Conversation

@Sukuna0007Abhi
Copy link
Contributor

@Sukuna0007Abhi Sukuna0007Abhi commented Sep 23, 2025

Title: feat: Remove dependency on machine-id

Description:
This PR implements a flexible node ID generation system to remove the hard dependency on systemd's machine-id. The new system provides multiple fallback methods to ensure reliable node identification across different environments.

Implementation details:

  1. Tries to read from a persistent node ID file (/var/lib/veraison/veraison-node-id)
  2. Falls back to MAC address from the first available non-loopback interface
  3. Falls back to machine-id (maintains compatibility with systemd systems)
  4. Finally generates and persists a random node ID

Key improvements:

  • More portable: Works on non-systemd Linux systems
  • Persistent: Node ID remains stable across restarts
  • Flexible: Multiple fallback methods ensure reliability
  • Configurable: Node ID directory can be customized via VERAISON_NODE_ID_DIR

Added new files:

  • nodeid.go: Core implementation with multiple ID generation methods
  • nodeid_test.go: Comprehensive unit tests for all scenarios

Modified:

  • handler.go: Updated to use the new node ID implementation

This makes the verification service more portable and removes the hard dependency on systemd's machine-id while maintaining backward compatibility.

Fixes #124

Ready for Review sir @thomas-fossati @setrofim @yogeshbdeshpande

Implements a flexible node ID generation system that:
1. Tries to read from a persistent node ID file
2. Falls back to MAC address from network interface
3. Falls back to machine-id (for systemd systems)
4. Finally generates and persists a random node ID

This makes the verification service more portable and removes
the hard dependency on systemd's machine-id.

Fixes veraison#124

Signed-off-by: Sukuna0007Abhi <[email protected]>
@Sukuna0007Abhi
Copy link
Contributor Author

Pls review in your free time sir @setrofim sir @yogeshbdeshpande sir @thomas-fossati


// getMACBasedID returns a node ID based on the MAC address of the first
// available non-loopback interface
func getMACBasedID() ([]byte, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am hesitant about this.

  • The order of inteface may change (e.g. if someone adds a PCI network card to their machine).
  • In virtualized environments, MAC cannot be rilied on to be sufficiently unique.

I think might be better to remove this.


// generateRandomNodeID creates a random node ID
func generateRandomNodeID() ([]byte, error) {
id := make([]byte, nodeIDLength)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already depend on github.com/google/uuid, instead of doing this, you could just do uuid.New()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sir @setrofim will think about it

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.

Dependency on machine-id

2 participants