daemon: restore: fix fluentd-async-connect migration for downgrades

The "fluentd-async-connect" option was deprecated in 20.10 through
cc1f3c750e, and removed in 28.0 trough
49ec488036, which added migration code
on daemon startup.

However, the migration code _copied_ the deprecated option to the new
("fluentd-async") option, preserving the old field. Doing so could cause
an issue if a user would downgrade the daemon to a previous release, as
the changes in cc1f3c750e invalidate a config
that has both fields set (see [daemon/logger/fluentd/fluentd.go#L198-L200]);

    if cfg[asyncKey] != "" && cfg[asyncConnectKey] != "" {
        return config, errors.Errorf("conflicting options: cannot specify both '%s' and '%s", asyncKey, asyncConnectKey)
    }

This patch updates the migration code to remove the deprecated option.

[daemon/logger/fluentd/fluentd.go#L198-L200]: cc1f3c750e/daemon/logger/fluentd/fluentd.go (L198-L200)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-05-23 14:47:50 +02:00
parent 32c5774524
commit 979f18691a

View File

@@ -335,10 +335,11 @@ func (daemon *Daemon) restore(cfg *configStore) error {
// deprecated in v20.10 in favor of 'fluentd-async', and
// removed in v28.0.
// TODO(aker): remove this migration once the next LTS version of MCR is released.
if _, ok := c.HostConfig.LogConfig.Config["fluentd-async-connect"]; ok {
if v, ok := c.HostConfig.LogConfig.Config["fluentd-async-connect"]; ok {
if _, ok := c.HostConfig.LogConfig.Config["fluentd-async"]; !ok {
c.HostConfig.LogConfig.Config["fluentd-async"] = c.HostConfig.LogConfig.Config["fluentd-async-connect"]
c.HostConfig.LogConfig.Config["fluentd-async"] = v
}
delete(c.HostConfig.LogConfig.Config, "fluentd-async-connect")
}
}