From 3db960c502ad486cd1b107cdff267961bb8450a6 Mon Sep 17 00:00:00 2001 From: CMGS Date: Fri, 3 Jul 2026 22:22:17 +0800 Subject: [PATCH] fix(agent): fall back to random machine-id when systemd-machine-id-setup fails regenMachineID truncates /etc/machine-id before running the setup tool; a setup failure previously returned an error with the file left empty. Now any setup failure falls through to writeRandomMachineID, which is what the tool would generate anyway absent other sources. --- agent/reseed_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/agent/reseed_linux.go b/agent/reseed_linux.go index 0b8573d..960e9d7 100644 --- a/agent/reseed_linux.go +++ b/agent/reseed_linux.go @@ -118,10 +118,10 @@ func regenMachineID(ctx context.Context) error { return fmt.Errorf("truncate %s: %w", machineIDPath, err) } if path, err := exec.LookPath("systemd-machine-id-setup"); err == nil { - if err := exec.CommandContext(ctx, path).Run(); err != nil { //nolint:gosec // path resolved by LookPath for a fixed binary name, not user input - return fmt.Errorf("run systemd-machine-id-setup: %w", err) + if err := exec.CommandContext(ctx, path).Run(); err == nil { //nolint:gosec // path resolved by LookPath for a fixed binary name, not user input + return nil } - return nil + // Fall through: a failed setup must not leave the truncated file empty. } return writeRandomMachineID() }