Don't cause a crash loop when part of the pre-server-boot process fails

This commit is contained in:
Dane Everitt 2020-05-28 19:53:12 -07:00
parent 82ffb9804d
commit 4b366ae19e
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -182,6 +182,10 @@ func (d *DockerEnvironment) Start() error {
// that point. // that point.
defer func() { defer func() {
if sawError { if sawError {
// If we don't set it to stopping first, you'll trigger crash detection which
// we don't want to do at this point since it'll just immediately try to do the
// exact same action that lead to it crashing in the first place...
d.Server.SetState(ProcessStoppingState)
d.Server.SetState(ProcessOfflineState) d.Server.SetState(ProcessOfflineState)
} }
}() }()
@ -248,8 +252,8 @@ func (d *DockerEnvironment) Start() error {
return errors.WithStack(err) return errors.WithStack(err)
} }
opts := types.ContainerStartOptions{} ctx, _ := context.WithTimeout(context.Background(), time.Second * 10)
if err := d.Client.ContainerStart(context.Background(), d.Server.Uuid, opts); err != nil { if err := d.Client.ContainerStart(ctx, d.Server.Uuid, types.ContainerStartOptions{}); err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} }