From ff7414d110801a80708d7a4ab8aacf92dc3c33ad Mon Sep 17 00:00:00 2001 From: Alex Leites <18728999+tallaxes@users.noreply.github.com> Date: Mon, 31 Mar 2025 06:04:51 +0000 Subject: [PATCH] feat(go): support go 1.24 and delve 1.24.1 --- go/helper-image/Dockerfile | 4 +- go/helper-image/delve-as-options.patch | 4 +- go/skaffold.yaml | 9 +++ go/test/k8s-test-go124.yaml | 89 ++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 go/test/k8s-test-go124.yaml diff --git a/go/helper-image/Dockerfile b/go/helper-image/Dockerfile index b24d987..d79a137 100644 --- a/go/helper-image/Dockerfile +++ b/go/helper-image/Dockerfile @@ -1,10 +1,10 @@ -ARG GOVERSION=1.23 +ARG GOVERSION=1.24 FROM --platform=$BUILDPLATFORM golang:${GOVERSION} AS delve ARG BUILDPLATFORM ARG TARGETOS ARG TARGETARCH -ARG DELVE_VERSION=1.23.1 +ARG DELVE_VERSION=1.24.1 # Patch delve to make defaults for --check-go-version and --only-same-user # to be set at build time. We must install patch(1) to apply the patch. diff --git a/go/helper-image/delve-as-options.patch b/go/helper-image/delve-as-options.patch index 41e7d43..e61b58c 100644 --- a/go/helper-image/delve-as-options.patch +++ b/go/helper-image/delve-as-options.patch @@ -1,5 +1,5 @@ diff --git cmd/dlv/cmds/commands.go cmd/dlv/cmds/commands.go -index b5b7662c..dcdae257 100644 +index 374b5451..ad1c6b69 100644 --- cmd/dlv/cmds/commands.go +++ cmd/dlv/cmds/commands.go @@ -61,6 +61,8 @@ var ( @@ -31,7 +31,7 @@ index b5b7662c..dcdae257 100644 rootCommand.PersistentFlags().StringVar(&backend, "backend", "default", `Backend selection (see 'dlv help backend').`) must(rootCommand.RegisterFlagCompletionFunc("backend", cobra.FixedCompletions([]string{"default", "native", "lldb", "rr"}, cobra.ShellCompDirectiveNoFileComp))) rootCommand.PersistentFlags().StringArrayVarP(&redirects, "redirect", "r", []string{}, "Specifies redirect rules for target process (see 'dlv help redirect')") -@@ -1250,3 +1254,14 @@ func must(err error) { +@@ -1249,3 +1253,14 @@ func must(err error) { log.Fatal(err) } } diff --git a/go/skaffold.yaml b/go/skaffold.yaml index 9500373..682a9b8 100644 --- a/go/skaffold.yaml +++ b/go/skaffold.yaml @@ -86,6 +86,14 @@ profiles: docker: buildArgs: GOVERSION: '1.23' + - op: add + path: /build/artifacts/- + value: + image: go124app + context: test/goapp + docker: + buildArgs: + GOVERSION: '1.24' deploy: kubectl: @@ -96,6 +104,7 @@ profiles: - test/k8s-test-go121.yaml - test/k8s-test-go122.yaml - test/k8s-test-go123.yaml + - test/k8s-test-go124.yaml # release: pushes images to production with :latest - name: release diff --git a/go/test/k8s-test-go124.yaml b/go/test/k8s-test-go124.yaml new file mode 100644 index 0000000..b94f182 --- /dev/null +++ b/go/test/k8s-test-go124.yaml @@ -0,0 +1,89 @@ +# This test approximates `skaffold debug` for a go app. +apiVersion: v1 +kind: Pod +metadata: + name: go124pod + labels: + app: hello + protocol: dlv + runtime: go124 +spec: + containers: + - name: go124app + image: go124app + args: + - /dbg/go/bin/dlv + - exec + - --log + - --headless + - --continue + - --accept-multiclient + # listen on 0.0.0.0 as it is exposed as a service + - --listen=0.0.0.0:56286 + - --api-version=2 + - ./app + ports: + - containerPort: 8080 + - containerPort: 56286 + name: dlv + readinessProbe: + httpGet: + path: / + port: 8080 + volumeMounts: + - mountPath: /dbg + name: go-debugging-support + initContainers: + - image: skaffold-debug-go + name: install-go-support + resources: {} + volumeMounts: + - mountPath: /dbg + name: go-debugging-support + volumes: + - emptyDir: {} + name: go-debugging-support + +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-dlv-go124 +spec: + ports: + - name: http + port: 8080 + protocol: TCP + - name: dlv + port: 56286 + protocol: TCP + selector: + app: hello + protocol: dlv + runtime: go124 + +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: connect-to-go124 + labels: + project: container-debug-support + type: integration-test +spec: + ttlSecondsAfterFinished: 10 + backoffLimit: 1 + template: + spec: + restartPolicy: Never + initContainers: + - name: wait-for-go124 + image: kubectl + command: [sh, -c, "while ! curl -s hello-dlv-go124:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] + containers: + - name: dlv-to-go124 + image: skaffold-debug-go + command: [sh, -c, ' + (echo bt; echo exit -c) > init.txt; + set -x; + /duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go124:56286']