GoogleContainerTools / container-debug-support

Language-runtime support files for in-container debugging
Apache License 2.0
93 stars 25 forks source link

init container for dotnet6 debug is broken #103

Closed hlacikd closed 2 years ago

hlacikd commented 2 years ago

Init container gcr.io/k8s-skaffold/skaffold-debug-support/netcore , apparently latest (gcr.io/k8s-skaffold/skaffold-debug-support/netcore@sha256:4b871274583a647eea17e73ffe239eba650a131ee1cb739760981b77985374da)

has non functional vsdbg package which is mounted from install-netcore-debug-support

Starting: "kubectl" exec dotnet-hello-world-5645b65c95-p4847 -c server --namespace dev -i -- /dbg/netcore/vsdbg --interpreter=vscode
Error from pipe program 'kubectl': error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "c708b8347bdde9d005355bb11745cce0d10531fdca6796db38e19206b7d6fc7d": OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: no such file or directory: unknown
The pipe program 'kubectl' exited unexpectedly with code 1.

when i go to console of my container and try to run vsdb

root@dotnet-hello-world-5645b65c95-p4847:/src# /dbg/netcore/vsdbg 
bash: /dbg/netcore/vsdbg: No such file or directory

seems like vsdbg was build using musl and not glibc


root@dotnet-hello-world-5645b65c95-p4847:/src# ldd /dbg/netcore/vsdbg
        linux-vdso.so.1 (0x00007ffc15fd9000)
        libvsdbg.so => /dbg/netcore/libvsdbg.so (0x00007fe8b8aa7000)
        libvsdebugeng.impl.so => /dbg/netcore/libvsdebugeng.impl.so (0x00007fe8b88b6000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe8b86d1000)
        libvsdebugeng.so => /dbg/netcore/libvsdebugeng.so (0x00007fe8b844d000)
        libvsbaseservices.so => /dbg/netcore/libvsbaseservices.so (0x00007fe8b839c000)
        libintl.so.8 => not found
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe8b837f000)
        libc.musl-x86_64.so.1 => not found
        libintl.so.8 => not found
        libc.musl-x86_64.so.1 => not found
        libintl.so.8 => not found
        libc.musl-x86_64.so.1 => not found
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe8b822e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe8b803c000)
        /lib/ld-musl-x86_64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007fe8b8c5f000)
        libintl.so.8 => not found
        libc.musl-x86_64.so.1 => not found
        libintl.so.8 => not found
        libc.musl-x86_64.so.1 => not found

tested with following Dockerfiles :

FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
WORKDIR /src
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
WORKDIR /src
EXPOSE 80
COPY . .
RUN dotnet restore helloworld.csproj
RUN dotnet build "./helloworld.csproj" -c Debug -o /out

FROM build AS publish
RUN dotnet publish helloworld.csproj -c Debug -o /out

# Building final image used in running container
FROM base AS final
# Installing procps on the container to enable debugging of .NET Core
RUN apt-get update \
    && apt-get install -y unzip procps build-essential

WORKDIR /src
COPY --from=publish /out .
ENV ASPNETCORE_URLS=http://*:8080

ENTRYPOINT ["dotnet", "helloworld.dll"]

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /src
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
EXPOSE 80
COPY . .
RUN dotnet restore helloworld.csproj
RUN dotnet build "./helloworld.csproj" -c Debug -o /out

FROM build AS publish
RUN dotnet publish helloworld.csproj -c Debug -o /out

# Building final image used in running container
FROM base AS final
# Installing procps on the container to enable debugging of .NET Core
RUN apt-get update \
    && apt-get install -y unzip procps

WORKDIR /src
COPY --from=publish /out .
ENV ASPNETCORE_URLS=http://*:8080

ENTRYPOINT ["dotnet", "helloworld.dll"]
briandealwis commented 2 years ago

Thank you for reporting this @hlacik — I'm not sure how this happened as we're explicitly downloading for a non-musl runtime. We're lacking tests for netcore, but I've just figured out how to add an integration test so that this won't happen again.

briandealwis commented 2 years ago

@hlacik I apologize, I have staged these images but haven't been able to promote them in time for the production freeze for the holiday period. They will be promoted in the new year.

You can use the staged images however by running:

skaffold config set --global debug-helpers-registry us-central1-docker.pkg.dev/k8s-skaffold/skaffold-staging/skaffold-debug-support
briandealwis commented 2 years ago

The rebuilt netcore images are now released today in v1.1.0. We now select the architecture in a more rigorous manner (#99), and have proper tests (#105) to ensure this situation is caught in the future.