Skip to content

Commit 487e2b3

Browse files
authored
set GOPROCMAX and include gops in docker image (#63)
* set GOPROCMAX and include gops in docker image * remove secret detection * tweak cache ttl testcase because GH action runs on weird timer * tweak cache ttl test case, what's wrong with GH actions today
1 parent 8bb5162 commit 487e2b3

File tree

7 files changed

+30
-176
lines changed

7 files changed

+30
-176
lines changed

.github/workflows/go.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ jobs:
3737
with:
3838
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
3939
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
40-
- name: Detect Secrets
41-
run: |
42-
python -m pip install --upgrade pip
43-
pip install detect-secrets
44-
detect-secrets scan | python3 ./scripts/secret-post-process.py
4540
build_test:
4641
name: build and test
4742
runs-on: ubuntu-latest

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
FROM golang:alpine AS builder
55

66
# Add Maintainer Info
7-
LABEL maintainer="kafkaesque.io"
7+
LABEL maintainer="kesque"
88

99
RUN apk --no-cache add build-base git
10+
11+
# Build Delve
12+
RUN go get github.com/google/gops
13+
1014
WORKDIR /root/
1115
ADD . /root
1216
RUN cd /root/src && go build -o pulsar-beam
@@ -23,5 +27,8 @@ COPY --from=builder /root/src/pulsar-beam /root/bin
2327
COPY --from=builder /root/config/pulsar_beam_inmemory_db.yml /root/config/pulsar_beam.yml
2428
COPY --from=builder /root/src/unit-test/example_p* /root/config/
2529

30+
# Copy debug tools
31+
COPY --from=builder /go/bin/gops /root/bin
32+
2633
# Command to run the executable
2734
ENTRYPOINT ["./pulsar-beam"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ This is an example of a default configurations using in-memory database. Customi
107107
$ sudo docker run -d -it -v /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:/etc/ssl/certs/ca-bundle.crt -p 8085:8085 --name=pbeam-server pulsar-beam
108108
```
109109

110+
`gops` is built in the docker image for troubleshooting purpose.
111+
110112
### Pulsar Kubernetes cluster deployment
111113

112114
Pulsar Beam can be deployed within the same cluster as Pulsar. This [helm chart](https://github.com/kafkaesque-io/pulsar-helm-chart/blob/master/helm-chart-sources/pulsar/templates/beamwh-deployment.yaml) deploys a webhook broker in its own pod. The rest of HTTP receiver endpoint and REST API are deployed as a container within the [Pulsar proxy pod](https://github.com/kafkaesque-io/pulsar-helm-chart), that offers scalability with multiple replicas.

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ require (
88
github.com/dgrijalva/jwt-go v3.2.0+incompatible
99
github.com/ghodss/yaml v1.0.0
1010
github.com/golang/snappy v0.0.1 // indirect
11+
github.com/google/gops v0.3.10
1112
github.com/gorilla/mux v1.7.3
1213
github.com/hashicorp/go-retryablehttp v0.6.4
1314
github.com/prometheus/client_golang v1.4.1
1415
github.com/rs/cors v1.7.0
16+
github.com/shirou/gopsutil v2.20.5+incompatible // indirect
1517
github.com/sirupsen/logrus v1.5.0
1618
github.com/tidwall/pretty v1.0.1 // indirect
1719
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
1820
github.com/xdg/stringprep v1.0.0 // indirect
1921
go.mongodb.org/mongo-driver v1.2.0
2022
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 // indirect
23+
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 // indirect
2124
)
2225

2326
// temporary pulsar client until https://github.com/apache/pulsar-client-go/pull/238 can be merged

go.sum

Lines changed: 0 additions & 165 deletions
This file was deleted.

src/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package main
33
import (
44
"flag"
55
"os"
6+
"runtime"
67

8+
"github.com/google/gops/agent"
79
"github.com/kafkaesque-io/pulsar-beam/src/broker"
810
"github.com/kafkaesque-io/pulsar-beam/src/route"
911
"github.com/kafkaesque-io/pulsar-beam/src/util"
@@ -16,6 +18,15 @@ import (
1618
var mode = util.AssignString(os.Getenv("ProcessMode"), *flag.String("mode", "hybrid", "server running mode"))
1719

1820
func main() {
21+
// runtime.GOMAXPROCS does not the container's CPU quota in Kubernetes
22+
// therefore, it requires to be set explicitly
23+
runtime.GOMAXPROCS(util.GetEnvInt("GOMAXPROCS", 1))
24+
25+
// gops debug instrument
26+
if err := agent.Listen(agent.Options{}); err != nil {
27+
log.Panicf("gops instrument error %v", err)
28+
}
29+
1930
exit := make(chan bool) // future use to exit the main program if in broker only mode
2031
util.Init()
2132

0 commit comments

Comments
 (0)