GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
14.99k stars 1.62k forks source link

"skaffold debug" not working #7022

Open akitson-degreed opened 2 years ago

akitson-degreed commented 2 years ago

I cannot get "skaffold debug" to work. I'm certain this is a configuration issue, but I don't know what's wrong.

Expected behavior

Being able to connect to the debugger after running "skaffold debug".

Actual behavior

The duct-tape container is never added, so there is no debugger, and the annotations for the debugging are not on the pods.

Information

Repo showing issue: https://github.com/akitson-degreed/skaffold-debug-issue

apiVersion: skaffold/v2beta26
kind: Config
build:
  artifacts:
    - image: visier-utility
      context: .
      buildpacks:
        builder: paketobuildpacks/builder:base
        buildpacks:
          - gcr.io/paketo-buildpacks/dotnet-core
        env:
          - "BP_DOTNET_PUBLISH_FLAGS=--configuration Debug"
  tagPolicy:
    envTemplate:
      template: local
deploy:
  helm:
    releases:
      - name: visier-utility-release
        remoteChart: aspnet-core
        wait: true
        artifactOverrides:
          image: visier-utility
        setValueTemplates:
          ingress.hostname: localhost
          extraEnvVars.AZURE_CLIENT_ID: "xxxxxx # service principal's app id
          extraEnvVars.AZURE_TENANT_ID: "xxxxxx" # id of the principal's Azure Active Directory tenant
          extraEnvVars.AZURE_CLIENT_SECRET: "xxxxx" # one of the service principal's client secrets
        overrides:
          nameOverride: web
          commonLabels:
            app.kubernetes.io/instance: visier-utility-release
            app.kubernetes.io/managed-by: Helm
            app.kubernetes.io/name: retool-utility
          appFromExternalRepo:
            enabled: false
          command:
            - "web"
          bindURLs: "https://+;http://+"
          image:
            debug: true
          ingress:
            enabled: true
            apiVersion: networking.k8s.io/v1
            ingressClassName: nginx
            annotations:
              nginx.ingress.kubernetes.io/client-body-buffer-size: "100M"
              nginx.ingress.kubernetes.io/proxy-body-size: "100M"
            pathType: Prefix
            path: /
            tls: false
        createNamespace: false
        repo: https://charts.bitnami.com/bitnami
        upgradeOnChange: true
        imageStrategy:
          helm: {}
portForward:
  - resourceType: Service
    resourceName: visier-utility-release-web
    port: 80
    localPort: 5000
profiles:
  - name: ci
    activation: # criteria by which a profile can be auto-activated. The profile is auto-activated if any one of the activations are triggered. An activation is triggered if all of the criteria (env, kubeContext, command) are triggered.
      - kubeContext: "!minikube"
    patches:
      - op: replace
        path: /deploy/helm/releases/0/upgradeOnChange
        value: true
      - op: replace
        path: /deploy/helm/releases/0/overrides/image/debug
        value: false
      - op: replace
        path: /deploy/helm/releases/0/overrides/ingress/tls
        value: true
      - op: replace
        path: /deploy/helm/releases/0/setValueTemplates/extraEnvVars.AZURE_TENANT_ID
        value: "{{.AZURE_TENANT_ID}}"
      - op: add
        path: "/deploy/helm/releases/0/setValueTemplates/commonLabels.app\\.kubernetes\\.io~1build-number"
        value: "{{.BUILD_BUILDNUMBER}}"
      - op: add
        path: "/deploy/helm/releases/0/setValueTemplates/ingress.annotations.cert-manager\\.io~1cluster-issuer"
        value: "{{.CLUSTER_CERT_ISSUER}}"
      - op: replace
        path: /deploy/helm/releases/0/setValueTemplates/extraEnvVars.AZURE_CLIENT_SECRET
        value: "{{.AZURE_CLIENT_SECRET}}"
      - op: add
        path: /deploy/helm/releases/0/setValueTemplates/ingress.hostname
        value: "{{.APP_HOSTNAME}}"
      - op: add
        path: /deploy/helm/releases/0/imageStrategy/helm/explicitRegistry
        value: true
      - op: replace
        path: /build/tagPolicy/envTemplate/template
        value: "{{.BUILD_BUILDNUMBER}}"
      - op: replace
        path: /build/artifacts/0/buildpacks/env/0
        value: "BP_DOTNET_PUBLISH_FLAGS=--configuration Release"
      - op: remove
        path: /portForward

Steps to reproduce the behavior

  1. skaffold debug
Listing files to watch...
 - visier-utility
Generating tags...
 - visier-utility -> visier-utility:local
Checking cache...
 - visier-utility: Not found. Building
