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

create a shutdown_command method in distro classes #567

Merged

Conversation

emmanuelthome
Copy link
Contributor

Copy link
Collaborator

@igalic igalic left a comment

Choose a reason for hiding this comment

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

wouldn't this be a candidate to go into the distro classes, rather than having to map it out here, we should only be calling the distro's shutdown method

@emmanuelthome
Copy link
Contributor Author

yes, it would be better. Note though that load_power_state already had some special case stuff for alpine linux. If we want to refactor, I guess that this would mean something along the lines of the present commits.

Eventually, I can sign the CLA if this piece of code is agreed upon. Who's the "canonical project manager or conact" here ?

(unless advised otherwise, I'd rather force-push a single commit with the different changes here).

@igalic
Copy link
Collaborator

igalic commented Sep 7, 2020

according to https://cloudinit.readthedocs.io/en/latest/topics/hacking.html it's ‘Rick Harding’.

Under FreeBSD, we want to use "shutdown -p" for poweroff.

Alpine linux also has some specificities.

We choose to define a method that returns the shutdown command line to
use, rather than a method that actually does the shutdown. This makes it
easier to have the tests in test_handler_power_state do their
verifications.

Two tests are added for the special behaviours that are known so far.
@emmanuelthome emmanuelthome changed the title under freebsd, use 'shutdown -p' for poweroff create a shutdown_command method in distro classes Sep 7, 2020
@mitechie
Copy link
Contributor

mitechie commented Sep 8, 2020

according to https://cloudinit.readthedocs.io/en/latest/topics/hacking.html it's ‘Rick Harding’.

/me waves

When you feel it's ready and the CLA is signed let me know and we'll get someone to help review and guide it through. Thanks!

@emmanuelthome
Copy link
Contributor Author

according to https://cloudinit.readthedocs.io/en/latest/topics/hacking.html it's ‘Rick Harding’.

/me waves

When you feel it's ready and the CLA is signed let me know and we'll get someone to help review and guide it through. Thanks!

At this point I'd be happy to get feedback. The patch can be reviewed.

As the gitlab bot says, CLA signed and all tests pass.

Copy link
Collaborator

@OddBloke OddBloke left a comment

Choose a reason for hiding this comment

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

Oops, I reviewed this a few days ago but never hit the button, apologies for the delay. Thanks for this change, the refactor onto Distro is much appreciated! I have some inline comments. :-)

(And sorry to make you duplicate a review, Lucas!)

cloudinit/distros/bsd.py Outdated Show resolved Hide resolved
tools/.github-cla-signers Show resolved Hide resolved
tests/unittests/test_handler/test_handler_power_state.py Outdated Show resolved Hide resolved
cloudinit/distros/alpine.py Outdated Show resolved Hide resolved
cloudinit/distros/alpine.py Outdated Show resolved Hide resolved
cloudinit/distros/alpine.py Show resolved Hide resolved
tests/unittests/test_handler/test_handler_power_state.py Outdated Show resolved Hide resolved
tests/unittests/test_handler/test_handler_power_state.py Outdated Show resolved Hide resolved
@emmanuelthome
Copy link
Contributor Author

emmanuelthome commented Sep 10, 2020 via email

@OddBloke
Copy link
Collaborator

Do we agree that this is what you have in mind ?

I can't speak for Lucas, but this is exactly what I had in mind when I wrote my similar comment a few days ago. 👍

@lucasmoura
Copy link
Contributor

@OddBloke @emmanuelthome Yes, that was my idea too

emmanuelthome and others added 2 commits September 10, 2020 22:33
Co-authored-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
This follows from the review suggestions. Indeed, we can avoid the
cumbersome duplication of the Distro.shutdown_command in the BSD command
by mere variation of a shutdown_options_map class object.
Copy link
Collaborator

@OddBloke OddBloke left a comment

Choose a reason for hiding this comment

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

Thanks for this second pass, this is looking really good now. I do still have a few (small!) inline comments.

cloudinit/config/cc_power_state_change.py Outdated Show resolved Hide resolved
cloudinit/distros/__init__.py Outdated Show resolved Hide resolved
cloudinit/distros/__init__.py Outdated Show resolved Hide resolved
cloudinit/distros/alpine.py Outdated Show resolved Hide resolved
emmanuelthome and others added 4 commits September 11, 2020 16:03
Co-authored-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
Co-authored-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
Co-authored-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
Copy link
Collaborator

@OddBloke OddBloke left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks for all your work!

@OddBloke OddBloke merged commit 6d332e5 into canonical:master Sep 15, 2020
@emmanuelthome emmanuelthome deleted the fix-bad-shutdown-option-freebsd branch September 16, 2020 08:35
This was referenced May 11, 2023
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.

None yet

6 participants