fix: prevent potential panic in Shutdown when EventsService is nil

Add nil check before calling EventsService.Close() to prevent panic
when daemon.EventsService is not initialized during shutdown.

Signed-off-by: jinda.ljd <jinda.ljd@alibaba-inc.com>
This commit is contained in:
jinda.ljd
2025-12-30 20:04:25 +08:00
parent 3bd2edb375
commit 5c637b7209

View File

@@ -1498,7 +1498,9 @@ func (daemon *Daemon) Shutdown(ctx context.Context) error {
// running anymore. If there are still some open connections to the
// '/events' endpoint, closing the EventsService should tear them down
// immediately.
daemon.EventsService.Close()
if daemon.EventsService != nil {
daemon.EventsService.Close()
}
return daemon.cleanupMounts(cfg)
}