Skip to content

Commit

Permalink
ci: Test jaeger-v2 as all-in-one in CI (#4890)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Enable testing of jaeger-v2 in all-in-one mode in CI
- Part of #4843

## Description of the changes
- Add `cmd/jaeger-v2/Dockerfile`
- Parameterize `scripts/build-all-in-one-image.sh` to allow running
`jaeger-v2` instead of `all-in-one`
- Call this script with `jaeger-v2` from
.github/workflows/ci-all-in-one-build.yml

## How was this change tested?
```shell
$ BINARY=jaeger-v2 BRANCH=v2-docker GITHUB_SHA=abcd scripts/build-all-in-one-image.sh pr-only
```

---------

Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
yurishkuro committed Nov 3, 2023
1 parent 10e82c0 commit 7ff9c3a
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 30 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci-all-in-one-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
if: github.ref_name != 'main'
run: bash scripts/build-all-in-one-image.sh pr-only

- name: Build and test jaeger-v2 as all-in-one
if: github.ref_name != 'main'
run: BINARY=jaeger-v2 bash scripts/build-all-in-one-image.sh pr-only

- name: Build, test, and publish all-in-one image
if: github.ref_name == 'main'
run: bash scripts/build-all-in-one-image.sh
Expand Down
93 changes: 93 additions & 0 deletions cmd/jaeger-v2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
ARG base_image
ARG debug_image

FROM $base_image AS release
ARG TARGETARCH
ARG USER_UID=10001

# Agent zipkin.thrift compact
EXPOSE 5775/udp

# Agent jaeger.thrift compact
EXPOSE 6831/udp

# Agent jaeger.thrift binary
EXPOSE 6832/udp

# Agent config HTTP
EXPOSE 5778

# Collector OTLP gRPC
EXPOSE 4317

# Collector OTLP HTTP
EXPOSE 4318

# Collector HTTP
EXPOSE 14268

# Collector gRPC
EXPOSE 14250

# Collector Zipkin
EXPOSE 9411

# Web HTTP
EXPOSE 16686

# Default configuration file for setting sampling strategies
# ENV SAMPLING_STRATEGIES_FILE=/etc/jaeger/sampling_strategies.json

COPY jaeger-v2-linux-$TARGETARCH /go/bin/jaeger-v2-linux
# COPY sampling_strategies.json /etc/jaeger/

VOLUME ["/tmp"]
ENTRYPOINT ["/go/bin/jaeger-v2-linux"]
USER ${USER_UID}

FROM $debug_image AS debug
ARG TARGETARCH=amd64
ARG USER_UID=10001

# Agent zipkin.thrift compact
EXPOSE 5775/udp

# Agent jaeger.thrift compact
EXPOSE 6831/udp

# Agent jaeger.thrift binary
EXPOSE 6832/udp

# Agent config HTTP
EXPOSE 5778

# Collector OTLP gRPC
EXPOSE 4317

# Collector OTLP HTTP
EXPOSE 4318

# Collector HTTP
EXPOSE 14268

# Collector gRPC
EXPOSE 14250

# Collector Zipkin
EXPOSE 9411

# Web HTTP
EXPOSE 16686

# Delve
EXPOSE 12345

# Default configuration file for setting sampling strategies
# ENV SAMPLING_STRATEGIES_FILE=/etc/jaeger/sampling_strategies.json

COPY jaeger-v2-debug-linux-$TARGETARCH /go/bin/jaeger-v2-linux
# COPY sampling_strategies.json /etc/jaeger/

VOLUME ["/tmp"]
ENTRYPOINT ["/go/bin/dlv", "exec", "/go/bin/jaeger-v2-linux", "--headless", "--listen=:12345", "--api-version=2", "--accept-multiclient", "--log", "--"]
USER ${USER_UID}
10 changes: 9 additions & 1 deletion cmd/jaeger-v2/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import (
"github.com/jaegertracing/jaeger/ports"
)

var _ extension.Extension = (*server)(nil)
var (
_ extension.Extension = (*server)(nil)
_ extension.Dependent = (*server)(nil)
)

type server struct {
config *Config
Expand All @@ -35,6 +38,11 @@ func newServer(config *Config, otel component.TelemetrySettings) *server {
}
}

// Dependencies implements extension.Dependent to ensure this always starts after jaegerstorage extension.
func (s *server) Dependencies() []component.ID {
return []component.ID{jaegerstorage.ID}
}

func (s *server) Start(ctx context.Context, host component.Host) error {
f, err := jaegerstorage.GetStorageFactory(s.config.TraceStoragePrimary, host)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ require (
go.opentelemetry.io/collector/exporter/loggingexporter v0.88.0
go.opentelemetry.io/collector/exporter/otlpexporter v0.88.0
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.88.0
go.opentelemetry.io/collector/extension v0.88.0
go.opentelemetry.io/collector/extension v0.88.1-0.20231102040825-2e44da36e2c6
go.opentelemetry.io/collector/extension/ballastextension v0.88.0
go.opentelemetry.io/collector/extension/zpagesextension v0.88.0
go.opentelemetry.io/collector/otelcol v0.88.0
Expand All @@ -71,7 +71,7 @@ require (
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.88.0
go.opentelemetry.io/collector/receiver v0.88.0
go.opentelemetry.io/collector/receiver/otlpreceiver v0.88.0
go.opentelemetry.io/collector/service v0.88.0
go.opentelemetry.io/collector/service v0.88.1-0.20231102040825-2e44da36e2c6
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0
go.opentelemetry.io/otel v1.19.0
Expand Down Expand Up @@ -123,7 +123,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down Expand Up @@ -182,7 +182,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shirou/gopsutil/v3 v3.23.9 // indirect
github.com/shirou/gopsutil/v3 v3.23.10 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand All @@ -323,8 +324,8 @@ github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLe
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
Expand Down Expand Up @@ -598,8 +599,8 @@ github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9c
github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/shirou/gopsutil/v3 v3.23.9 h1:ZI5bWVeu2ep4/DIxB4U9okeYJ7zp/QLTO4auRb/ty/E=
github.com/shirou/gopsutil/v3 v3.23.9/go.mod h1:x/NWSb71eMcjFIO0vhyGW5nZ7oSIgVjrCnADckb85GA=
github.com/shirou/gopsutil/v3 v3.23.10 h1:/N42opWlYzegYaVkWejXWJpbzKv2JDy3mrgGzKsh9hM=
github.com/shirou/gopsutil/v3 v3.23.10/go.mod h1:JIE26kpucQi+innVlAUnIEOSBhBUkirr5b44yr55+WE=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
Expand Down Expand Up @@ -741,8 +742,8 @@ go.opentelemetry.io/collector/exporter/otlpexporter v0.88.0 h1:YDfXZ+MtmMUqxXMw+
go.opentelemetry.io/collector/exporter/otlpexporter v0.88.0/go.mod h1:BgMN5q8rds0nrXX5YiBAgAjPzodcVopgIS/uRRe430c=
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.88.0 h1:fBbhhfEcnBgiLDFvkDptC3RsiDflxBTNXROSn04y+YM=
go.opentelemetry.io/collector/exporter/otlphttpexporter v0.88.0/go.mod h1:CuQxbaYd8aMSAJTS0/CMmZUDY8kLKZZVT4H5EfmTEJQ=
go.opentelemetry.io/collector/extension v0.88.0 h1:/WH97pQYypL7ZC5OEccoE0gFs6fjBC/Uh9NuVEYEoZ0=
go.opentelemetry.io/collector/extension v0.88.0/go.mod h1:5wPlOyWtVJcZS9CMhFUnuRvNQ0XIoV/iUSaZWtCjoHA=
go.opentelemetry.io/collector/extension v0.88.1-0.20231102040825-2e44da36e2c6 h1:NNafnNlRAZLI+PCY3w2NvridWfjTgyDSr80TqHG9dUE=
go.opentelemetry.io/collector/extension v0.88.1-0.20231102040825-2e44da36e2c6/go.mod h1:5wPlOyWtVJcZS9CMhFUnuRvNQ0XIoV/iUSaZWtCjoHA=
go.opentelemetry.io/collector/extension/auth v0.88.0 h1:4vjVCWwkh3uGqClM32jbmUDGzZ22lK4IdoSTd5xTu/s=
go.opentelemetry.io/collector/extension/auth v0.88.0/go.mod h1:IcwiPhj6ZGTaZ7WVRVvl97uyw9NShsVqcTRLtXddpK0=
go.opentelemetry.io/collector/extension/ballastextension v0.88.0 h1:3R5fGqa0jvDIj0RUWq83Mr7l0zI9TCVs+fYYaMFK5N4=
Expand All @@ -767,8 +768,8 @@ go.opentelemetry.io/collector/receiver/otlpreceiver v0.88.0 h1:Sh+Y4RB6C7ZQkMPBv
go.opentelemetry.io/collector/receiver/otlpreceiver v0.88.0/go.mod h1:Qr01GQKUmFnbgQApFhq4LNuS+n0YURfJfgLiaydwZRc=
go.opentelemetry.io/collector/semconv v0.88.0 h1:8TVP4hYaUC87S6CCLKNoSxsUE0ChldE4vqotvNHHUnE=
go.opentelemetry.io/collector/semconv v0.88.0/go.mod h1:j/8THcqVxFna1FpvA2zYIsUperEtOaRaqoLYIN4doWw=
go.opentelemetry.io/collector/service v0.88.0 h1:KSue2w94Tb2xjenlm+SC2y2g87hdhFJeHMT9pEshKAE=
go.opentelemetry.io/collector/service v0.88.0/go.mod h1:+Fov4arJzWl8SBuMonvM7gOrfK72G+d+2WotRjR5c2I=
go.opentelemetry.io/collector/service v0.88.1-0.20231102040825-2e44da36e2c6 h1:bgsioa6MiPW8uGTjxLLHGlAOHcyghNCqI/aKSDrCZQk=
go.opentelemetry.io/collector/service v0.88.1-0.20231102040825-2e44da36e2c6/go.mod h1:p8cjrpe1YYkQhH0dl4c+ZDKTUqRRfWYqghmfn31OR88=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0 h1:RsQi0qJ2imFfCvZabqzM9cNXBG8k6gXMv1A0cXRmH6A=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0/go.mod h1:vsh3ySueQCiKPxFLvjWC4Z135gIa34TQ/NSqkDTZYUM=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg=
Expand Down Expand Up @@ -1035,7 +1036,6 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
43 changes: 28 additions & 15 deletions scripts/build-all-in-one-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

set -exu

if [[ "$1" == "pr-only" ]]; then
is_pull_request=true
else
is_pull_request=false
fi

# alternative can be jaeger-v2
BINARY=${BINARY:-'all-in-one'}

# Set default GOARCH variable to the host GOARCH, the target architecture can
# be overrided by passing architecture value to the script:
# `GOARCH=<target arch> ./scripts/build-all-in-one-image.sh`.
GOARCH=${GOARCH:-$(go env GOARCH)}
mode=${1-main}
repo=jaegertracing/all-in-one
repo="jaegertracing/${BINARY}"

# verify Node.js version
expected_version="v$(cat jaeger-ui/.nvmrc)"
Expand Down Expand Up @@ -35,35 +43,40 @@ run_integration_test() {
docker kill "$CID"
}

if [ "$mode" = "pr-only" ]; then
if [[ "${is_pull_request}" == "true" ]]; then
make create-baseimg
# build architecture for linux/amd64 only for pull requests
platforms="linux/amd64"
make build-all-in-one GOOS=linux GOARCH=amd64
# build current architecture only for pull requests
platforms="linux/${GOARCH}"
make "build-${BINARY}" GOOS=linux "GOARCH=${GOARCH}"
else
make create-baseimg-debugimg
platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
make build-all-in-one GOOS=linux GOARCH=amd64
make build-all-in-one GOOS=linux GOARCH=s390x
make build-all-in-one GOOS=linux GOARCH=ppc64le
make build-all-in-one GOOS=linux GOARCH=arm64
make "build-${BINARY}" GOOS=linux GOARCH=amd64
make "build-${BINARY}" GOOS=linux GOARCH=s390x
make "build-${BINARY}" GOOS=linux GOARCH=ppc64le
make "build-${BINARY}" GOOS=linux GOARCH=arm64
fi

# build all-in-one image locally for integration test
bash scripts/build-upload-a-docker-image.sh -l -b -c all-in-one -d cmd/all-in-one -p "${platforms}" -t release
run_integration_test localhost:5000/$repo
bash scripts/build-upload-a-docker-image.sh -l -b -c "${BINARY}" -d "cmd/${BINARY}" -p "${platforms}" -t release
run_integration_test "localhost:5000/$repo"

# skip building and uploading real Docker images if it's not all-in-one
if [[ "${BINARY}" != "all-in-one" ]]; then
exit
fi

# build all-in-one image and upload to dockerhub/quay.io
bash scripts/build-upload-a-docker-image.sh -b -c all-in-one -d cmd/all-in-one -p "${platforms}" -t release

# build debug image if not on a pull request
if [ "$mode" != "pr-only" ]; then
if [[ "${is_pull_request}" == "false" ]]; then
make build-all-in-one GOOS=linux GOARCH="$GOARCH" DEBUG_BINARY=1
repo=${repo}-debug
repo="${repo}-debug"

# build all-in-one DEBUG image locally for integration test
bash scripts/build-upload-a-docker-image.sh -l -b -c all-in-one-debug -d cmd/all-in-one -t debug
run_integration_test localhost:5000/$repo
run_integration_test "localhost:5000/$repo"

# build all-in-one-debug image and upload to dockerhub/quay.io
bash scripts/build-upload-a-docker-image.sh -b -c all-in-one-debug -d cmd/all-in-one -t debug
Expand Down

0 comments on commit 7ff9c3a

Please sign in to comment.