Merge pull request #48518 from thaJeztah/windows_daemon_nofatal

cmd/dockerd: windows: don't use Fatal log to prevent early exit
This commit is contained in:
Sebastiaan van Stijn
2024-10-04 15:03:48 +02:00
committed by GitHub
5 changed files with 15 additions and 8 deletions

View File

@@ -227,7 +227,9 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) {
}()
// Notify that the API is active, but before daemon is set up.
preNotifyReady()
if err := preNotifyReady(); err != nil {
return err
}
const otelServiceNameEnv = "OTEL_SERVICE_NAME"
if _, ok := os.LookupEnv(otelServiceNameEnv); !ok {

View File

@@ -3,7 +3,8 @@ package main
import "github.com/docker/docker/daemon/config"
// preNotifyReady sends a message to the host when the API is active, but before the daemon is
func preNotifyReady() {
func preNotifyReady() error {
return nil
}
// notifyReady sends a message to the host when the server is ready to be used

View File

@@ -26,7 +26,8 @@ func setPlatformOptions(conf *config.Config) error {
}
// preNotifyReady sends a message to the host when the API is active, but before the daemon is
func preNotifyReady() {
func preNotifyReady() error {
return nil
}
// notifyReady sends a message to the host when the server is ready to be used

View File

@@ -41,15 +41,16 @@ func setDefaultUmask() error {
}
// preNotifyReady sends a message to the host when the API is active, but before the daemon is
func preNotifyReady() {
func preNotifyReady() error {
// start the service now to prevent timeouts waiting for daemon to start
// but still (eventually) complete all requests that are sent after this
if service != nil {
err := service.started()
if err != nil {
log.G(context.TODO()).Fatal(err)
return err
}
}
return nil
}
// notifyReady sends a message to the host when the server is ready to be used
@@ -63,9 +64,6 @@ func notifyStopping() {
// notifyShutdown is called after the daemon shuts down but before the process exits.
func notifyShutdown(err error) {
if service != nil {
if err != nil {
log.G(context.TODO()).Fatal(err)
}
service.stopped(err)
}
}

View File

@@ -26,6 +26,11 @@ func runDaemon(ctx context.Context, cli *daemonCLI) error {
}
err = cli.start(ctx)
if service != nil {
// When running as a service, log the error, so that it's sent to
// the event-log.
log.G(ctx).Error(err)
}
notifyShutdown(err)
return err
}