Skip to content

Commit 3b1d9f1

Browse files
committed
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="<nil>" 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 <[email protected]>
1 parent cd41f65 commit 3b1d9f1

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

api/server/router/swarm/cluster_routes.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter,
209209
if err := httputils.ReadJSON(r, &service); err != nil {
210210
return err
211211
}
212+
// TODO(thaJeztah): remove logentries check and migration code in release v26.0.0.
213+
if service.TaskTemplate.LogDriver != nil && service.TaskTemplate.LogDriver.Name == "logentries" {
214+
return errdefs.InvalidParameter(errors.New("the logentries logging driver has been deprecated and removed"))
215+
}
212216

213217
// Get returns "" if the header does not exist
214218
encodedAuth := r.Header.Get(registry.AuthHeader)
@@ -245,6 +249,10 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter,
245249
if err := httputils.ReadJSON(r, &service); err != nil {
246250
return err
247251
}
252+
// TODO(thaJeztah): remove logentries check and migration code in release v26.0.0.
253+
if service.TaskTemplate.LogDriver != nil && service.TaskTemplate.LogDriver.Name == "logentries" {
254+
return errdefs.InvalidParameter(errors.New("the logentries logging driver has been deprecated and removed"))
255+
}
248256

249257
rawVersion := r.URL.Query().Get("version")
250258
version, err := strconv.ParseUint(rawVersion, 10, 64)

daemon/create.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func (daemon *Daemon) containerCreate(ctx context.Context, daemonCfg *configStor
6262
if opts.params.Config == nil {
6363
return containertypes.CreateResponse{}, errdefs.InvalidParameter(runconfig.ErrEmptyConfig)
6464
}
65+
// TODO(thaJeztah): remove logentries check and migration code in release v26.0.0.
66+
if opts.params.HostConfig != nil && opts.params.HostConfig.LogConfig.Type == "logentries" {
67+
return containertypes.CreateResponse{}, errdefs.InvalidParameter(fmt.Errorf("the logentries logging driver has been deprecated and removed"))
68+
}
6569

6670
// Normalize some defaults. Doing this "ad-hoc" here for now, as there's
6771
// only one field to migrate, but we should consider having a better

daemon/daemon.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
_ "github.com/docker/docker/daemon/graphdriver/register" // register graph drivers
4242
"github.com/docker/docker/daemon/images"
4343
dlogger "github.com/docker/docker/daemon/logger"
44+
"github.com/docker/docker/daemon/logger/local"
4445
"github.com/docker/docker/daemon/network"
4546
"github.com/docker/docker/daemon/snapshotter"
4647
"github.com/docker/docker/daemon/stats"
@@ -339,17 +340,31 @@ func (daemon *Daemon) restore(cfg *configStore) error {
339340

340341
baseLogger := log.G(context.TODO()).WithField("container", c.ID)
341342

342-
// Migrate containers that don't have the default ("no") restart-policy set.
343-
// The RestartPolicy.Name field may be empty for containers that were
344-
// created with versions before v25.0.0.
345-
//
346-
// We also need to set the MaximumRetryCount to 0, to prevent
347-
// validation from failing (MaximumRetryCount is not allowed if
348-
// no restart-policy ("none") is set).
349-
if c.HostConfig != nil && c.HostConfig.RestartPolicy.Name == "" {
350-
baseLogger.WithError(err).Debug("migrated restart-policy")
351-
c.HostConfig.RestartPolicy.Name = containertypes.RestartPolicyDisabled
352-
c.HostConfig.RestartPolicy.MaximumRetryCount = 0
343+
if c.HostConfig != nil {
344+
// Migrate containers that don't have the default ("no") restart-policy set.
345+
// The RestartPolicy.Name field may be empty for containers that were
346+
// created with versions before v25.0.0.
347+
//
348+
// We also need to set the MaximumRetryCount to 0, to prevent
349+
// validation from failing (MaximumRetryCount is not allowed if
350+
// no restart-policy ("none") is set).
351+
if c.HostConfig.RestartPolicy.Name == "" {
352+
baseLogger.Debug("migrated restart-policy")
353+
c.HostConfig.RestartPolicy.Name = containertypes.RestartPolicyDisabled
354+
c.HostConfig.RestartPolicy.MaximumRetryCount = 0
355+
}
356+
357+
// Migrate containers that use the deprecated (and now non-functional)
358+
// logentries driver. Update them to use the "local" logging driver
359+
// instead.
360+
//
361+
// TODO(thaJeztah): remove logentries check and migration code in release v26.0.0.
362+
if c.HostConfig.LogConfig.Type == "logentries" {
363+
baseLogger.Warn("migrated deprecated logentries logging driver")
364+
c.HostConfig.LogConfig = containertypes.LogConfig{
365+
Type: local.Name,
366+
}
367+
}
353368
}
354369

355370
if err := daemon.checkpointAndSave(c); err != nil {

0 commit comments

Comments
 (0)