-
Notifications
You must be signed in to change notification settings - Fork 13
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
If 'truncate' fails for /etc/machine-id during 'commit', attempt with 'sudo' before giving up #31
Conversation
…iving up (LINBIT#29). Also, fix a spelling error in the help messages.
Thanks for the contribution! There are alternatives to Could we change this so that, instead of doing a new provisioning step when the first |
Sure, I'll modify the PR to follow the pattern in the commit you linked. |
How would you feel about this being executed in the provisionshellstep: // Starting the VM creates a machine ID.
// We want these IDs to be unique, so reset to empty.
err = v.VMExecShell(
ctx, []string{vmName},
&ProvisionShellStep{Script: "CMD='truncate -c -s 0 /etc/machine-id'; [ \"$(id -u)\" -eq 0 ] && $CMD || { ESC=$(command -v sudo || command -v doas || command -v please || echo ''); $ESC $CMD; }"})
if err != nil {
return err
} |
Neat. I'm happy with that 👍 It breaks on a system where CMD='truncate -c -s 0 /etc/machine-id'; [ "$(id -u)" -eq 0 ] && $CMD || { ESC=$(command -v sudo || command -v doas || command -v please); [ -n "$ESC" ] && "$ESC" $CMD || $CMD; } But that said, I think your suggestion is better. It is easier to understand and I really don't think anyone has |
…er than retrying on a failed execution of truncating /etc/machine-id, determine if elevated privileges are needed in the shell script and use them from the get-go
Sounds good. I've committed an update. I've tested it locally (I will admit only on images that do have |
@JoelColledge not to be a pest, but what's y'all's release cadence like? I've got some coworkers I want to get this PR to. I could just build the binary for them myself, but if an official release is forthcoming I'll wait so they can just grab it from the official repo here. |
We don't have a regular release cadence. We release a new version when there is need. v0.28.0 released. |
Thanks, I appreciate it! |
If 'truncate' fails for /etc/machine-id during 'commit', attempt with 'sudo' before giving up.
Addresses #29. Tested locally with
virter vm commit
as well asvirter image build
.Also, fixed a typo in some help messages (
s/durign/during/
).