Revert "Merge pull request #16228 from duglin/ContextualizeEvents"
Although having a request ID available throughout the codebase is very valuable, the impact of requiring a Context as an argument to every function in the codepath of an API request, is too significant and was not properly understood at the time of the review. Furthermore, mixing API-layer code with non-API-layer code makes the latter usable only by API-layer code (one that has a notion of Context). This reverts commit de4164043546d2b9ee3bf323dbc41f4979c84480, reversing changes made to 7daeecd42d7bb112bfe01532c8c9a962bb0c7967. Signed-off-by: Tibor Vass <tibor@docker.com> Conflicts: api/server/container.go builder/internals.go daemon/container_unix.go daemon/create.go Upstream-commit: b08f071e18043abe8ce15f56826d38dd26bedb78 Component: engine
This commit is contained in:
@ -17,7 +17,6 @@ import (
|
||||
"github.com/docker/docker/autogen/dockerversion"
|
||||
"github.com/docker/docker/cli"
|
||||
"github.com/docker/docker/cliconfig"
|
||||
"github.com/docker/docker/context"
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/daemon/logger"
|
||||
"github.com/docker/docker/opts"
|
||||
@ -151,11 +150,6 @@ func getGlobalFlag() (globalFlag *flag.Flag) {
|
||||
|
||||
// CmdDaemon is the daemon command, called the raw arguments after `docker daemon`.
|
||||
func (cli *DaemonCli) CmdDaemon(args ...string) error {
|
||||
// This may need to be made even more global - it all depends
|
||||
// on whether we want the CLI to have a context object too.
|
||||
// For now we'll leave it as a daemon-side object only.
|
||||
ctx := context.Background()
|
||||
|
||||
// warn from uuid package when running the daemon
|
||||
uuid.Loggerf = logrus.Warnf
|
||||
|
||||
@ -230,7 +224,7 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
|
||||
serverConfig.TLSConfig = tlsConfig
|
||||
}
|
||||
|
||||
api := apiserver.New(ctx, serverConfig)
|
||||
api := apiserver.New(serverConfig)
|
||||
|
||||
// The serve API routine never exits unless an error occurs
|
||||
// We need to start it as a goroutine and wait on it so
|
||||
@ -251,7 +245,7 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
|
||||
cli.TrustKeyPath = commonFlags.TrustKey
|
||||
|
||||
registryService := registry.NewService(cli.registryOptions)
|
||||
d, err := daemon.NewDaemon(ctx, cli.Config, registryService)
|
||||
d, err := daemon.NewDaemon(cli.Config, registryService)
|
||||
if err != nil {
|
||||
if pfile != nil {
|
||||
if err := pfile.Remove(); err != nil {
|
||||
@ -266,14 +260,14 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"version": dockerversion.VERSION,
|
||||
"commit": dockerversion.GITCOMMIT,
|
||||
"execdriver": d.ExecutionDriver(ctx).Name(),
|
||||
"graphdriver": d.GraphDriver(ctx).String(),
|
||||
"execdriver": d.ExecutionDriver().Name(),
|
||||
"graphdriver": d.GraphDriver().String(),
|
||||
}).Info("Docker daemon")
|
||||
|
||||
signal.Trap(func() {
|
||||
api.Close()
|
||||
<-serveAPIWait
|
||||
shutdownDaemon(ctx, d, 15)
|
||||
shutdownDaemon(d, 15)
|
||||
if pfile != nil {
|
||||
if err := pfile.Remove(); err != nil {
|
||||
logrus.Error(err)
|
||||
@ -283,12 +277,12 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
|
||||
|
||||
// after the daemon is done setting up we can tell the api to start
|
||||
// accepting connections with specified daemon
|
||||
api.AcceptConnections(ctx, d)
|
||||
api.AcceptConnections(d)
|
||||
|
||||
// Daemon is fully initialized and handling API traffic
|
||||
// Wait for serve API to complete
|
||||
errAPI := <-serveAPIWait
|
||||
shutdownDaemon(ctx, d, 15)
|
||||
shutdownDaemon(d, 15)
|
||||
if errAPI != nil {
|
||||
if pfile != nil {
|
||||
if err := pfile.Remove(); err != nil {
|
||||
@ -303,10 +297,10 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
|
||||
// shutdownDaemon just wraps daemon.Shutdown() to handle a timeout in case
|
||||
// d.Shutdown() is waiting too long to kill container or worst it's
|
||||
// blocked there
|
||||
func shutdownDaemon(ctx context.Context, d *daemon.Daemon, timeout time.Duration) {
|
||||
func shutdownDaemon(d *daemon.Daemon, timeout time.Duration) {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
d.Shutdown(ctx)
|
||||
d.Shutdown()
|
||||
close(ch)
|
||||
}()
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user