From cd41f655f9266ae078ec62a9114cc697259f27b1 Mon Sep 17 00:00:00 2001 From: Bjorn Neergaard Date: Thu, 3 Nov 2022 12:21:44 -0500 Subject: [PATCH 1/2] logger: remove logentries driver The Logentries service will be discontinued next week: > Dear Logentries user, > > We have identified you as the owner of, or collaborator of, a Logentries account. > > The Logentries service will be discontinued on November 15th, 2022. This means that your Logentries account access will be removed and all your log data will be permanently deleted on this date. > > Next Steps > If you are interested in an alternative Rapid7 log management solution, InsightOps will be available for purchase through December 16th, 2022. Please note, there is no support to migrate your existing Logentries account to InsightOps. > > Thank you for being a valued user of Logentries. > > Thank you, > Rapid7 Customer Success There is no reason to preserve this code in Moby as a result. Signed-off-by: Bjorn Neergaard Signed-off-by: Sebastiaan van Stijn --- daemon/logdrivers_linux.go | 1 - daemon/logdrivers_windows.go | 1 - daemon/logger/logentries/logentries.go | 117 ---------- vendor.mod | 1 - vendor.sum | 2 - vendor/github.com/bsphere/le_go/.gitignore | 23 -- vendor/github.com/bsphere/le_go/.travis.yml | 4 - vendor/github.com/bsphere/le_go/LICENSE | 21 -- vendor/github.com/bsphere/le_go/README.md | 37 ---- vendor/github.com/bsphere/le_go/le.go | 228 -------------------- vendor/modules.txt | 3 - 11 files changed, 438 deletions(-) delete mode 100644 daemon/logger/logentries/logentries.go delete mode 100644 vendor/github.com/bsphere/le_go/.gitignore delete mode 100644 vendor/github.com/bsphere/le_go/.travis.yml delete mode 100644 vendor/github.com/bsphere/le_go/LICENSE delete mode 100644 vendor/github.com/bsphere/le_go/README.md delete mode 100644 vendor/github.com/bsphere/le_go/le.go diff --git a/daemon/logdrivers_linux.go b/daemon/logdrivers_linux.go index 425f412b200eb..b2669564faaa3 100644 --- a/daemon/logdrivers_linux.go +++ b/daemon/logdrivers_linux.go @@ -10,7 +10,6 @@ import ( _ "github.com/docker/docker/daemon/logger/journald" _ "github.com/docker/docker/daemon/logger/jsonfilelog" _ "github.com/docker/docker/daemon/logger/local" - _ "github.com/docker/docker/daemon/logger/logentries" _ "github.com/docker/docker/daemon/logger/loggerutils/cache" _ "github.com/docker/docker/daemon/logger/splunk" _ "github.com/docker/docker/daemon/logger/syslog" diff --git a/daemon/logdrivers_windows.go b/daemon/logdrivers_windows.go index 6c9d97f785821..4b286a83fcb61 100644 --- a/daemon/logdrivers_windows.go +++ b/daemon/logdrivers_windows.go @@ -9,7 +9,6 @@ import ( _ "github.com/docker/docker/daemon/logger/gcplogs" _ "github.com/docker/docker/daemon/logger/gelf" _ "github.com/docker/docker/daemon/logger/jsonfilelog" - _ "github.com/docker/docker/daemon/logger/logentries" _ "github.com/docker/docker/daemon/logger/loggerutils/cache" _ "github.com/docker/docker/daemon/logger/splunk" _ "github.com/docker/docker/daemon/logger/syslog" diff --git a/daemon/logger/logentries/logentries.go b/daemon/logger/logentries/logentries.go deleted file mode 100644 index 5ade4bc34eb1d..0000000000000 --- a/daemon/logger/logentries/logentries.go +++ /dev/null @@ -1,117 +0,0 @@ -// Package logentries provides the log driver for forwarding server logs -// to logentries endpoints. -package logentries // import "github.com/docker/docker/daemon/logger/logentries" - -import ( - "context" - "fmt" - "strconv" - - "github.com/bsphere/le_go" - "github.com/containerd/log" - "github.com/docker/docker/daemon/logger" - "github.com/pkg/errors" -) - -type logentries struct { - tag string - containerID string - containerName string - writer *le_go.Logger - extra map[string]string - lineOnly bool -} - -const ( - name = "logentries" - token = "logentries-token" - lineonly = "line-only" -) - -func init() { - if err := logger.RegisterLogDriver(name, New); err != nil { - panic(err) - } - if err := logger.RegisterLogOptValidator(name, ValidateLogOpt); err != nil { - panic(err) - } -} - -// New creates a logentries logger using the configuration passed in on -// the context. The supported context configuration variable is -// logentries-token. -func New(info logger.Info) (logger.Logger, error) { - log.G(context.TODO()).WithField("container", info.ContainerID). - WithField("token", info.Config[token]). - WithField("line-only", info.Config[lineonly]). - Debug("logging driver logentries configured") - - log, err := le_go.Connect(info.Config[token]) - if err != nil { - return nil, errors.Wrap(err, "error connecting to logentries") - } - var lineOnly bool - if info.Config[lineonly] != "" { - if lineOnly, err = strconv.ParseBool(info.Config[lineonly]); err != nil { - return nil, errors.Wrap(err, "error parsing lineonly option") - } - } - return &logentries{ - containerID: info.ContainerID, - containerName: info.ContainerName, - writer: log, - lineOnly: lineOnly, - }, nil -} - -func (f *logentries) Log(msg *logger.Message) error { - if !f.lineOnly { - data := map[string]string{ - "container_id": f.containerID, - "container_name": f.containerName, - "source": msg.Source, - "log": string(msg.Line), - } - for k, v := range f.extra { - data[k] = v - } - ts := msg.Timestamp - logger.PutMessage(msg) - f.writer.Println(f.tag, ts, data) - } else { - line := string(msg.Line) - logger.PutMessage(msg) - f.writer.Println(line) - } - return nil -} - -func (f *logentries) Close() error { - return f.writer.Close() -} - -func (f *logentries) Name() string { - return name -} - -// ValidateLogOpt looks for logentries specific log option logentries-address. -func ValidateLogOpt(cfg map[string]string) error { - for key := range cfg { - switch key { - case "env": - case "env-regex": - case "labels": - case "labels-regex": - case "tag": - case key: - default: - return fmt.Errorf("unknown log opt '%s' for logentries log driver", key) - } - } - - if cfg[token] == "" { - return fmt.Errorf("Missing logentries token") - } - - return nil -} diff --git a/vendor.mod b/vendor.mod index a41002d902c06..19d20ba12976e 100644 --- a/vendor.mod +++ b/vendor.mod @@ -22,7 +22,6 @@ require ( github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.24 github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.17 github.com/aws/smithy-go v1.13.5 - github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8 github.com/cloudflare/cfssl v1.6.4 github.com/containerd/cgroups/v3 v3.0.2 github.com/containerd/containerd v1.7.11 diff --git a/vendor.sum b/vendor.sum index 969f4ea9f7b94..e8c002e15b46f 100644 --- a/vendor.sum +++ b/vendor.sum @@ -236,8 +236,6 @@ github.com/bombsimon/wsl/v3 v3.0.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2 github.com/bombsimon/wsl/v3 v3.1.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= -github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8 h1:fcONpniVVbh9+duVZYYbJuc+yGGdLRxTqpk7pTTz/qI= -github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8/go.mod h1:GrjfimWtH8h8EqJSfbO+sTQYV/fAjL/VN7dMeU8XP2Y= github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= diff --git a/vendor/github.com/bsphere/le_go/.gitignore b/vendor/github.com/bsphere/le_go/.gitignore deleted file mode 100644 index 836562412fe8a..0000000000000 --- a/vendor/github.com/bsphere/le_go/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test diff --git a/vendor/github.com/bsphere/le_go/.travis.yml b/vendor/github.com/bsphere/le_go/.travis.yml deleted file mode 100644 index 6c604df110616..0000000000000 --- a/vendor/github.com/bsphere/le_go/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: go - -go: - - 1.12.x diff --git a/vendor/github.com/bsphere/le_go/LICENSE b/vendor/github.com/bsphere/le_go/LICENSE deleted file mode 100644 index 03f6677a723eb..0000000000000 --- a/vendor/github.com/bsphere/le_go/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Gal Ben-Haim - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/bsphere/le_go/README.md b/vendor/github.com/bsphere/le_go/README.md deleted file mode 100644 index 9d2ca9a9882d4..0000000000000 --- a/vendor/github.com/bsphere/le_go/README.md +++ /dev/null @@ -1,37 +0,0 @@ -le_go -===== - -Golang client library for logentries.com - -It is compatible with http://golang.org/pkg/log/#Logger -and also implements http://golang.org/pkg/io/#Writer - -[![GoDoc](https://godoc.org/github.com/bsphere/le_go?status.png)](https://godoc.org/github.com/bsphere/le_go) - -[![Build Status](https://travis-ci.org/bsphere/le_go.svg)](https://travis-ci.org/bsphere/le_go) - -Usage ------ -Add a new manual TCP token log at [logentries.com](https://logentries.com/quick-start/) and copy the [token](https://logentries.com/doc/input-token/). - -Installation: `go get github.com/bsphere/le_go` - -**Note:** The Logger is blocking, it can be easily run in a goroutine by calling `go le.Println(...)` - -```go -package main - -import "github.com/bsphere/le_go" - -func main() { - le, err := le_go.Connect("XXXX-XXXX-XXXX-XXXX") // replace with token - if err != nil { - panic(err) - } - - defer le.Close() - - le.Println("another test message") -} -``` - diff --git a/vendor/github.com/bsphere/le_go/le.go b/vendor/github.com/bsphere/le_go/le.go deleted file mode 100644 index a536743e80cc2..0000000000000 --- a/vendor/github.com/bsphere/le_go/le.go +++ /dev/null @@ -1,228 +0,0 @@ -// Package le_go provides a Golang client library for logging to -// logentries.com over a TCP connection. -// -// it uses an access token for sending log events. -package le_go - -import ( - "crypto/tls" - "fmt" - "net" - "os" - "strings" - "sync" - "time" -) - -// Logger represents a Logentries logger, -// it holds the open TCP connection, access token, prefix and flags. -// -// all Logger operations are thread safe and blocking, -// log operations can be invoked in a non-blocking way by calling them from -// a goroutine. -type Logger struct { - conn net.Conn - flag int - mu sync.Mutex - prefix string - token string - buf []byte -} - -const lineSep = "\n" - -// Connect creates a new Logger instance and opens a TCP connection to -// logentries.com, -// The token can be generated at logentries.com by adding a new log, -// choosing manual configuration and token based TCP connection. -func Connect(token string) (*Logger, error) { - logger := Logger{ - token: token, - } - - if err := logger.openConnection(); err != nil { - return nil, err - } - - return &logger, nil -} - -// Close closes the TCP connection to logentries.com -func (logger *Logger) Close() error { - if logger.conn != nil { - return logger.conn.Close() - } - - return nil -} - -// Opens a TCP connection to logentries.com -func (logger *Logger) openConnection() error { - conn, err := tls.Dial("tcp", "data.logentries.com:443", &tls.Config{}) - if err != nil { - return err - } - logger.conn = conn - return nil -} - -// It returns if the TCP connection to logentries.com is open -func (logger *Logger) isOpenConnection() bool { - if logger.conn == nil { - return false - } - - buf := make([]byte, 1) - - logger.conn.SetReadDeadline(time.Now()) - - _, err := logger.conn.Read(buf) - - switch err.(type) { - case net.Error: - if err.(net.Error).Timeout() == true { - logger.conn.SetReadDeadline(time.Time{}) - - return true - } - } - - return false -} - -// It ensures that the TCP connection to logentries.com is open. -// If the connection is closed, a new one is opened. -func (logger *Logger) ensureOpenConnection() error { - if !logger.isOpenConnection() { - if err := logger.openConnection(); err != nil { - return err - } - } - - return nil -} - -// Fatal is same as Print() but calls to os.Exit(1) -func (logger *Logger) Fatal(v ...interface{}) { - logger.Output(2, fmt.Sprint(v...)) - os.Exit(1) -} - -// Fatalf is same as Printf() but calls to os.Exit(1) -func (logger *Logger) Fatalf(format string, v ...interface{}) { - logger.Output(2, fmt.Sprintf(format, v...)) - os.Exit(1) -} - -// Fatalln is same as Println() but calls to os.Exit(1) -func (logger *Logger) Fatalln(v ...interface{}) { - logger.Output(2, fmt.Sprintln(v...)) - os.Exit(1) -} - -// Flags returns the logger flags -func (logger *Logger) Flags() int { - return logger.flag -} - -// Output does the actual writing to the TCP connection -func (logger *Logger) Output(calldepth int, s string) error { - var ( - err error - waitPeriod = time.Millisecond - ) - for { - _, err = logger.Write([]byte(s)) - if err != nil { - if connectionErr := logger.openConnection(); connectionErr != nil { - return connectionErr - } - waitPeriod *= 2 - time.Sleep(waitPeriod) - continue - } - return err - } -} - -// Panic is same as Print() but calls to panic -func (logger *Logger) Panic(v ...interface{}) { - s := fmt.Sprint(v...) - logger.Output(2, s) - panic(s) -} - -// Panicf is same as Printf() but calls to panic -func (logger *Logger) Panicf(format string, v ...interface{}) { - s := fmt.Sprintf(format, v...) - logger.Output(2, s) - panic(s) -} - -// Panicln is same as Println() but calls to panic -func (logger *Logger) Panicln(v ...interface{}) { - s := fmt.Sprintln(v...) - logger.Output(2, s) - panic(s) -} - -// Prefix returns the logger prefix -func (logger *Logger) Prefix() string { - return logger.prefix -} - -// Print logs a message -func (logger *Logger) Print(v ...interface{}) error { - return logger.Output(2, fmt.Sprint(v...)) -} - -// Printf logs a formatted message -func (logger *Logger) Printf(format string, v ...interface{}) error { - return logger.Output(2, fmt.Sprintf(format, v...)) -} - -// Println logs a message with a linebreak -func (logger *Logger) Println(v ...interface{}) error { - return logger.Output(2, fmt.Sprintln(v...)) -} - -// SetFlags sets the logger flags -func (logger *Logger) SetFlags(flag int) { - logger.flag = flag -} - -// SetPrefix sets the logger prefix -func (logger *Logger) SetPrefix(prefix string) { - logger.prefix = prefix -} - -// Write writes a bytes array to the Logentries TCP connection, -// it adds the access token and prefix and also replaces -// line breaks with the unicode \u2028 character -func (logger *Logger) Write(p []byte) (n int, err error) { - logger.mu.Lock() - if err := logger.ensureOpenConnection(); err != nil { - return 0, err - } - defer logger.mu.Unlock() - - logger.makeBuf(p) - - return logger.conn.Write(logger.buf) -} - -// makeBuf constructs the logger buffer -// it is not safe to be used from within multiple concurrent goroutines -func (logger *Logger) makeBuf(p []byte) { - count := strings.Count(string(p), lineSep) - p = []byte(strings.Replace(string(p), lineSep, "\u2028", count-1)) - - logger.buf = logger.buf[:0] - logger.buf = append(logger.buf, (logger.token + " ")...) - logger.buf = append(logger.buf, (logger.prefix + " ")...) - logger.buf = append(logger.buf, p...) - - if !strings.HasSuffix(string(logger.buf), lineSep) { - logger.buf = append(logger.buf, (lineSep)...) - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index e9a64b78e6bb3..b2c074652f08c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -186,9 +186,6 @@ github.com/aws/smithy-go/transport/http/internal/io # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile -# github.com/bsphere/le_go v0.0.0-20200109081728-fc06dab2caa8 -## explicit; go 1.12 -github.com/bsphere/le_go # github.com/cenkalti/backoff/v4 v4.2.1 ## explicit; go 1.18 github.com/cenkalti/backoff/v4 From 3b1d9f1a26de1d1be89c8e7f7d700954e12b6228 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 13 Dec 2023 00:03:37 +0100 Subject: [PATCH 2/2] add validation and migration for deprecated logentries driver A validation step was added to prevent the daemon from considering "logentries" as a dynamically loaded plugin, causing it to continue trying to load the plugin; WARN[2023-12-12T21:53:16.866857127Z] Unable to locate plugin: logentries, retrying in 1s WARN[2023-12-12T21:53:17.868296836Z] Unable to locate plugin: logentries, retrying in 2s WARN[2023-12-12T21:53:19.874259254Z] Unable to locate plugin: logentries, retrying in 4s WARN[2023-12-12T21:53:23.879869881Z] Unable to locate plugin: logentries, retrying in 8s But would ultimately be returned as an error to the user: docker container create --name foo --log-driver=logentries nginx:alpine Error response from daemon: error looking up logging plugin logentries: plugin "logentries" not found With the additional validation step, an error is returned immediately: docker container create --log-driver=logentries busybox Error response from daemon: the logentries logging driver has been deprecated and removed A migration step was added on container restore. Containers using the "logentries" logging driver are migrated to use the "local" logging driver: WARN[2023-12-12T22:38:53.108349297Z] migrated deprecated logentries logging driver container=4c9309fedce75d807340ea1820cc78dc5c774d7bfcae09f3744a91b84ce6e4f7 error="" As an alternative to the validation step, I also considered using a "stub" deprecation driver, however this would not result in an error when creating the container, and only produce an error when starting: docker container create --name foo --log-driver=logentries nginx:alpine 4c9309fedce75d807340ea1820cc78dc5c774d7bfcae09f3744a91b84ce6e4f7 docker start foo Error response from daemon: failed to create task for container: failed to initialize logging driver: the logentries logging driver has been deprecated and removed Error: failed to start containers: foo For containers, this validation is added in the backend (daemon). For services, this was not sufficient, as SwarmKit would try to schedule the task, which caused a close loop; docker service create --log-driver=logentries --name foo nginx:alpine zo0lputagpzaua7cwga4lfmhp overall progress: 0 out of 1 tasks 1/1: no suitable node (missing plugin on 1 node) Operation continuing in background. DEBU[2023-12-12T22:50:28.132732757Z] Calling GET /v1.43/tasks?filters=%7B%22_up-to-date%22%3A%7B%22true%22%3Atrue%7D%2C%22service%22%3A%7B%22zo0lputagpzaua7cwga4lfmhp%22%3Atrue%7D%7D DEBU[2023-12-12T22:50:28.137961549Z] Calling GET /v1.43/nodes DEBU[2023-12-12T22:50:28.340665007Z] Calling GET /v1.43/services/zo0lputagpzaua7cwga4lfmhp?insertDefaults=false DEBU[2023-12-12T22:50:28.343437632Z] Calling GET /v1.43/tasks?filters=%7B%22_up-to-date%22%3A%7B%22true%22%3Atrue%7D%2C%22service%22%3A%7B%22zo0lputagpzaua7cwga4lfmhp%22%3Atrue%7D%7D DEBU[2023-12-12T22:50:28.345201257Z] Calling GET /v1.43/nodes So a validation was added in the service create and update endpoints; docker service create --log-driver=logentries --name foo nginx:alpine Error response from daemon: the logentries logging driver has been deprecated and removed Signed-off-by: Sebastiaan van Stijn --- api/server/router/swarm/cluster_routes.go | 8 +++++ daemon/create.go | 4 +++ daemon/daemon.go | 37 ++++++++++++++++------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/api/server/router/swarm/cluster_routes.go b/api/server/router/swarm/cluster_routes.go index 68fec7b57ce0a..47dc7e52bd906 100644 --- a/api/server/router/swarm/cluster_routes.go +++ b/api/server/router/swarm/cluster_routes.go @@ -209,6 +209,10 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter, if err := httputils.ReadJSON(r, &service); err != nil { return err } + // TODO(thaJeztah): remove logentries check and migration code in release v26.0.0. + if service.TaskTemplate.LogDriver != nil && service.TaskTemplate.LogDriver.Name == "logentries" { + return errdefs.InvalidParameter(errors.New("the logentries logging driver has been deprecated and removed")) + } // Get returns "" if the header does not exist encodedAuth := r.Header.Get(registry.AuthHeader) @@ -245,6 +249,10 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter, if err := httputils.ReadJSON(r, &service); err != nil { return err } + // TODO(thaJeztah): remove logentries check and migration code in release v26.0.0. + if service.TaskTemplate.LogDriver != nil && service.TaskTemplate.LogDriver.Name == "logentries" { + return errdefs.InvalidParameter(errors.New("the logentries logging driver has been deprecated and removed")) + } rawVersion := r.URL.Query().Get("version") version, err := strconv.ParseUint(rawVersion, 10, 64) diff --git a/daemon/create.go b/daemon/create.go index 757f8b026e657..c524c03b8ed04 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -62,6 +62,10 @@ func (daemon *Daemon) containerCreate(ctx context.Context, daemonCfg *configStor if opts.params.Config == nil { return containertypes.CreateResponse{}, errdefs.InvalidParameter(runconfig.ErrEmptyConfig) } + // TODO(thaJeztah): remove logentries check and migration code in release v26.0.0. + if opts.params.HostConfig != nil && opts.params.HostConfig.LogConfig.Type == "logentries" { + return containertypes.CreateResponse{}, errdefs.InvalidParameter(fmt.Errorf("the logentries logging driver has been deprecated and removed")) + } // Normalize some defaults. Doing this "ad-hoc" here for now, as there's // only one field to migrate, but we should consider having a better diff --git a/daemon/daemon.go b/daemon/daemon.go index f332b4e77b8c5..16352e878e488 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -41,6 +41,7 @@ import ( _ "github.com/docker/docker/daemon/graphdriver/register" // register graph drivers "github.com/docker/docker/daemon/images" dlogger "github.com/docker/docker/daemon/logger" + "github.com/docker/docker/daemon/logger/local" "github.com/docker/docker/daemon/network" "github.com/docker/docker/daemon/snapshotter" "github.com/docker/docker/daemon/stats" @@ -339,17 +340,31 @@ func (daemon *Daemon) restore(cfg *configStore) error { baseLogger := log.G(context.TODO()).WithField("container", c.ID) - // Migrate containers that don't have the default ("no") restart-policy set. - // The RestartPolicy.Name field may be empty for containers that were - // created with versions before v25.0.0. - // - // We also need to set the MaximumRetryCount to 0, to prevent - // validation from failing (MaximumRetryCount is not allowed if - // no restart-policy ("none") is set). - if c.HostConfig != nil && c.HostConfig.RestartPolicy.Name == "" { - baseLogger.WithError(err).Debug("migrated restart-policy") - c.HostConfig.RestartPolicy.Name = containertypes.RestartPolicyDisabled - c.HostConfig.RestartPolicy.MaximumRetryCount = 0 + if c.HostConfig != nil { + // Migrate containers that don't have the default ("no") restart-policy set. + // The RestartPolicy.Name field may be empty for containers that were + // created with versions before v25.0.0. + // + // We also need to set the MaximumRetryCount to 0, to prevent + // validation from failing (MaximumRetryCount is not allowed if + // no restart-policy ("none") is set). + if c.HostConfig.RestartPolicy.Name == "" { + baseLogger.Debug("migrated restart-policy") + c.HostConfig.RestartPolicy.Name = containertypes.RestartPolicyDisabled + c.HostConfig.RestartPolicy.MaximumRetryCount = 0 + } + + // Migrate containers that use the deprecated (and now non-functional) + // logentries driver. Update them to use the "local" logging driver + // instead. + // + // TODO(thaJeztah): remove logentries check and migration code in release v26.0.0. + if c.HostConfig.LogConfig.Type == "logentries" { + baseLogger.Warn("migrated deprecated logentries logging driver") + c.HostConfig.LogConfig = containertypes.LogConfig{ + Type: local.Name, + } + } } if err := daemon.checkpointAndSave(c); err != nil {