Need More Info
Last Updated: 05 Jan 2024 10:39 by ADMIN
Damian
Created on: 29 Dec 2023 18:18
Type: Bug Report
0
Error when running report in Docker container

Hi,

We have today updated our docker reporting container to improve security, and at the same time upgraded to ,NET 8 from .NET 7 (Which worked fine).  The error we're getting from Kubernetes is as shown below..... 

   at Telerik.Reporting.Processing.ReportProcessor.RenderReportSafe(Func`2 renderCallback, String format, IRenderingContext renderingContext)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo, CancellationToken cancellationToken)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo)
   at ReportService.UI.Controllers.API.ReportExportController.GenerateReportPDFBase64(ReportRequestDTO reportRequest) in /src/ReportService.UI/Controllers/API/ReportExportController.cs:line 35
   at lambda_method492(Closure, Object, Object[])
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.UsePathBaseMiddleware.InvokeCore(HttpContext context, PathString matchedPath, PathString remainingPath)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
[18:05:37 INF] HTTP GET /ready responded 200 in 0.1777 ms
[18:05:47 INF] HTTP GET /ready responded 200 in 0.1380 ms
[18:05:57 INF] HTTP GET /ready responded 200 in 0.1588 ms
Logs from 12/29/2023, 5:54:22 PM

 

Our dockerfile is as shown below....

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
ENV ASPNETCORE_HTTP_PORTS=80

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["AppointmentService.Api/NuGet.config", "./"]
COPY ["AppointmentService.Api/AppointmentService.Api.csproj", "AppointmentService.Api/"]
COPY ["AppointmentService.Domain/AppointmentService.Domain.csproj", "AppointmentService.Domain/"]
COPY ["AppointmentService.Infrastructure/AppointmentService.Infrastructure.csproj", "AppointmentService.Infrastructure/"]
COPY ["AppointmentService.Data/AppointmentService.Data.csproj", "AppointmentService.Data/"]

# Set the PAT for the IQHT NuGet feed
ARG IQHTNugetPAT=localhost
RUN sed -i "s|</configuration>|<packageSourceCredentials><iQHealthTech><add key=\"Username\" value=\"IQHTNuget\" /><add key=\"ClearTextPassword\" value=\"${IQHTNugetPAT}\" /></iQHealthTech></packageSourceCredentials></configuration>|g" ./NuGet.config

RUN dotnet restore "AppointmentService.Api/AppointmentService.Api.csproj"
COPY . .
WORKDIR "/src/AppointmentService.Api"
RUN dotnet build "AppointmentService.Api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "AppointmentService.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false

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

Our Kubernetes deployment manifest is as below...


apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    service: appointmentservice
  name: appointmentservice
spec:
  replicas: 1
  selector:
    matchLabels:
      service: appointmentservice
  strategy: {}
  template:
    metadata:
      labels:
        service: appointmentservice
      annotations:
        dapr.io/enabled: "true"
        dapr.io/app-id: "iqht-dev-appointmentservice"
        dapr.io/app-port: "80"
    spec:
      containers:
        - image: acriqemodevuks01.azurecr.io/appointmentservice:v$(Build.BuildNumber)
          securityContext:
            runAsUser: 5678
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsNonRoot: true
          imagePullPolicy: IfNotPresent
          name: appointmentservice
          startupProbe:
            httpGet:
             path: /health/startup
             port: 80
            failureThreshold: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /ready
              port: 80
            successThreshold: 3
          ports:
            - containerPort: 80
          env: 
          - name: "ASPNETCORE_ENVIRONMENT"
            value: "iqemov2-development"
          volumeMounts:
            - name: secrets
              mountPath: /app/secrets
              readOnly: true
          resources: 
            limits:
              cpu: 75m
              memory: 100Mi
            requests:
              cpu: 50m
              memory: 50Mi 
      restartPolicy: Always
      volumes:
        - name: secrets
          secret:
            secretName: secret-appsettings
status: {}
...
apiVersion: v1
kind: Service
metadata:
  labels:
    service: appointmentservice
  name: appointmentservice
  namespace: iqemov2-development
spec:
  type: ClusterIP
  ports:
    - port: 80
      protocol: TCP
  selector:
    service: appointmentservice
status:
  loadBalancer: {}
  

I wonder whether you are able to provide us with some guidance on how we can resolve this issue so that we can deploy it to the customer.

Thanks in advance for any help you can provide to help us resolve this issue.

Regards,

Damian

1 comment
ADMIN
Todor
Posted on: 05 Jan 2024 10:39

Hello Damian,

Based on the stack trace I assume that you render the report with ReportProcessor. Unfortunately, I don't see the exception message.

Did you ensure all the needed packages are installed on the Linux Docker container as specified in the article section Linux Docker Container with SkiaSharp?

Please, attach a Trace Listener to the application to record the logs from our code. I hope it will shed more light on the problem and help us troubleshoot further.

Regards,
Todor
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.