dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.28k stars 4.73k forks source link

.NET 6 with specific Dynatrace versions does not start up in a AKS, and produces no logs #64760

Closed aullom1 closed 2 years ago

aullom1 commented 2 years ago

Description

I have a .NET 6 API that I would like to run in AKS. Locally it works just fine. In AKS the pod will start up, but the container produces no logs and refuses all connections. I can exec into the container and run dotnet MyApp.Api.dll but the command will just hang and not write any output.

Exec'ing into the container and manually running dotnet MyApp.Api.dll will just hang and produce no output.

Reproduction Steps

Generate a minimal .NET 6 webapi (.e.g dotnet new webapi -minimal -o MyApp.Api).

Create a Dockerfile and build and push to a repo.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app

# Switch the default port from 80 to 5000
ENV ASPNETCORE_URLS=http://+:5000 \
    # Enable detection of running in a container
    DOTNET_RUNNING_IN_CONTAINER=true

EXPOSE 5000

# Create a group and user to run the ASP.NET Core application
RUN addgroup --system dotnetappgroup && \
    adduser --system --ingroup dotnetappgroup --shell /bin/sh dotnetappuser && \
    mkdir -p /local/ && \
    chown dotnetappuser:dotnetappgroup /local && \
    chown dotnetappuser:dotnetappgroup /app

# Update Docker to run all future commands as the appuser user.
USER dotnetappuser

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG NuGetConfig=NuGet.Config
WORKDIR /src
COPY . .
RUN dotnet restore "MyApp.Api/MyApp.Api.csproj"
WORKDIR "/src/MyApp.Api"
RUN dotnet build "MyApp.Api.csproj" -c Release -o /app/build --no-restore

FROM build AS publish
RUN dotnet publish "MyApp.Api.csproj" -c Release -o /app/publish --no-restore

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]

Create an AKS cluster. Obviously there can be a ton of variability here. I am using:

Kubernetes version 1.20.9
Node image version AKSUbuntu-1804gen2containerd-2021.10.19
Container runtime version containerd://1.4.9+azure

Deploy your app. The important bits about the manifest are:

image: <YOUR_IMAGE_REFERENCE>
imagePullPolicy: Always
name: myapp
ports:
- containerPort: 5000
  protocol: TCP
resources:
  limits:
    cpu: 200m
    memory: 500Mi
  requests:
    cpu: 100m
    memory: 200Mi

Expected behavior

The pod should start up, and the logs should show the typical startup output (e.g. Now listening on port...).

Actual behavior

The pod reports that it is running, but there are no logs, and all connections are refused.

Regression?

Prior versions of .NET Core do not have this problem.

Known Workarounds

No response

Configuration

No response

Other information

No response

CaveSven commented 2 years ago

Not working: 1.221.132.20210728-085542, 1.223.105.20210824-140926 Working: 1.231.245.20220112-085307

mangod9 commented 2 years ago

So guessing we could close this now since this is Dynatrace specific? The repro artifacts listed in the original didnt have any Dynatrace references?

aullom1 commented 2 years ago

Yes, I think this can be closed.

mangod9 commented 2 years ago

Ok thanks, I have updated the title for clarity and hoping Dynatrace is able to provide some RCA for the issue.

CaveSven commented 2 years ago

Here is a compatibility matrix between .NET and Dynatrace: https://www.dynatrace.com/support/help/technology-support/application-software/dotnet#net-and-net-core

ivanthelad commented 2 years ago

@CaveSven did your issue get resolved ?