-
Notifications
You must be signed in to change notification settings - Fork 56
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
Conversation
This option is useful for validating the Pebble layers without having to actually start the Pebble daemon.
There was a problem hiding this 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.
// 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anpep!?
There was a problem hiding this comment.
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.", |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
Closing this PR now. Will create a new one with a better approach as we discussed (: |
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.