Procházet zdrojové kódy

Fluentd: add fluentd-async option, deprecate fluentd-async-connect

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn před 6 roky
rodič
revize
cc1f3c750e
2 změnil soubory, kde provedl 22 přidání a 2 odebrání
  1. 17 2
      daemon/logger/fluentd/fluentd.go
  2. 5 0
      docs/api/version-history.md

+ 17 - 2
daemon/logger/fluentd/fluentd.go

@@ -49,7 +49,8 @@ const (
 	defaultRetryWait  = 1000
 
 	addressKey            = "fluentd-address"
-	asyncConnectKey       = "fluentd-async-connect"
+	asyncKey              = "fluentd-async"
+	asyncConnectKey       = "fluentd-async-connect" // deprecated option (use fluent-async instead)
 	bufferLimitKey        = "fluentd-buffer-limit"
 	maxRetriesKey         = "fluentd-max-retries"
 	retryWaitKey          = "fluentd-retry-wait"
@@ -143,6 +144,7 @@ func ValidateLogOpt(cfg map[string]string) error {
 		case "tag":
 
 		case addressKey:
+		case asyncKey:
 		case asyncConnectKey:
 		case bufferLimitKey:
 		case maxRetriesKey:
@@ -193,6 +195,18 @@ func parseConfig(cfg map[string]string) (fluent.Config, error) {
 		maxRetries = int(mr64)
 	}
 
+	if cfg[asyncKey] != "" && cfg[asyncConnectKey] != "" {
+		return config, errors.Errorf("conflicting options: cannot specify both '%s' and '%s", asyncKey, asyncConnectKey)
+	}
+
+	async := false
+	if cfg[asyncKey] != "" {
+		if async, err = strconv.ParseBool(cfg[asyncKey]); err != nil {
+			return config, err
+		}
+	}
+
+	// TODO fluentd-async-connect is deprecated in driver v1.4.0. Remove after two stable releases
 	asyncConnect := false
 	if cfg[asyncConnectKey] != "" {
 		if asyncConnect, err = strconv.ParseBool(cfg[asyncConnectKey]); err != nil {
@@ -215,7 +229,8 @@ func parseConfig(cfg map[string]string) (fluent.Config, error) {
 		BufferLimit:        bufferLimit,
 		RetryWait:          retryWait,
 		MaxRetry:           maxRetries,
-		Async:              asyncConnect,
+		Async:              async,
+		AsyncConnect:       asyncConnect,
 		SubSecondPrecision: subSecondPrecision,
 	}
 

+ 5 - 0
docs/api/version-history.md

@@ -85,6 +85,11 @@ keywords: "API, Docker, rcli, REST, documentation"
   on the node.label. The format of the label filter is `node.label=<key>`/`node.label=<key>=<value>`
   to return those with the specified labels, or `node.label!=<key>`/`node.label!=<key>=<value>`
   to return those without the specified labels.
+* `POST /containers/create` now accepts a `fluentd-async` option in `HostConfig.LogConfig.Config`
+  when using the Fluentd logging driver. This option deprecates the `fluentd-async-connect`
+  option, which remains funtional, but will be removed in a future release. Users
+  are encouraged to use the `fluentd-async` option going forward. This change is
+  not versioned, and affects all API versions if the daemon has this patch.
 * `POST /containers/create`, `GET /containers/{id}/json`, and `GET /containers/json` now supports
   `BindOptions.NonRecursive`.
 * `POST /swarm/init` now accepts a `DataPathPort` property to set data path port number.