From 47b98a6dc80110ef9b2a4823848606f09b38cd12 Mon Sep 17 00:00:00 2001 From: Henry McConville Date: Mon, 25 Nov 2024 18:54:05 +0000 Subject: [PATCH] feat(go): support go 1.23 and delve 1.23.1 --- go/helper-image/Dockerfile | 6 +- go/helper-image/delve-as-options.patch | 39 ++++---- go/skaffold.yaml | 32 ++++++- go/test/k8s-test-go116.yaml | 91 ------------------- go/test/k8s-test-go117.yaml | 91 ------------------- ...8s-test-go113.yaml => k8s-test-go121.yaml} | 24 +++-- ...8s-test-go114.yaml => k8s-test-go122.yaml} | 24 +++-- ...8s-test-go115.yaml => k8s-test-go123.yaml} | 24 +++-- 8 files changed, 89 insertions(+), 242 deletions(-) delete mode 100644 go/test/k8s-test-go116.yaml delete mode 100644 go/test/k8s-test-go117.yaml rename go/test/{k8s-test-go113.yaml => k8s-test-go121.yaml} (84%) rename go/test/{k8s-test-go114.yaml => k8s-test-go122.yaml} (84%) rename go/test/{k8s-test-go115.yaml => k8s-test-go123.yaml} (84%) diff --git a/go/helper-image/Dockerfile b/go/helper-image/Dockerfile index e1bca021..b24d987c 100644 --- a/go/helper-image/Dockerfile +++ b/go/helper-image/Dockerfile @@ -1,10 +1,10 @@ -ARG GOVERSION=1.20 -FROM --platform=$BUILDPLATFORM golang:${GOVERSION} as delve +ARG GOVERSION=1.23 +FROM --platform=$BUILDPLATFORM golang:${GOVERSION} AS delve ARG BUILDPLATFORM ARG TARGETOS ARG TARGETARCH -ARG DELVE_VERSION=1.20.1 +ARG DELVE_VERSION=1.23.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 2405efe6..41e7d434 100644 --- a/go/helper-image/delve-as-options.patch +++ b/go/helper-image/delve-as-options.patch @@ -1,32 +1,39 @@ diff --git cmd/dlv/cmds/commands.go cmd/dlv/cmds/commands.go -index 15df5f6..f145330 100644 +index b5b7662c..dcdae257 100644 --- cmd/dlv/cmds/commands.go +++ cmd/dlv/cmds/commands.go -@@ -46,6 +46,10 @@ var ( - apiVersion int - // acceptMulti allows multiple clients to connect to the same server - acceptMulti bool -+ // checkGoVersionDefault sets default for --check-go-version -+ checkGoVersionDefault = "true" +@@ -61,6 +61,8 @@ var ( + // checkLocalConnUser is true if the debugger should check that local + // connections come from the same user that started the headless server + checkLocalConnUser bool + // checkLocalConnUserDefault sets default for --only-same-user + checkLocalConnUserDefault = "true" - // addr is the debugging server listen address. - addr string - // initFile is the path to initialization file. -@@ -139,8 +143,8 @@ func New(docCall bool) *cobra.Command { - rootCommand.PersistentFlags().StringVar(&initFile, "init", "", "Init file, executed by the terminal client.") - rootCommand.PersistentFlags().StringVar(&buildFlags, "build-flags", buildFlagsDefault, "Build flags, to be passed to the compiler. For example: --build-flags=\"-tags=integration -mod=vendor -cover -v\"") + // tty is used to provide an alternate TTY for the program you wish to debug. + tty string + // disableASLR is used to disable ASLR +@@ -78,6 +80,8 @@ var ( + // used to compile the executable and refuse to work on incompatible + // versions. + checkGoVersion bool ++ // checkGoVersionDefault sets default for --check-go-version ++ checkGoVersionDefault = "true" + + // rootCommand is the root of the command tree. + rootCommand *cobra.Command +@@ -158,8 +162,8 @@ func New(docCall bool) *cobra.Command { + must(rootCommand.RegisterFlagCompletionFunc("build-flags", cobra.NoFileCompletions)) rootCommand.PersistentFlags().StringVar(&workingDir, "wd", "", "Working directory for running the program.") + must(rootCommand.MarkPersistentFlagDirname("wd")) - rootCommand.PersistentFlags().BoolVarP(&checkGoVersion, "check-go-version", "", true, "Exits if the version of Go in use is not compatible (too old or too new) with the version of Delve.") - rootCommand.PersistentFlags().BoolVarP(&checkLocalConnUser, "only-same-user", "", true, "Only connections from the same user that started this instance of Delve are allowed to connect.") + rootCommand.PersistentFlags().BoolVarP(&checkGoVersion, "check-go-version", "", parseBool(checkGoVersionDefault), "Exits if the version of Go in use is not compatible (too old or too new) with the version of Delve.") + rootCommand.PersistentFlags().BoolVarP(&checkLocalConnUser, "only-same-user", "", parseBool(checkLocalConnUserDefault), "Only connections from the same user that started this instance of Delve are allowed to connect.") 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')") - rootCommand.PersistentFlags().BoolVar(&allowNonTerminalInteractive, "allow-non-terminal-interactive", false, "Allows interactive sessions of Delve that don't have a terminal as stdin, stdout and stderr") -@@ -1020,3 +1024,14 @@ func parseRedirects(redirects []string) ([3]string, error) { +@@ -1250,3 +1254,14 @@ func must(err error) { + log.Fatal(err) } - return r, nil } + +// parseBool parses a boolean value represented by a string, and panics if there is an error. diff --git a/go/skaffold.yaml b/go/skaffold.yaml index bda83a79..9500373a 100644 --- a/go/skaffold.yaml +++ b/go/skaffold.yaml @@ -45,7 +45,7 @@ profiles: context: test/goapp docker: buildArgs: - GOVERSION: 1.18 + GOVERSION: '1.18' - op: add path: /build/artifacts/- value: @@ -53,7 +53,7 @@ profiles: context: test/goapp docker: buildArgs: - GOVERSION: 1.19 + GOVERSION: '1.19' - op: add path: /build/artifacts/- value: @@ -62,12 +62,40 @@ profiles: docker: buildArgs: GOVERSION: '1.20' + - op: add + path: /build/artifacts/- + value: + image: go121app + context: test/goapp + docker: + buildArgs: + GOVERSION: '1.21' + - op: add + path: /build/artifacts/- + value: + image: go122app + context: test/goapp + docker: + buildArgs: + GOVERSION: '1.22' + - op: add + path: /build/artifacts/- + value: + image: go123app + context: test/goapp + docker: + buildArgs: + GOVERSION: '1.23' + deploy: kubectl: manifests: - test/k8s-test-go118.yaml - test/k8s-test-go119.yaml - test/k8s-test-go120.yaml + - test/k8s-test-go121.yaml + - test/k8s-test-go122.yaml + - test/k8s-test-go123.yaml # release: pushes images to production with :latest - name: release diff --git a/go/test/k8s-test-go116.yaml b/go/test/k8s-test-go116.yaml deleted file mode 100644 index a54cefa7..00000000 --- a/go/test/k8s-test-go116.yaml +++ /dev/null @@ -1,91 +0,0 @@ -# This test approximates `skaffold debug` for a go app. -apiVersion: v1 -kind: Pod -metadata: - name: go116pod - labels: - app: hello - protocol: dlv - runtime: go116 -spec: - containers: - - name: go116app - image: go116app - 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-go116 -spec: - ports: - - name: http - port: 8080 - protocol: TCP - - name: dlv - port: 56286 - protocol: TCP - selector: - app: hello - protocol: dlv - runtime: go116 - ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: connect-to-go116 - labels: - project: container-debug-support - type: integration-test -spec: - ttlSecondsAfterFinished: 10 - backoffLimit: 1 - template: - spec: - restartPolicy: Never - initContainers: - - name: wait-for-go116pod - image: kubectl - command: [sh, -c, "while ! curl -s hello-dlv-go116:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] - containers: - - name: dlv-to-go116 - 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-go116:56286'] - - diff --git a/go/test/k8s-test-go117.yaml b/go/test/k8s-test-go117.yaml deleted file mode 100644 index b45bc81b..00000000 --- a/go/test/k8s-test-go117.yaml +++ /dev/null @@ -1,91 +0,0 @@ -# This test approximates `skaffold debug` for a go app. -apiVersion: v1 -kind: Pod -metadata: - name: go117pod - labels: - app: hello - protocol: dlv - runtime: go117 -spec: - containers: - - name: go117app - image: go117app - 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-go117 -spec: - ports: - - name: http - port: 8080 - protocol: TCP - - name: dlv - port: 56286 - protocol: TCP - selector: - app: hello - protocol: dlv - runtime: go117 - ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: connect-to-go117 - labels: - project: container-debug-support - type: integration-test -spec: - ttlSecondsAfterFinished: 10 - backoffLimit: 1 - template: - spec: - restartPolicy: Never - initContainers: - - name: wait-for-go117pod - image: kubectl - command: [sh, -c, "while ! curl -s hello-dlv-go117:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] - containers: - - name: dlv-to-go117 - 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-go117:56286'] - - diff --git a/go/test/k8s-test-go113.yaml b/go/test/k8s-test-go121.yaml similarity index 84% rename from go/test/k8s-test-go113.yaml rename to go/test/k8s-test-go121.yaml index ab4be2f3..8f1fb2ad 100644 --- a/go/test/k8s-test-go113.yaml +++ b/go/test/k8s-test-go121.yaml @@ -2,15 +2,15 @@ apiVersion: v1 kind: Pod metadata: - name: go113pod + name: go121pod labels: app: hello protocol: dlv - runtime: go113 + runtime: go121 spec: containers: - - name: go113app - image: go113app + - name: go121app + image: go121app args: - /dbg/go/bin/dlv - exec @@ -48,7 +48,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: hello-dlv-go113 + name: hello-dlv-go121 spec: ports: - name: http @@ -60,13 +60,13 @@ spec: selector: app: hello protocol: dlv - runtime: go113 + runtime: go121 --- apiVersion: batch/v1 kind: Job metadata: - name: connect-to-go113 + name: connect-to-go121 labels: project: container-debug-support type: integration-test @@ -77,15 +77,13 @@ spec: spec: restartPolicy: Never initContainers: - - name: wait-for-go113pod + - name: wait-for-go121 image: kubectl - command: [sh, -c, "while ! curl -s hello-dlv-go113:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] + command: [sh, -c, "while ! curl -s hello-dlv-go121:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] containers: - - name: dlv-to-go113 + - name: dlv-to-go121 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-go113:56286'] - - + /duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go121:56286'] diff --git a/go/test/k8s-test-go114.yaml b/go/test/k8s-test-go122.yaml similarity index 84% rename from go/test/k8s-test-go114.yaml rename to go/test/k8s-test-go122.yaml index 9012b435..3c9991ad 100644 --- a/go/test/k8s-test-go114.yaml +++ b/go/test/k8s-test-go122.yaml @@ -2,15 +2,15 @@ apiVersion: v1 kind: Pod metadata: - name: go114pod + name: go120pod labels: app: hello protocol: dlv - runtime: go114 + runtime: go120 spec: containers: - - name: go114app - image: go114app + - name: go120app + image: go120app args: - /dbg/go/bin/dlv - exec @@ -48,7 +48,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: hello-dlv-go114 + name: hello-dlv-go120 spec: ports: - name: http @@ -60,13 +60,13 @@ spec: selector: app: hello protocol: dlv - runtime: go114 + runtime: go120 --- apiVersion: batch/v1 kind: Job metadata: - name: connect-to-go114 + name: connect-to-go120 labels: project: container-debug-support type: integration-test @@ -77,15 +77,13 @@ spec: spec: restartPolicy: Never initContainers: - - name: wait-for-go114pod + - name: wait-for-go120 image: kubectl - command: [sh, -c, "while ! curl -s hello-dlv-go114:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] + command: [sh, -c, "while ! curl -s hello-dlv-go120:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] containers: - - name: dlv-to-go114 + - name: dlv-to-go120 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-go114:56286'] - - + /duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go120:56286'] diff --git a/go/test/k8s-test-go115.yaml b/go/test/k8s-test-go123.yaml similarity index 84% rename from go/test/k8s-test-go115.yaml rename to go/test/k8s-test-go123.yaml index 988f35b4..80e5b92c 100644 --- a/go/test/k8s-test-go115.yaml +++ b/go/test/k8s-test-go123.yaml @@ -2,15 +2,15 @@ apiVersion: v1 kind: Pod metadata: - name: go115pod + name: go123pod labels: app: hello protocol: dlv - runtime: go115 + runtime: go123 spec: containers: - - name: go115app - image: go115app + - name: go123app + image: go123app args: - /dbg/go/bin/dlv - exec @@ -48,7 +48,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: hello-dlv-go115 + name: hello-dlv-go123 spec: ports: - name: http @@ -60,13 +60,13 @@ spec: selector: app: hello protocol: dlv - runtime: go115 + runtime: go123 --- apiVersion: batch/v1 kind: Job metadata: - name: connect-to-go115 + name: connect-to-go123 labels: project: container-debug-support type: integration-test @@ -77,15 +77,13 @@ spec: spec: restartPolicy: Never initContainers: - - name: wait-for-go115pod + - name: wait-for-go123 image: kubectl - command: [sh, -c, "while ! curl -s hello-dlv-go115:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] + command: [sh, -c, "while ! curl -s hello-dlv-go123:8080 2>/dev/null; do echo waiting for app; sleep 1; done"] containers: - - name: dlv-to-go115 + - name: dlv-to-go123 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-go115:56286'] - - + /duct-tape/go/bin/dlv connect --init init.txt hello-dlv-go123:56286']