Browse code

Revert "Added flag to ignore fluentd connect error on container start"

This reverts commit 3cf82ff1ab14e1ddd2b629524e894ac359168388.

Signed-off-by: Pierre Carrier <pierre@meteor.com>

Pierre Carrier authored on 2016/01/30 09:05:46
Showing 5 changed files
... ...
@@ -27,6 +27,7 @@ const (
27 27
 	name               = "fluentd"
28 28
 	defaultHostName    = "localhost"
29 29
 	defaultPort        = 24224
30
+	defaultTagPrefix   = "docker"
30 31
 	defaultBufferLimit = 1 * 1024 * 1024 // 1M buffer by default
31 32
 )
32 33
 
... ...
@@ -52,24 +53,13 @@ func New(ctx logger.Context) (logger.Logger, error) {
52 52
 	if err != nil {
53 53
 		return nil, err
54 54
 	}
55
-	failOnStartupError, err := loggerutils.ParseFailOnStartupErrorFlag(ctx)
56
-	if err != nil {
57
-		return nil, err
58
-	}
59
-	bufferLimit, err := parseBufferLimit(ctx.Config["buffer-limit"])
60
-	if err != nil {
61
-		return nil, err
62
-	}
63 55
 	extra := ctx.ExtraAttributes(nil)
64 56
 	logrus.Debugf("logging driver fluentd configured for container:%s, host:%s, port:%d, tag:%s, extra:%v.", ctx.ContainerID, host, port, tag, extra)
65 57
 	// logger tries to reconnect 2**32 - 1 times
66 58
 	// failed (and panic) after 204 years [ 1.5 ** (2**32 - 1) - 1 seconds]
67
-	log, err := fluent.New(fluent.Config{FluentPort: port, FluentHost: host, RetryWait: 1000, MaxRetry: math.MaxInt32, BufferLimit: bufferLimit})
59
+	log, err := fluent.New(fluent.Config{FluentPort: port, FluentHost: host, RetryWait: 1000, MaxRetry: math.MaxInt32})
68 60
 	if err != nil {
69
-		if failOnStartupError {
70
-			return nil, err
71
-		}
72
-		logrus.Warnf("fluentd cannot connect to configured endpoint. Ignoring as instructed. Error: %q", err)
61
+		return nil, err
73 62
 	}
74 63
 	return &fluentd{
75 64
 		tag:           tag,
... ...
@@ -112,8 +102,6 @@ func ValidateLogOpt(cfg map[string]string) error {
112 112
 		case "tag":
113 113
 		case "labels":
114 114
 		case "env":
115
-		case "fail-on-startup-error":
116
-		case "buffer-limit":
117 115
 		default:
118 116
 			return fmt.Errorf("unknown log opt '%s' for fluentd log driver", key)
119 117
 		}
... ...
@@ -145,14 +133,3 @@ func parseAddress(address string) (string, int, error) {
145 145
 	}
146 146
 	return host, portnum, nil
147 147
 }
148
-
149
-func parseBufferLimit(bufferLimit string) (int, error) {
150
-	if bufferLimit == "" {
151
-		return defaultBufferLimit, nil
152
-	}
153
-	limit, err := strconv.Atoi(bufferLimit)
154
-	if err != nil {
155
-		return 0, fmt.Errorf("invalid buffer limit %s: %s", bufferLimit, err)
156
-	}
157
-	return limit, nil
158
-}
159 148
deleted file mode 100644
... ...
@@ -1,26 +0,0 @@
1
-package loggerutils
2
-
3
-import (
4
-	"fmt"
5
-	"strconv"
6
-
7
-	"github.com/docker/docker/daemon/logger"
8
-)
9
-
10
-const (
11
-	defaultFailOnStartupError = true // So that we do not break existing behaviour
12
-)
13
-
14
-// ParseFailOnStartupErrorFlag parses a log driver flag that determines if
15
-// the driver should ignore possible connection errors during startup
16
-func ParseFailOnStartupErrorFlag(ctx logger.Context) (bool, error) {
17
-	failOnStartupError := ctx.Config["fail-on-startup-error"]
18
-	if failOnStartupError == "" {
19
-		return defaultFailOnStartupError, nil
20
-	}
21
-	failOnStartupErrorFlag, err := strconv.ParseBool(failOnStartupError)
22
-	if err != nil {
23
-		return defaultFailOnStartupError, fmt.Errorf("invalid connect error flag %s: %s", failOnStartupError, err)
24
-	}
25
-	return failOnStartupErrorFlag, nil
26
-}
27 1
deleted file mode 100644
... ...
@@ -1,51 +0,0 @@
1
-package loggerutils
2
-
3
-import (
4
-	"testing"
5
-
6
-	"github.com/docker/docker/daemon/logger"
7
-)
8
-
9
-func TestParseDefaultIgnoreFlag(t *testing.T) {
10
-	ctx := buildContext(map[string]string{})
11
-	flag, e := ParseFailOnStartupErrorFlag(ctx)
12
-	assertFlag(t, e, flag, true)
13
-}
14
-
15
-func TestParseIgnoreFlagWhenFalse(t *testing.T) {
16
-	ctx := buildContext(map[string]string{"fail-on-startup-error": "false"})
17
-	flag, e := ParseFailOnStartupErrorFlag(ctx)
18
-	assertFlag(t, e, flag, false)
19
-}
20
-
21
-func TestParseIgnoreFlagWhenTrue(t *testing.T) {
22
-	ctx := buildContext(map[string]string{"fail-on-startup-error": "true"})
23
-	flag, e := ParseFailOnStartupErrorFlag(ctx)
24
-	assertFlag(t, e, flag, true)
25
-}
26
-
27
-func TestParseIgnoreFlagWithError(t *testing.T) {
28
-	ctx := buildContext(map[string]string{"fail-on-startup-error": "maybe :)"})
29
-	flag, e := ParseFailOnStartupErrorFlag(ctx)
30
-	if e == nil {
31
-		t.Fatalf("Error should have happened")
32
-	}
33
-	assertFlag(t, nil, flag, true)
34
-}
35
-
36
-// Helpers
37
-
38
-func buildConfig(cfg map[string]string) logger.Context {
39
-	return logger.Context{
40
-		Config: cfg,
41
-	}
42
-}
43
-
44
-func assertFlag(t *testing.T, e error, flag bool, expected bool) {
45
-	if e != nil {
46
-		t.Fatalf("Error parsing ignore connect error flag: %q", e)
47
-	}
48
-	if flag != expected {
49
-		t.Fatalf("Wrong flag: %t, should be %t", flag, expected)
50
-	}
51
-}
... ...
@@ -35,8 +35,7 @@ Some options are supported by specifying `--log-opt` as many times as needed:
35 35
 
36 36
  - `fluentd-address`: specify `host:port` to connect `localhost:24224`
37 37
  - `tag`: specify tag for fluentd message, which interpret some markup, ex `{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}`
38
- - `fail-on-startup-error`: true/false; Should the logging driver fail container startup in case of connect error during startup. Default: true (backwards compatible)
39
- - `buffer-limit`: Size limit (bytes) for the buffer which is used to buffer messages in case of connection outages. Default: 1M
38
+
40 39
 
41 40
 Configure the default logging driver by passing the
42 41
 `--log-driver` option to the Docker daemon:
... ...
@@ -79,20 +78,6 @@ the log tag format.
79 79
 
80 80
 The `labels` and `env` options each take a comma-separated list of keys. If there is collision between `label` and `env` keys, the value of the `env` takes precedence. Both options add additional fields to the extra attributes of a logging message.
81 81
 
82
-### fail-on-startup-error
83
-
84
-By default, if the logging driver cannot connect to the backend it will fail the entire startup of the container. If you wish to ignore potential connect error during container startup supply the `fail-on-startup-error` flag.
85
-
86
-    docker run --log-driver=fluentd --log-opt fail-on-startup-error=false
87
-
88
-
89
-### buffer-limit
90
-
91
-When fluent driver loses connection, or cannot connect at container startup, it will buffer the log events locally for re-transmission. Buffer limit option controls how much data will be buffered locally, **per container**. Specified in bytes.
92
-
93
-    docker run --log-driver=fluentd --log-opt buffer-limit=5242880
94
-
95
-The above would result to use 5M buffer locally. Keep in mind that during possible connection errors all your containers will start buffering locally and thus might result in considerable memory usage.
96 82
 
97 83
 ## Fluentd daemon management with Docker
98 84
 
... ...
@@ -190,8 +190,6 @@ You can use the `--log-opt NAME=VALUE` flag to specify these additional Fluentd
190 190
 
191 191
  - `fluentd-address`: specify `host:port` to connect [localhost:24224]
192 192
  - `tag`: specify tag for `fluentd` message,
193
- - `fail-on-startup-error`: true/false; Should the logging driver fail container startup in case of connect error during startup. Default: true (backwards compatible)
194
- - `buffer-limit`: Size limit (bytes) for the buffer which is used to buffer messages in case of connection outages. Default: 1M
195 193
 
196 194
 For example, to specify both additional options:
197 195