Skip to content

Commit

Permalink
fix issue that push empty logs to logstore and change vendor updating… (
Browse files Browse the repository at this point in the history
moby#2)

* fix issue that push empty logs to logstore and change vendor updating method

* update vendor
  • Loading branch information
shuting-yst authored and rockuw committed Jun 13, 2017
1 parent 979c699 commit 90c18a7
Show file tree
Hide file tree
Showing 35 changed files with 7,239 additions and 146 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -27,5 +27,4 @@ docs/changed-files
man/man1
man/man5
man/man8
vendor/
vendor/pkg/
71 changes: 71 additions & 0 deletions COMPILE_GUIDANCE.md
@@ -0,0 +1,71 @@
## Update vendor

* if you need to update dependent package in vendor, you need to add or update package in hack/vendor.sh file, like this:

```
clone git github.com/galaxydi/go-loghub 228ca31911b37dd900a5ab9a3fbdc66c2d88ab16
clone git github.com/cloudflare/golz4 ef862a3cdc58a6f1fee4e3af3d44fbe279194cde
clone git github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998
```

* if your package use 'import "C"'(use cgo) and has necessary .c and .h files, append the directory which contains only .c and .h files to the parameter "findArgs" in hack/.vendor-helpers.sh like this:

```
# lz4 uses cgo and has .c and .h files
findArgs+=( -or -path vendor/src/github.com/cloudflare/golz4/src )
```

* run the command to update vendor

```
bash hack/vendor.sh
```

* run the command to compile binary

```
make bianry
```

* you will see the result in

```
$ll -rt bundles/*
lrwxrwxrwx 1 yushuting staff 6 Jun 13 17:46 bundles/latest -> 1.12.6
bundles/1.12.6:
total 0
drwxr-xr-x 6 yushuting staff 204 Jun 13 17:46 binary-client
drwxr-xr-x 22 yushuting staff 748 Jun 13 17:48 binary-daemon
$ll -rt *
binary-client:
total 30648
-rw-r--r-- 1 yushuting staff 80 Jun 13 17:46 docker-1.12.6.sha256
-rw-r--r-- 1 yushuting staff 48 Jun 13 17:46 docker-1.12.6.md5
-rwxr-xr-x 1 yushuting staff 15675704 Jun 13 17:46 docker-1.12.6
lrwxrwxrwx 1 yushuting staff 13 Jun 13 17:46 docker -> docker-1.12.6
binary-daemon:
total 163160
-rwxr-xr-x 1 yushuting staff 46168368 Jun 13 17:48 dockerd-1.12.6
-rw-r--r-- 1 yushuting staff 49 Jun 13 17:48 dockerd-1.12.6.md5
lrwxrwxrwx 1 yushuting staff 14 Jun 13 17:48 dockerd -> dockerd-1.12.6
-rw-r--r-- 1 yushuting staff 81 Jun 13 17:48 dockerd-1.12.6.sha256
-rw-r--r-- 1 yushuting staff 86 Jun 13 17:48 docker-proxy-1.12.6.sha256
-rw-r--r-- 1 yushuting staff 54 Jun 13 17:48 docker-proxy-1.12.6.md5
-rwxr-xr-x 1 yushuting staff 2879456 Jun 13 17:48 docker-proxy-1.12.6
lrwxrwxrwx 1 yushuting staff 19 Jun 13 17:48 docker-proxy -> docker-proxy-1.12.6
-rw-r--r-- 1 yushuting staff 52 Jun 13 17:48 docker-containerd.md5
-rwxr-xr-x 1 yushuting staff 11291144 Jun 13 17:48 docker-containerd
-rw-r--r-- 1 yushuting staff 84 Jun 13 17:48 docker-containerd.sha256
-rw-r--r-- 1 yushuting staff 89 Jun 13 17:48 docker-containerd-shim.sha256
-rw-r--r-- 1 yushuting staff 57 Jun 13 17:48 docker-containerd-shim.md5
-rwxr-xr-x 1 yushuting staff 3831592 Jun 13 17:48 docker-containerd-shim
-rw-r--r-- 1 yushuting staff 56 Jun 13 17:48 docker-containerd-ctr.md5
-rwxr-xr-x 1 yushuting staff 10537472 Jun 13 17:48 docker-containerd-ctr
-rw-r--r-- 1 yushuting staff 46 Jun 13 17:48 docker-runc.md5
-rwxr-xr-x 1 yushuting staff 8764120 Jun 13 17:48 docker-runc
-rw-r--r-- 1 yushuting staff 88 Jun 13 17:48 docker-containerd-ctr.sha256
-rw-r--r-- 1 yushuting staff 78 Jun 13 17:48 docker-runc.sha256
```
3 changes: 3 additions & 0 deletions hack/.vendor-helpers.sh
Expand Up @@ -134,6 +134,9 @@ clean() {
# The docker proxy command is built from libnetwork
findArgs+=( -or -path vendor/src/github.com/docker/libnetwork/cmd/proxy )

# lz4 uses cgo and has .c and .h files
findArgs+=( -or -path vendor/src/github.com/cloudflare/golz4/src )

local IFS=$'\n'
local prune=( $($find vendor -depth -type d -not '(' "${findArgs[@]}" ')') )
unset IFS
Expand Down
5 changes: 5 additions & 0 deletions hack/vendor.sh
Expand Up @@ -122,6 +122,11 @@ clone git github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c
# fsnotify
clone git gopkg.in/fsnotify.v1 v1.2.11

# alilogs deps
clone git github.com/galaxydi/go-loghub 228ca31911b37dd900a5ab9a3fbdc66c2d88ab16
clone git github.com/cloudflare/golz4 ef862a3cdc58a6f1fee4e3af3d44fbe279194cde
clone git github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998

# awslogs deps
clone git github.com/aws/aws-sdk-go v1.1.30
clone git github.com/go-ini/ini 060d7da055ba6ec5ea7a31f116332fe5efa04ce0
Expand Down
145 changes: 0 additions & 145 deletions vendor.conf

This file was deleted.

22 changes: 22 additions & 0 deletions vendor/src/github.com/cloudflare/golz4/.gitignore
@@ -0,0 +1,22 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
27 changes: 27 additions & 0 deletions vendor/src/github.com/cloudflare/golz4/LICENSE
@@ -0,0 +1,27 @@
Copyright (c) 2013 CloudFlare, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

* Neither the name of the CloudFlare, Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 14 additions & 0 deletions vendor/src/github.com/cloudflare/golz4/Makefile
@@ -0,0 +1,14 @@
GCFLAGS :=
LDFLAGS :=

.PHONY: install
install:
@go install -v .

.PHONY: test
test:
@go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' .

.PHONY: bench
bench:
@go test -gcflags='$(GCFLAGS)' -ldflags='$(LDFLAGS)' -bench .
4 changes: 4 additions & 0 deletions vendor/src/github.com/cloudflare/golz4/README.md
@@ -0,0 +1,4 @@
golz4
=====

Golang interface to LZ4 compression
4 changes: 4 additions & 0 deletions vendor/src/github.com/cloudflare/golz4/doc.go
@@ -0,0 +1,4 @@
// Package lz4 implements compression using lz4.c and lz4hc.c
//
// Copyright (c) 2013 CloudFlare, Inc.
package lz4
55 changes: 55 additions & 0 deletions vendor/src/github.com/cloudflare/golz4/lz4.go
@@ -0,0 +1,55 @@
package lz4

// #cgo CFLAGS: -O3
// #include "src/lz4.h"
// #include "src/lz4.c"
import "C"

import (
"errors"
"fmt"
"unsafe"
)

// p gets a char pointer to the first byte of a []byte slice
func p(in []byte) *C.char {
if len(in) == 0 {
return (*C.char)(unsafe.Pointer(nil))
}
return (*C.char)(unsafe.Pointer(&in[0]))
}

// clen gets the length of a []byte slice as a char *
func clen(s []byte) C.int {
return C.int(len(s))
}

// Uncompress with a known output size. len(out) should be equal to
// the length of the uncompressed out.
func Uncompress(in, out []byte) (error) {
if int(C.LZ4_decompress_safe(p(in), p(out), clen(in), clen(out))) < 0 {
return errors.New("Malformed compression stream")
}

return nil
}

// CompressBound calculates the size of the output buffer needed by
// Compress. This is based on the following macro:
//
// #define LZ4_COMPRESSBOUND(isize)
// ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
func CompressBound(in []byte) int {
return len(in) + ((len(in) / 255) + 16)
}

// Compress compresses in and puts the content in out. len(out)
// should have enough space for the compressed data (use CompressBound
// to calculate). Returns the number of bytes in the out slice.
func Compress(in, out []byte) (outSize int, err error) {
outSize = int(C.LZ4_compress_limitedOutput(p(in), p(out), clen(in), clen(out)))
if outSize == 0 {
err = fmt.Errorf("insufficient space for compression")
}
return
}

0 comments on commit 90c18a7

Please sign in to comment.