-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat(cli): add --dry
option to pebble run
#214
Changes from all commits
8ecc565
901dcd4
f615dbf
782783f
73954cf
e973894
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
package overlord | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"os" | ||
|
@@ -94,7 +95,6 @@ type Overlord struct { | |
|
||
// New creates an Overlord with all its state managers. | ||
func New(opts *Options) (*Overlord, error) { | ||
|
||
o := &Overlord{ | ||
pebbleDir: opts.PebbleDir, | ||
loopTomb: new(tomb.Tomb), | ||
|
@@ -175,6 +175,10 @@ func New(opts *Options) (*Overlord, error) { | |
// before it. | ||
o.stateEng.AddManager(o.runner) | ||
|
||
// Dry start all managers. | ||
if err := o.stateEng.DryStart(); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this only happen if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really; the dry start mechanism, as discussed on KO026, always runs in order to run initialization tasks that do not incur in unwanted side-effects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, but it's a bit awkward to see this here at the end of Init. I think this shoud be run when starting, or on a specific There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue of running this when starting (e.g. at the top of The issue of requiring callers to call an I think running this at the bottom of |
||
return nil, err | ||
} | ||
return o, nil | ||
} | ||
|
||
|
@@ -358,17 +362,16 @@ func (o *Overlord) settle(timeout time.Duration, beforeCleanups func()) error { | |
var errs []error | ||
for !done { | ||
if timeout > 0 && time.Since(t0) > timeout { | ||
err := fmt.Errorf("Settle is not converging") | ||
if len(errs) != 0 { | ||
return &ensureError{append(errs, err)} | ||
return newMultiError("settle is not converging", errs) | ||
} | ||
return err | ||
return errors.New("settle is not converging") | ||
} | ||
next := o.ensureTimerReset() | ||
err := o.stateEng.Ensure() | ||
switch ee := err.(type) { | ||
case nil: | ||
case *ensureError: | ||
case *multiError: | ||
anpep marked this conversation as resolved.
Show resolved
Hide resolved
|
||
errs = append(errs, ee.errs...) | ||
default: | ||
errs = append(errs, err) | ||
|
@@ -395,7 +398,7 @@ func (o *Overlord) settle(timeout time.Duration, beforeCleanups func()) error { | |
} | ||
} | ||
if len(errs) != 0 { | ||
return &ensureError{errs} | ||
return newMultiError("state ensure errors", errs) | ||
} | ||
return nil | ||
} | ||
|
@@ -474,6 +477,7 @@ func FakeWithState(handleRestart func(restart.RestartType)) *Overlord { | |
s := state.New(fakeBackend{o: o}) | ||
o.stateEng = NewStateEngine(s) | ||
o.runner = state.NewTaskRunner(s) | ||
o.stateEng.DryStart() | ||
return o | ||
} | ||
|
||
|
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.
Shouldn't this go all the way to the sanityCheck below, right before Start?
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've extensively discussed this with @flotter, and one of his (rightful) concerns where around system-wide side effects caused by e.g. listening on a port, since it's an "external" side effect (i.e. contributes to Pebble initialization by persisting some state externally, be it listening on a socket or calling
.Checkpoint()
on the state backend).The idea is for the validation to be contained in the
.DryStart()
methods, and alsosanityCheck()
is a no-op for now anyway.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.
Yeah, there's definitely a limit that is worth considering, so @flotter is right on track. The question here is the cost-benefit: what are we leaving out by following a bit further, and what are the issues that can happen. For example, if we just open the port, it means we've validated that the port may be opened at all. Given that benefit, what's the cost? Will any messages be handled, or maybe not because that's done further down?