Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 595987fd082165b0c5739993b374bb5b6fa3f466)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -91,6 +91,8 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
|
| 91 | 91 |
return err |
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 |
+ logrus.Info("Starting up")
|
|
| 95 |
+ |
|
| 94 | 96 |
cli.configFile = &opts.configFile |
| 95 | 97 |
cli.flags = opts.flags |
| 96 | 98 |
|
| ... | ... |
@@ -266,6 +268,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
|
| 266 | 266 |
return errors.Wrap(errAPI, "shutting down due to ServeAPI error") |
| 267 | 267 |
} |
| 268 | 268 |
|
| 269 |
+ logrus.Info("Daemon shutdown complete")
|
|
| 269 | 270 |
return nil |
| 270 | 271 |
} |
| 271 | 272 |
|
| ... | ... |
@@ -20,6 +20,7 @@ import ( |
| 20 | 20 |
"github.com/docker/docker/pkg/homedir" |
| 21 | 21 |
"github.com/docker/libnetwork/portallocator" |
| 22 | 22 |
"github.com/pkg/errors" |
| 23 |
+ "github.com/sirupsen/logrus" |
|
| 23 | 24 |
"golang.org/x/sys/unix" |
| 24 | 25 |
) |
| 25 | 26 |
|
| ... | ... |
@@ -152,6 +153,7 @@ func (cli *DaemonCli) initContainerD(ctx context.Context) (func(time.Duration) e |
| 152 | 152 |
return nil, errors.Wrap(err, "could not determine whether the system containerd is running") |
| 153 | 153 |
} |
| 154 | 154 |
if !ok {
|
| 155 |
+ logrus.Debug("Containerd not running, starting daemon managed containerd")
|
|
| 155 | 156 |
opts, err := cli.getContainerdDaemonOpts() |
| 156 | 157 |
if err != nil {
|
| 157 | 158 |
return nil, errors.Wrap(err, "failed to generate containerd options") |
| ... | ... |
@@ -161,6 +163,7 @@ func (cli *DaemonCli) initContainerD(ctx context.Context) (func(time.Duration) e |
| 161 | 161 |
if err != nil {
|
| 162 | 162 |
return nil, errors.Wrap(err, "failed to start containerd") |
| 163 | 163 |
} |
| 164 |
+ logrus.Debug("Started daemon managed containerd")
|
|
| 164 | 165 |
cli.Config.ContainerdAddr = r.Address() |
| 165 | 166 |
|
| 166 | 167 |
// Try to wait for containerd to shutdown |
| ... | ... |
@@ -312,9 +312,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
| 312 | 312 |
return errors.Errorf("[%s] Daemon exited and never started", d.id)
|
| 313 | 313 |
case <-tick: |
| 314 | 314 |
ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Second) |
| 315 |
- req := req.WithContext(ctx) |
|
| 316 |
- |
|
| 317 |
- resp, err := client.Do(req) |
|
| 315 |
+ resp, err := client.Do(req.WithContext(ctx)) |
|
| 318 | 316 |
cancel() |
| 319 | 317 |
if err != nil {
|
| 320 | 318 |
d.log.Logf("[%s] error pinging daemon on start: %v", d.id, err)
|
| ... | ... |
@@ -416,12 +414,16 @@ func (d *Daemon) Stop(t testingT) {
|
| 416 | 416 |
// If it timeouts, a SIGKILL is sent. |
| 417 | 417 |
// Stop will not delete the daemon directory. If a purged daemon is needed, |
| 418 | 418 |
// instantiate a new one with NewDaemon. |
| 419 |
-func (d *Daemon) StopWithError() error {
|
|
| 419 |
+func (d *Daemon) StopWithError() (err error) {
|
|
| 420 | 420 |
if d.cmd == nil || d.Wait == nil {
|
| 421 | 421 |
return errDaemonNotStarted |
| 422 | 422 |
} |
| 423 | 423 |
defer func() {
|
| 424 |
- d.log.Logf("[%s] Daemon stopped", d.id)
|
|
| 424 |
+ if err == nil {
|
|
| 425 |
+ d.log.Logf("[%s] Daemon stopped", d.id)
|
|
| 426 |
+ } else {
|
|
| 427 |
+ d.log.Logf("[%s] Error when stopping daemon: %v", d.id, err)
|
|
| 428 |
+ } |
|
| 425 | 429 |
d.logFile.Close() |
| 426 | 430 |
d.cmd = nil |
| 427 | 431 |
}() |
| ... | ... |
@@ -493,7 +495,6 @@ func (d *Daemon) Restart(t testingT, args ...string) {
|
| 493 | 493 |
// RestartWithError will restart the daemon by first stopping it and then starting it. |
| 494 | 494 |
func (d *Daemon) RestartWithError(arg ...string) error {
|
| 495 | 495 |
if err := d.StopWithError(); err != nil {
|
| 496 |
- d.log.Logf("[%s] Error when stopping daemon: %v", d.id, err)
|
|
| 497 | 496 |
return err |
| 498 | 497 |
} |
| 499 | 498 |
return d.StartWithError(arg...) |