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 --dry option to run command #175

Closed
wants to merge 4 commits into from
Closed

Conversation

anpep
Copy link
Collaborator

@anpep anpep commented Jan 4, 2023

This option is useful for validating the Pebble layers without having to actually start the Pebble daemon.
Note that, in any case, pebble will exit. If the plan was valid, pebble will exit with an error code of 0; otherwise, with a non-zero exit code.

This option is useful for validating the Pebble layers without having to
actually start the Pebble daemon.
@anpep anpep requested review from niemeyer and benhoyt January 5, 2023 10:53
cmd/pebble/cmd_run.go Outdated Show resolved Hide resolved
cmd/pebble/cmd_run.go Outdated Show resolved Hide resolved
internal/daemon/daemon.go Show resolved Hide resolved
@anpep anpep requested a review from benhoyt January 17, 2023 09:02
Copy link
Contributor

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Couple of minor comments, but approved assuming those changes are mode.

internal/daemon/daemon.go Outdated Show resolved Hide resolved
internal/daemon/daemon.go Outdated Show resolved Hide resolved
cmd/pebble/cmd_run.go Outdated Show resolved Hide resolved
// Init sets up the Daemon's internal workings.
// Don't call more than once.
func (d *Daemon) Init() error {
if err := d.Validate(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I read the code correctly, we will always perform all the validation steps twice for a normal run? It does not feel clean to me if I understand it correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@anpep!?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's correct. My opinion on that, as we discussed previously, is that a more elegant implementation would add too much complexity to the existing code, so I thought this is a good compromise. Will stay tuned to Gustavo's feedback once he reviews this PR. Thanks!

@@ -49,6 +50,7 @@ func init() {
addCommand("run", shortRunHelp, longRunHelp, func() flags.Commander { return &cmdRun{} },
map[string]string{
"create-dirs": "Create pebble directory on startup if it doesn't exist",
"dry": "Validate plan without starting the pebble daemon.",
Copy link
Contributor

Choose a reason for hiding this comment

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

"Attempt to run without actually running"

This keeps it open ended, as we'll want to do more than just validate the plan there.

As a convention trivial, please note the lack of full stop on these sentences.

@@ -351,9 +351,19 @@ func logit(handler http.Handler) http.Handler {
})
}

// Validate performs the checks needed to ensure that the Pebble daemon can be started.
func (d *Daemon) Validate() error {
_, err := d.overlord.ServiceManager().Plan()
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Fred's earlier comment, in that this is doing logic twice, but also this is a bit limited in what it can do. So in a way, it does too much, and too little at the same time.

What might be nice is to have an actual drymode that starts the overlord and all the managers, so all the little areas have a chance of attempting to run, and then shut it all down. We'll of course need to have a way to inform the managers that they're running dry, so they don't actually start work that could change the system.

Happy to discuss ideas here or elsewhere before you spent too much time on an uncertain avenue.

@anpep
Copy link
Collaborator Author

anpep commented Apr 17, 2023

Closing this PR now. Will create a new one with a better approach as we discussed (:

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.

4 participants