1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

Debug mode for DLV debugger (#869)

* Debug mode for DLV debugger

* Changelog update
This commit is contained in:
jwierzbo 2021-12-28 12:04:01 +01:00 committed by GitHub
parent 94ed3786c6
commit 591acec8aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 16 deletions

View file

@ -6,6 +6,7 @@
- Remove unused `status.members.<group>.sidecars-specs` variable
- Keep only recent terminations
- Add endpoint into member status
- Add debug mode (Golang DLV)
## [1.2.6](https://github.com/arangodb/kube-arangodb/tree/1.2.6) (2021-12-15)
- Add ArangoBackup backoff functionality

View file

@ -16,4 +16,4 @@ ARG RELEASE_MODE=community
ARG TARGETARCH=amd64
ADD bin/${RELEASE_MODE}/linux/${TARGETARCH}/arangodb_operator /usr/bin/arangodb_operator
ENTRYPOINT [ "/usr/bin/arangodb_operator" ]
ENTRYPOINT [ "/usr/bin/arangodb_operator" ]

30
Dockerfile.debug Normal file
View file

@ -0,0 +1,30 @@
FROM golang:1.16 as builder
ARG TARGETARCH
RUN apt-get update && apt-get install -y build-essential
RUN go install github.com/go-delve/delve/cmd/dlv@latest
FROM alpine:3.14 as artifact
ARG RELEASE_MODE
ARG TARGETARCH
ARG VERSION
LABEL name="kube-arangodb" \
vendor="ArangoDB" \
version="${VERSION}" \
release="${VERSION}" \
summary="ArangoDB Kubernetes Oparator" \
description="ArangoDB Kubernetes Operator" \
maintainer="redhat@arangodb.com"
RUN apk add --no-cache libc6-compat
ADD ./LICENSE /licenses/LICENSE
ADD bin/${RELEASE_MODE}/linux/${TARGETARCH}/arangodb_operator /usr/bin/arangodb_operator
COPY --from=builder /go/bin/dlv /usr/bin/dlv
ENTRYPOINT ["/usr/bin/dlv", "--listen=:2345", "--headless=true", "--continue", "--accept-multiclient", "--api-version=2", "exec", "/usr/bin/arangodb_operator", "--" ]

View file

@ -33,6 +33,18 @@ To run only a single test, set `TESTOPTIONS` to something like
`-test.run=TestRocksDBEncryptionSingle` where
`TestRocksDBEncryptionSingle` is the name of the test.
## Debugging with DLV
To attach DLV debugger, first prepare operator image with DLV server included:
```shell
IMAGETAG=1.2.4dlv DEBUG=true make docker
```
Then deploy it on your k8s and use following command to access DLV server on `localhost:2345` from your local machine:
```shell
kubectl port-forward deployment/arango-arango-deployment-operator 2345
```
## Preparing a release
To prepare for a release, do the following:
@ -76,3 +88,17 @@ If the release process fails, it may leave:
To resolve remove it using `git tag -d ...`.
- A git tag named `<major>.<minor>.<patch>` in this repository in github.
To resolve remove it manually.
## Development on MacOS
This repo requires GNU command line tools instead BSD one (which are by default available on Mac).
```shell
brew install coreutils ed findutils gawk gnu-sed gnu-tar grep make
```
Please add following to your `~/bashrc` or `~/.zshrc` file (it requires Homebrew to be installed):
```shell
HOMEBREW_PREFIX=$(brew --prefix)
for d in ${HOMEBREW_PREFIX}/opt/*/libexec/gnubin; do export PATH=$d:$PATH; done
```

View file

@ -39,8 +39,6 @@ GOASSETSBUILDER := $(GOBUILDDIR)/bin/go-assets-builder$(shell go env GOEXE)
BUILDTIME = $(shell go run "$(ROOT)/tools/dategen/")
DOCKERFILE := Dockerfile
HELM ?= $(shell which helm)
UPPER = $(shell echo '$1' | tr '[:lower:]' '[:upper:]')
@ -62,6 +60,7 @@ HELM_CMD = $(HELM) template "$(ROOTDIR)/chart/$(CHART_NAME)" \
--set "operator.image=$(OPERATORIMAGE)" \
--set "operator.imagePullPolicy=Always" \
--set "operator.resources=null" \
--set "operator.debug=$(DEBUG)" \
--namespace "$(DEPLOYMENTNAMESPACE)"
ifndef LOCALONLY
@ -74,6 +73,17 @@ else
IMAGESUFFIX := :dev
endif
ifdef DEBUG
DEBUG := true
DOCKERFILE := Dockerfile.debug
# required by DLV https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_exec.md
COMPILE_DEBUG_FLAGS := -gcflags="all=-N -l"
else
DEBUG := false
DOCKERFILE := Dockerfile
COMPILE_DEBUG_FLAGS :=
endif
ifeq ($(MANIFESTSUFFIX),-)
# Release setting
MANIFESTSUFFIX :=
@ -257,11 +267,11 @@ bin-all: $(BIN) $(VBIN_LINUX_AMD64) $(VBIN_LINUX_ARM64)
$(VBIN_LINUX_AMD64): $(SOURCES) dashboard/assets.go VERSION
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/amd64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --tags "$(RELEASE_MODE)" -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_AMD64) ./
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --tags "$(RELEASE_MODE)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_AMD64) ./
$(VBIN_LINUX_ARM64): $(SOURCES) dashboard/assets.go VERSION
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/arm64
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --tags "$(RELEASE_MODE)" -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_ARM64) ./
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --tags "$(RELEASE_MODE)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_ARM64) ./
$(BIN): $(VBIN_LINUX_AMD64)
@cp "$(VBIN_LINUX_AMD64)" "$(BIN)"

View file

@ -24,7 +24,11 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
spec:
{{- if .Values.operator.debug }}
replicas: 1
{{- else }}
replicas: {{ .Values.operator.replicaCount }}
{{- end }}
strategy:
{{ toYaml .Values.operator.updateStrategy | indent 8 }}
selector:
@ -134,10 +138,15 @@ spec:
capabilities:
drop:
- 'ALL'
{{- if .Values.operator.debug }}
add:
- 'SYS_PTRACE'
{{- end }}
{{- if .Values.operator.resources }}
resources:
{{ toYaml .Values.operator.resources | indent 22 }}
{{- end }}
{{- if not .Values.operator.debug }}
livenessProbe:
httpGet:
path: /health
@ -152,6 +161,7 @@ spec:
scheme: HTTPS
initialDelaySeconds: 5
periodSeconds: 10
{{- end }}
tolerations:
- key: "node.kubernetes.io/unreachable"
operator: "Exists"

View file

@ -7,6 +7,8 @@ operator:
scope: legacy
debug: false
args: []
service:

View file

@ -1,16 +1,5 @@
# Maintenance
## Development on MacOS
This repo requires GNU command line tools instead BSD one (which are by default available on Mac).
Please add following to your `~/bashrc` or `~/.zshrc` file (it requires Hombebrew to be installed):
```shell
HOMEBREW_PREFIX=$(brew --prefix)
for d in ${HOMEBREW_PREFIX}/opt/*/libexec/gnubin; do export PATH=$d:$PATH; done
```
## ArangoDeployment
Maintenance on ArangoDeployment can be enabled using annotation.