Starting build...
Found [minikube] context, using local docker daemon.
Building [visier-utility]...
base: Pulling from paketobuildpacks/builder
Digest: sha256:8c7bf75982a38407d8e236a664f8abca88718b918649905f585c5f3ccda93a2c
Status: Image is up to date for paketobuildpacks/builder:base
base-cnb: Pulling from paketobuildpacks/run
Digest: sha256:59aa1da9db6d979e21721e306b9ce99a7c4e3d1663c4c20f74f9b3876cce5192
Status: Image is up to date for paketobuildpacks/run:base-cnb
latest: Pulling from paketo-buildpacks/dotnet-core
Digest: sha256:b4278f0ade59815effe88429c08f14a5711be224449abed77f6415b812dfc8f3
Status: Image is up to date for gcr.io/paketo-buildpacks/dotnet-core:latest
0.13.2: Pulling from buildpacksio/lifecycle
Digest: sha256:b7f2b9f44525ed0e962bdf5be186a266e36adc502b3dc0595dd2aac7f2b92e75
Status: Image is up to date for buildpacksio/lifecycle:0.13.2
===> DETECTING
[detector] 8 of 12 buildpacks participating
[detector] paketo-buildpacks/ca-certificates       3.0.2
[detector] paketo-buildpacks/dotnet-core-runtime   0.5.1
[detector] paketo-buildpacks/dotnet-core-aspnet    0.5.1
[detector] paketo-buildpacks/dotnet-core-sdk       0.5.2
[detector] paketo-buildpacks/icu                   0.1.0
[detector] paketo-buildpacks/dotnet-publish        0.5.1
[detector] paketo-buildpacks/dotnet-execute        0.7.0
[detector] paketo-buildpacks/environment-variables 4.0.2
===> ANALYZING
[analyzer] Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
[analyzer] Restoring metadata for "paketo-buildpacks/dotnet-core-runtime:dotnet-core-runtime" from app image
[analyzer] Restoring metadata for "paketo-buildpacks/dotnet-core-aspnet:dotnet-core-aspnet" from app image
[analyzer] Restoring metadata for "paketo-buildpacks/dotnet-core-sdk:dotnet-core-sdk" from cache
[analyzer] Restoring metadata for "paketo-buildpacks/icu:icu" from app image
[analyzer] Restoring metadata for "paketo-buildpacks/environment-variables:environment-variables" from app image
===> RESTORING
[restorer] Restoring data for "paketo-buildpacks/dotnet-core-runtime:dotnet-core-runtime" from cache
[restorer] Restoring data for "paketo-buildpacks/dotnet-core-aspnet:dotnet-core-aspnet" from cache
[restorer] Restoring data for "paketo-buildpacks/dotnet-core-sdk:dotnet-core-sdk" from cache
[restorer] Restoring data for "paketo-buildpacks/icu:icu" from cache
===> BUILDING
[builder]
[builder] Paketo CA Certificates Buildpack 3.0.2
[builder]   https://github.com/paketo-buildpacks/ca-certificates
[builder]   Launch Helper: Reusing cached layer
[builder] Paketo .NET Core Runtime Buildpack 0.5.1
[builder]   Resolving Dotnet Core Runtime version
[builder]     Candidate version sources (in priority order):
[builder]       BP_DOTNET_FRAMEWORK_VERSION -> "5.0.12"
[builder]       VisierUtility.csproj        -> "5.0.0"
[builder]       <unknown>                   -> ""
[builder]
[builder]     Selected dotnet-runtime version (using BP_DOTNET_FRAMEWORK_VERSION): 5.0.12
[builder]
[builder]   Reusing cached layer /layers/paketo-buildpacks_dotnet-core-runtime/dotnet-core-runtime
[builder]
[builder] Paketo ASP.NET Core Buildpack 0.5.1
[builder]   Resolving Dotnet Core ASPNet version
[builder]     Candidate version sources (in priority order):
[builder]       RUNTIME_VERSION             -> "5.0.12"
[builder]       BP_DOTNET_FRAMEWORK_VERSION -> "5.0.12"
[builder]       VisierUtility.csproj        -> "5.0.0"
[builder]       <unknown>                   -> ""
[builder]
[builder]     Selected dotnet-aspnetcore version (using RUNTIME_VERSION): 5.0.12
[builder]
[builder]   Reusing cached layer /layers/paketo-buildpacks_dotnet-core-aspnet/dotnet-core-aspnet
[builder]
[builder] Paketo .NET Core SDK Buildpack 0.5.2
[builder]   Resolving .NET Core SDK version
[builder]     Candidate version sources (in priority order):
[builder]       RUNTIME_VERSION      -> "5.0.403"
[builder]       <unknown>            -> "*"
[builder]       VisierUtility.csproj -> "5.0.*"
[builder]
[builder]     Selected .NET Core SDK version (using RUNTIME_VERSION): 5.0.403
[builder]
[builder]   Reusing cached layer /layers/paketo-buildpacks_dotnet-core-sdk/dotnet-core-sdk
[builder]
[builder]   Configuring environment
[builder]     DOTNET_ROOT -> "/workspace/.dotnet_root"
[builder]     PATH        -> "/workspace/.dotnet_root:$PATH"
[builder]
[builder] Paketo ICU Buildpack 0.1.0
[builder]   Reusing cached layer /layers/paketo-buildpacks_icu/icu
[builder]
[builder] Paketo .NET Publish Buildpack 0.5.1
[builder]   Executing build process
[builder]     Running 'dotnet publish /workspace/src/VisierUtility --runtime ubuntu.18.04-x64 --self-contained false --output /tmp/dotnet-publish-output4081838634 --configuration Debug'
[builder]       Completed in 16.2994317s
[builder]
[builder]   Removing source code
[builder]
[builder] Paketo .NET Execute Buildpack 0.7.0
[builder]   Assigning launch processes
[builder]     web: /workspace/VisierUtility --urls http://0.0.0.0:${PORT:-8080}
[builder]
[builder]
[builder] Paketo Environment Variables Buildpack 4.0.2
[builder]   https://github.com/paketo-buildpacks/environment-variables
[builder]   Launch Configuration:
[builder]     $BPE_<NAME>                prepend value to $NAME, delimiting with OS path list separator
[builder]     $BPE_APPEND_<NAME>         append value to $NAME
[builder]     $BPE_DEFAULT_<NAME>        set default value for $NAME
[builder]     $BPE_DELIM_<NAME>          set delimeter to use when appending or prepending to $NAME
[builder]     $BPE_OVERRIDE_<NAME>       set $NAME to value
[builder]     $BPE_PREPEND_<NAME>        prepend value to $NAME
[builder]   Environment Variables: Reusing cached layer
===> EXPORTING
[exporter] Reusing layer 'paketo-buildpacks/ca-certificates:helper'
[exporter] Reusing layer 'paketo-buildpacks/dotnet-core-runtime:dotnet-core-runtime'
[exporter] Reusing layer 'paketo-buildpacks/dotnet-core-aspnet:dotnet-core-aspnet'
[exporter] Reusing layer 'paketo-buildpacks/dotnet-core-sdk:dotnet-env-var'
[exporter] Reusing layer 'paketo-buildpacks/icu:icu'
[exporter] Reusing layer 'paketo-buildpacks/environment-variables:environment-variables'
[exporter] Reusing 1/1 app layer(s)
[exporter] Reusing layer 'launcher'
[exporter] Reusing layer 'config'
[exporter] Reusing layer 'process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting default process type 'web'
[exporter] Saving visier-utility:latest...
[exporter] *** Images (322c4dc27719):
[exporter]       visier-utility:latest
[exporter] Reusing cache layer 'paketo-buildpacks/dotnet-core-runtime:dotnet-core-runtime'
[exporter] Reusing cache layer 'paketo-buildpacks/dotnet-core-aspnet:dotnet-core-aspnet'
[exporter] Reusing cache layer 'paketo-buildpacks/dotnet-core-sdk:dotnet-core-sdk'
[exporter] Reusing cache layer 'paketo-buildpacks/icu:icu'
Tags used in deployment:
 - visier-utility -> visier-utility:322c4dc27719aced3f2b7515ccda86716adb3fcdbc308a03ad29fb40ead903a7
