Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging shared libraries before startup for startup hooks usage #4245

Closed
jander-msft opened this issue Apr 13, 2023 · 1 comment
Closed

Staging shared libraries before startup for startup hooks usage #4245

jander-msft opened this issue Apr 13, 2023 · 1 comment

Comments

@jander-msft
Copy link
Member

jander-msft commented Apr 13, 2023

For listen mode with nosuspend or connect mode, we'll need to have the user specify the path if the startup hook truly needs to be available at managed code startup. Because the target application will likely be executing managed code without waiting for .NET Monitor to instruct it to continue, any libraries that are required to exist at startup must be staged in an accessible location for the target process starts. This is problematic for process namespace separated environments such as Docker and Kubernetes where the target application does not have access to the file system of the .NET Monitor image.

To support these scenarios, the .NET Monitor tool should have a mode that can be used to stage the shared libraries BEFORE the target application container is started. This is typically done as an init container in Kubernetes. An example of how this may be used in a deployment is:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deploy-exampleapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: exampleapp
  template:
    metadata:
      labels:
        app: exampleapp
    spec:
      restartPolicy: Always
      initContainers:
      - name: init-diag
        image: mcr.microsoft.com/dotnet/nightly/monitor:8.0.0-preview.3
        args: [ "init-shared-path" ]
        env:
        - name: DOTNETMONITOR_Storage__DefaultSharedPath
          value: /diag
        volumeMounts:
        - mountPath: /diag
          name: diagvol
      containers:
      - name: app
        image: mcr.microsoft.com/dotnet/samples:aspnetapp
        imagePullPolicy: Always
        env:
        - name: ASPNETCORE_URLS
          value: http://+:80
        - name: DOTNET_DiagnosticPorts
          value: /diag/dotnet-monitor.sock,nosuspend
        - name: DOTNET_STARTUP_HOOKS
          value: /diag/libs/8.0.0-preview.3.23180.9/any/net6.0/Microsoft.Diagnostics.Monitoring.StartupHook.dll
        volumeMounts:
        - mountPath: /diag
          name: diagvol
      - name: monitor
        image: mcr.microsoft.com/dotnet/nightly/monitor:8.0.0-preview.3
        args: [ "collect", "--urls", "http://localhost:52323", "--metricUrls", "http://+:52325", "--no-auth" ]
        imagePullPolicy: Always
        env:
        - name: DOTNETMONITOR_DiagnosticPort__ConnectionMode
          value: Listen
        - name: DOTNETMONITOR_Storage__DefaultSharedPath
          value: /diag
        - name: DotnetMonitor_Experimental_Feature_Exceptions
          value: 'true'
        - name: DOTNETMONITOR_InProcessFeatures__Enabled
          value: 'true'
        volumeMounts:
        - mountPath: /diag
          name: diagvol
      volumes:
      - name: diagvol
        emptyDir: {}
@jander-msft
Copy link
Member Author

This was completed with the release of .NET Monitor 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant