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

Add exponential back-off waiting until /etc/machine-id is populated #193

Closed
wants to merge 1 commit into from

Conversation

jimmykarily
Copy link
Collaborator

@jimmykarily jimmykarily self-assigned this Dec 12, 2024
@@ -28,9 +27,21 @@ func Hostname(l logger.Interface, s schema.Stage, fs vfs.FS, console Console) er

// Template the input string with random generated strings and UUID.
// Those can be used to e.g. generate random node names based on patterns "foo-{{.UUID}}"
rand.Seed(time.Now().UnixNano())
Copy link
Collaborator Author

@jimmykarily jimmykarily Dec 12, 2024

Choose a reason for hiding this comment

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

// Deprecated: As of Go 1.20 there is no reason to call Seed with
// a random value. Programs that call Seed with a known value to get
// a specific sequence of results should use New(NewSource(seed)) to
// obtain a local random generator.

// Systemd might take a while before it populates /etc/machine-id.
var id string
var err error
for i := 0; i < 4; i++ {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what is a sane timeout here 🤷 .

@jimmykarily
Copy link
Collaborator Author

We discussed that in Slack and decided we should create a machine-id ourselves as early as possible (initramfs stage) if one doesn't exist (e.g. with dbus-uuidgen --ensure=/etc/machine-id). That's not "atomic" but it should be a rather fast operation to not leave a big enough window to systemd to create a machine-id between our check and writing the one we generated.

@Itxaka
Copy link
Collaborator

Itxaka commented Dec 12, 2024

the comand to create would be https://www.freedesktop.org/software/systemd/man/latest/systemd-machine-id-setup.html

Also we can disable the service systemd-machine-id-commit to avoid systemd even trying to do anything with the machine-id

@jimmykarily
Copy link
Collaborator Author

opted for this one instead: kairos-io/packages#1178

mudler pushed a commit to kairos-io/packages that referenced this pull request Dec 18, 2024
…#1178)

* Make sure /etc/machine-id is generate as early as possible in systemd

Fixes kairos-io/kairos#3038
Deprecates mudler/yip#193

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Mask in rootfs (earlier) as per the PR comment

#1178 (comment)

Signed-off-by: Dimitris Karakasilis <[email protected]>

* Bump version

Signed-off-by: Dimitris Karakasilis <[email protected]>

---------

Signed-off-by: Dimitris Karakasilis <[email protected]>
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.

.MachineID seems to be Null
2 participants