Starting deploy...
Helm release visier-utility-release not installed. Installing...
coalesce.go:163: warning: skipped value for extraEnvVars: Not a table.
coalesce.go:163: warning: skipped value for extraEnvVars: Not a table.
NAME: visier-utility-release
LAST DEPLOYED: Tue Jan 18 12:26:23 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: aspnet-core
CHART VERSION: 3.0.2
APP VERSION: 6.0.1

** Please be patient while the chart is being deployed **

ASP.NET Core can be accessed through the following DNS name from within your cluster:

    visier-utility-release-web.default.svc.cluster.local (port )

To access ASP.NET Core from outside the cluster execute the following commands:

1. Get the ASP.NET Core URL and associate its hostname to your cluster external IP:

   export CLUSTER_IP=$(minikube ip) # On Minikube. Use: `kubectl cluster-info` on others K8s clusters
   echo "ASP.NET Core URL: http://localhost"
   echo "$CLUSTER_IP  localhost" | sudo tee -a /etc/hosts

2. Access ASP.NET Core using the obtained URL.
Waiting for deployments to stabilize...
Deployments stabilized in 81.4517ms
Port forwarding Service/visier-utility-release-web in namespace default, remote port 80 -> http://127.0.0.1:5000
Press Ctrl+C to exit
Not watching for changes...

The image is using a paketo buildpack for dotnetcore.

When I try to run the debugger in vscode I get the following error:

Starting: "kubectl" exec -i visier-utility-release-web-685d4d45d9-6qdlc -- /dbg/netcore/vsdbg --interpreter=vscode
Error from pipe program 'kubectl': command terminated with exit code 126
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "/dbg/netcore/vsdbg": stat /dbg/netcore/vsdbg: no such file or directory: unknown

There are no annotations on the pod either, so it doesn't have that debug info on it.

When I connect to the pod, there is no /dbg/ folder either.

I do not have a message in the skaffold log about it not being able to determine the debugger, so I'm not sure why it isn't setting up the debugging duct-tape.

tejal29 commented 2 years ago

Sorry @akitson-degreed This fell off my radar. We will look into reproducing this at our end.