cloud-init icon indicating copy to clipboard operation
cloud-init copied to clipboard

Do not hardcode reboot command

Open holmanb opened this issue 1 year ago • 2 comments

Proposed Commit Message

fix(cmd): Do not hardcode reboot command

Attempting a `cloud-init clean --reboot` fails on alpine because this
command is hard-coded. This code already has an Init object available,
which has a Distro attribute. Stamp out the duplicate hard-coded
implementation and re-use distro reboot code to acquire cross-distro
compatiblity.

Error:
Could not reboot this system using "['shutdown', '-r', 'now']": Unexpected error while running comma  nd.
Command: ['shutdown', '-r', 'now']
Exit code: -
Reason: [Errno 2] No such file or directory: b'shutdown'
Stdout: -
Stderr: -

Context

This change is mostly test updates - the code change is trivial: just reuse the existing reboot code which already has multi-distro support.

holmanb avatar Apr 24 '24 20:04 holmanb

I guess I've never tried a cloud-init clean --reboot before.

dermotbradley avatar Apr 25 '24 00:04 dermotbradley

I guess I've never tried a cloud-init clean --reboot before.

It's honestly not much of a value add, so I'm not terribly surprised. I like it because it shaves off a command when iterating for development and it gets used a fair amount in integration testing so I figure it's worth supporting for all distros.

holmanb avatar Apr 25 '24 01:04 holmanb