diff --git a/.github/workflows/dev_module_build.yml b/.github/workflows/dev_module_build.yml index bc0b070943..6e4c4a1b25 100644 --- a/.github/workflows/dev_module_build.yml +++ b/.github/workflows/dev_module_build.yml @@ -35,6 +35,9 @@ on: type: number pull_request: types: [opened, reopened, synchronize, labeled, unlabeled] + branches: + - main + - chore/dev/dev-build-virtualization-controller push: branches: - main @@ -56,6 +59,7 @@ jobs: modules_module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }} module_edition: ${{ steps.modules_module_tag.outputs.MODULE_EDITION }} runner_type: ${{ steps.modules_module_tag.outputs.RUNNER_TYPE }} + delve_debug: ${{ steps.modules_module_tag.outputs.DELVE_DEBUG }} steps: - name: Get Pull Request Labels id: get-labels @@ -107,6 +111,13 @@ jobs: echo "RUNNER_TYPE=[\"self-hosted\", \"regular\", \"selectel\"]" >> "$GITHUB_OUTPUT" fi + # Delve debug + if echo "${{ steps.get-labels.outputs.result }}" | grep -q "delve/"; then + echo "DELVE_DEBUG=true" >> "$GITHUB_OUTPUT" + else + echo "DELVE_DEBUG=false" >> "$GITHUB_OUTPUT" + fi + show_dev_manifest: runs-on: ubuntu-latest name: Show manifest @@ -228,6 +239,7 @@ jobs: MODULES_MODULE_TAG: ${{needs.set_vars.outputs.modules_module_tag}} MODULE_EDITION: ${{needs.set_vars.outputs.module_edition}} WERF_VIRTUAL_MERGE: 0 + DELVE_DEBUG: ${{needs.set_vars.outputs.delve_debug}} steps: - name: Print vars run: | @@ -237,6 +249,7 @@ jobs: echo MODULES_MODULE_SOURCE=$MODULES_MODULE_SOURCE echo MODULES_MODULE_TAG=$MODULES_MODULE_TAG echo MODULE_EDITION=$MODULE_EDITION + echo DELVE_DEBUG=$DELVE_DEBUG - uses: actions/checkout@v4 with: diff --git a/images/virtualization-artifact/werf.inc.yaml b/images/virtualization-artifact/werf.inc.yaml index 1f23c8f165..09a6b565f4 100644 --- a/images/virtualization-artifact/werf.inc.yaml +++ b/images/virtualization-artifact/werf.inc.yaml @@ -24,6 +24,9 @@ mount: to: /go/pkg shell: install: + {{- if eq $.DELVE_DEBUG "true" }} + - go install github.com/go-delve/delve/cmd/dlv@latest + {{- end }} - cd /usr/local/go/src/virtualization-controller - go mod download setup: diff --git a/images/virtualization-controller/werf.inc.yaml b/images/virtualization-controller/werf.inc.yaml index 5f7866ca89..b5dddcf99d 100644 --- a/images/virtualization-controller/werf.inc.yaml +++ b/images/virtualization-controller/werf.inc.yaml @@ -6,7 +6,17 @@ import: add: /usr/local/go/src/virtualization-controller/virtualization-controller to: /app/virtualization-controller after: install +{{- if eq $.DELVE_DEBUG "true" }} + - image: virtualization-artifact + add: /go/bin/dlv + to: /app/dlv + after: install +{{- end }} docker: USER: 64535 WORKDIR: "/app" +{{- if eq $.DELVE_DEBUG "true" }} + ENTRYPOINT: ["./dlv", "--listen=:2345", "--headless=true", "--continue", "--log=true", "--log-output=debugger,debuglineerr,gdbwire,lldbout,rpc", "--accept-multiclient", "--api-version=2", "exec", "./virtualization-controller", "--"] +{{- else }} ENTRYPOINT: ["/app/virtualization-controller"] +{{- end }} diff --git a/werf-giterminism.yaml b/werf-giterminism.yaml index c3b431e12e..a2459d6792 100644 --- a/werf-giterminism.yaml +++ b/werf-giterminism.yaml @@ -6,6 +6,7 @@ config: - MODULES_MODULE_TAG - SOURCE_REPO - MODULE_EDITION + - DELVE_DEBUG stapel: mount: allowBuildDir: true diff --git a/werf.yaml b/werf.yaml index 8eabf7c21c..dba1caf5b7 100644 --- a/werf.yaml +++ b/werf.yaml @@ -46,6 +46,10 @@ configVersion: 1 # Edition module settings {{- $_ := set . "MODULE_EDITION" (env "MODULE_EDITION") }} +# Delve debag +{{- $_ := set . "DELVE_DEBUG" (env "DELVE_DEBUG" "false") }} + + # Component versions {{ $_ := set . "Version" dict }} {{- $versions_ctx := (.Files.Get "cv/version_map.yml" | fromYaml) }} @@ -86,6 +90,7 @@ dockerfile: Dockerfile {{- $_ := set $ctx "Images" $Root.Images }} {{- $_ := set $ctx "SOURCE_REPO" $Root.SOURCE_REPO }} {{- $_ := set $ctx "MODULE_EDITION" $Root.MODULE_EDITION }} + {{- $_ := set $ctx "DELVE_DEBUG" $Root.DELVE_DEBUG }} {{- $_ := set $ctx "Version" $Root.Version }} {{- include "module_image_template" $ctx }}