Skip to content

Commit 7fcccbf

Browse files
author
rafael_chicoli
committed
driver: close input channel on first pipe
1 parent 354a965 commit 7fcccbf

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

pkg/docker/driver.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (d *Driver) StartLogging(file string, info logger.Info) error {
177177
defer func() {
178178
fmt.Printf("info: [%v] closing docker reader\n", c.info.ContainerID)
179179
dec.Close()
180-
// close(c.pipeline.inputCh)
180+
close(c.pipeline.inputCh)
181181
}()
182182

183183
var buf logdriver.LogEntry
@@ -187,7 +187,6 @@ func (d *Driver) StartLogging(file string, info logger.Info) error {
187187
if err = dec.ReadMsg(&buf); err != nil {
188188
if err == io.EOF {
189189
fmt.Printf("info: [%v] shutting down logger: %v\n", c.info.ContainerID, err)
190-
// c.stream.Close()
191190
return nil
192191
}
193192
if err != nil {
@@ -335,12 +334,12 @@ func (d *Driver) StartLogging(file string, info logger.Info) error {
335334
// StopLogging ...
336335
func (d *Driver) StopLogging(file string) error {
337336

338-
time.Sleep(5 * time.Second)
337+
time.Sleep(1 * time.Second)
339338

340339
d.mu.Lock()
340+
filename := path.Base(file)
341341
// full path: /var/lib/docker/plugins/1ce514430f4da85be15e02ce6956e506246190ea790753a58f7821892b4639ef/
342342
// rootfs/run/docker/logging/4f8fdcf6793a3a72296e4aedf4f94f5bb5269b3f52eb17061bfe0fd75c66776a
343-
filename := path.Base(file)
344343
c, exists := d.logs[filename]
345344
if !exists {
346345
d.mu.Unlock()
@@ -356,14 +355,9 @@ func (d *Driver) StopLogging(file string) error {
356355
c.stream.Close()
357356
}
358357

359-
// TODO: count how many documents are in the queue
360-
// before closing client
361-
// time.Sleep(6 * time.Second)
362-
363358
if c.pipeline.group != nil {
364359
l.Printf("info: [%v] closing pipeline: %v\n", c.info.ContainerID, c.pipeline)
365-
366-
close(c.pipeline.inputCh)
360+
// close(c.pipeline.inputCh)
367361

368362
// Check whether any goroutines failed.
369363
if err := c.pipeline.group.Wait(); err != nil {

tests/acceptance-tests/03-index-and-type.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function setUp(){
1010

1111
function tearDown(){
1212
_debug
13-
_make undeploy_elasticsearch 1>/dev/null
13+
basht_run make -f "$MAKEFILE" undeploy_elasticsearch
1414
}
1515

1616
function test_different_index_and_type(){
@@ -44,6 +44,6 @@ function test_different_index_and_type(){
4444
basht_assert "echo '${output}' | jq -r '.hits.hits[0]._source.message'" equals "$message"
4545
basht_assert "echo '${output}' | jq -r '.hits.hits[0]._source.partial'" equals "true"
4646

47-
make -f "$MAKEFILE" undeploy_elasticsearch
47+
4848

4949
}

tests/helpers.bash

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ function _make() {
9595
function _debug() {
9696

9797
echo "$(date) OUTPUT:"
98-
# echo -n -e "${@}" "\n\n"
9998

10099
uptime
101100
free -m --human
@@ -105,10 +104,8 @@ function _debug() {
105104

106105
tail -n50 /var/log/upstart/docker.log || echo "log does not exist"
107106

108-
echo "searching for all documents: "
107+
echo "searching for all documents"
109108
curl -k --connect-timeout 5 -u "${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
110109
${ELASTICSEARCH_URL}/_search\?pretty=true\&size=100
111110

112-
# return 1
113-
114111
}

0 commit comments

Comments
 (0)