Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
avilevy18 committed Oct 30, 2023
1 parent fed3df5 commit a7c4abf
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 61 deletions.
72 changes: 24 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM centos7-build-golang-base AS centos7-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -257,10 +255,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM centos8-build-golang-base AS centos8-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -361,10 +357,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM rockylinux9-build-golang-base AS rockylinux9-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -460,10 +454,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM bookworm-build-golang-base AS bookworm-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -559,10 +551,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM bullseye-build-golang-base AS bullseye-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -660,10 +650,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM buster-build-golang-base AS buster-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -778,10 +766,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM sles12-build-golang-base AS sles12-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -882,10 +868,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM sles15-build-golang-base AS sles15-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -981,10 +965,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM focal-build-golang-base AS focal-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -1080,10 +1062,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM jammy-build-golang-base AS jammy-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -1179,10 +1159,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM lunar-build-golang-base AS lunar-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down Expand Up @@ -1278,10 +1256,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM mantic-build-golang-base AS mantic-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down
3 changes: 2 additions & 1 deletion cmd/agent_wrapper/main_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
package main

import (
"fmt"
"os/exec"
"strings"
)

// Get a command that will write the given number of bytes
func getCommand(writeBytes int) *exec.Cmd {
return exec.Command("echo", strings.Repeat("a", int(writeBytes-1)))
return exec.Command("/bin/sh", "-c", fmt.Sprintf("echo %s", strings.Repeat("a", writeBytes-1)))
}
4 changes: 1 addition & 3 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ override_dh_auto_configure:
override_dh_auto_build:
true
override_dh_auto_test:
pwd
ls -la /work/cache/opt/google-cloud-ops-agent/subagents/fluent-bit/bin
go test ./...
PATH="/usr/local/go/bin:$$PATH" FLB="../cache/opt/google-cloud-ops-agent/subagents/fluent-bit/bin" go test ./...
override_dh_strip_nondeterminism:
dh_strip_nondeterminism -X.jar
override_dh_auto_install:
Expand Down
4 changes: 3 additions & 1 deletion dockerfiles/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (

func TestDockerfileMatches(t *testing.T) {
gotDockerfile, err := os.ReadFile(getDockerfilePath())
if err != nil {
if os.IsNotExist(err) {
t.Skip("Dockerfile not found")
} else if err != nil {
t.Error(err)
}
expectedDockerfile, err := getDockerfile()
Expand Down
6 changes: 2 additions & 4 deletions dockerfiles/template
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ RUN ./agent_wrapper.sh /work/cache/

FROM {target_name}-build-golang-base AS {target_name}-build
WORKDIR /work
COPY cmd/google_cloud_ops_agent_engine cmd/google_cloud_ops_agent_engine
COPY VERSION build.sh ./
COPY debian debian
COPY pkg pkg
COPY . /work

# Run the build script once to build the ops agent engine to a cache
RUN mkdir -p /tmp/cache_run/golang && cp -r . /tmp/cache_run/golang
WORKDIR /tmp/cache_run/golang
Expand Down
4 changes: 4 additions & 0 deletions transformation_test/testdata/parse_json_upstream/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: parse_json
field: message
time_key: time
time_format: "%Y-%m-%dT%H:%M:%S %z"
2 changes: 2 additions & 0 deletions transformation_test/testdata/parse_json_upstream/input.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"key1": 12345, "key2": "abc", "time": "2006-07-28T13:22:04Z"}
{"key1": 12345, "key2": "abc", "time": "2006-07-28T13:22:04+01:00"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- date: 2006-07-28T13:22:04Z
key1: 12345
key2: abc
- date: 2006-07-28T12:22:04Z
key1: 12345
key2: abc
6 changes: 6 additions & 0 deletions transformation_test/testdata/test_timezone/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# When a timezone is not within a log Fluent-bit assumes UTC instead of system timezone
# https://github.com/fluent/fluent-bit/issues/593#issuecomment-811183471
- type: parse_json
field: message
time_key: time
time_format: "%Y-%m-%dT%H:%M"
1 change: 1 addition & 0 deletions transformation_test/testdata/test_timezone/input.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"key1": 12345, "key2": "abc", "time": "2006-07-28T13:22"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- date: 2006-07-28T13:22:00Z
key1: 12345
key2: abc
9 changes: 5 additions & 4 deletions transformation_test/transformation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"flag"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"strconv"
Expand All @@ -24,13 +25,13 @@ import (
const (
flbMainConf = "fluent_bit_main.conf"
flbParserConf = "fluent_bit_parser.conf"
transformationInput = "transformation_input.txt"
transformationOutput = "transformation_output.yaml"
transformationInput = "input.log"
transformationOutput = "output_fluentbit.yaml"
flbTag = "transformation_test"
)

var (
flbPath = flag.String("flb", "", "Fluent-bit path")
flbPath = flag.String("flb", os.Getenv("FLB"), "Fluent-bit path")
)

//go:embed testdata
Expand Down Expand Up @@ -163,7 +164,7 @@ func readTransformationConfig(dir string) (transformationTest, error) {
var transformationTestData []byte
var config transformationTest

transformationTestData, err := readFileFromTestDir(filepath.Join(dir, "transformation_config.yaml"))
transformationTestData, err := readFileFromTestDir(filepath.Join(dir, "config.yaml"))
if err != nil {
return config, err
}
Expand Down

0 comments on commit a7c4abf

Please sign in to comment.