cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynatrace OneAgent failed to start in PowerShell Core 7

tianmiaohu-fis
Visitor

Environment details: docker image running under OpenShift 3.11

OS: ubuntu:22.04
Runtime: powershell-7.3.2-linux-x64
The OpenShift job tries to execute a PowerShell script with the following setup:
        command: ["/usr/bin/pwsh"]
        args: ["/data/deploy.ps1"]
The setup works fine without OneAgent.  Got the below error with OneAgent.  How can I solve this issue?

AgentStatus=Failed (Initializing), AD=pwsh[1]
Failed to initialize agent: Cannot marshal 'parameter #1': Cannot marshal managed types when the runtime marshalling system is disabled.
   at Dynatrace.OneAgent.Sto.Detail.NativeSemanticTracingApi.NativeMethods.semanticTracing_isChannelEnabled(String name)
   at Dynatrace.OneAgent.Sto.Detail.NativeSemanticTracingApi.IsChannelEnabled(String name)
   at Dynatrace.OneAgent.Sto.Trace.IsChannelEnabled(String channelName)
   at Dynatrace.OneAgent.Sto.Trace.GetChannel(String channelName)
   at Dynatrace.OneAgent.Sto.SemanticTracer.GetTracer(String channelName, String loggingPrefix, String className, String methodName)
   at Dynatrace.OneAgent.Sto.SemanticTracer.GetTracer(String channelName, String className, String methodName)
   at Dynatrace.OneAgent.Agent.InitializeAgent()
Unhandled exception. System.Threading.Tasks.TaskSchedulerException: An exception was thrown by a TaskScheduler.
---> System.TypeInitializationException: The type initializer for 'Dynatrace.OneAgent.Sampling.ThreadRegistryEx' threw an exception.
---> System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #1': Cannot marshal managed types when the runtime marshalling system is disabled.
   at Dynatrace.OneAgent.AgentNative.runtimeConfigGetBool(String configName, Boolean defaultValue)
   at Dynatrace.OneAgent.Sampling.ThreadRegistryEx..cctor()
   --- End of inner exception stack trace ---
   at Dynatrace.OneAgent.Sampling.ThreadRegistryEx.NotifyThreadControlMethodEnter(Object threadObject, Int32 ctrlType)
   at System.Threading.Thread.Start(Boolean captureContext, Boolean internalThread)
   at System.Threading.Thread.UnsafeStart()
   at System.Threading.PortableThreadPool.WorkerThread.TryCreateWorkerThread()
   at System.Threading.PortableThreadPool.WorkerThread.MaybeAddWorkingWorker(PortableThreadPool threadPoolInstance)
   at System.Threading.PortableThreadPool.RequestWorker()
   at System.Threading.ThreadPool.RequestWorkerThread()
   at System.Threading.ThreadPoolWorkQueue.Enqueue(Object callback, Boolean forceGlobal)
   at System.Threading.ThreadPool.UnsafeQueueUserWorkItemInternal(Object callBack, Boolean preferLocal)
   at System.Threading.Tasks.ThreadPoolTaskScheduler.QueueTask(Task task)
   at System.Threading.Tasks.TaskScheduler.InternalQueueTask(Task task)
   at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
   at System.Threading.Tasks.Task.InternalStartNew(Task creatingTask, Delegate action, Object state, CancellationToken cancellationToken, TaskScheduler scheduler, TaskCreationOptions options, InternalTaskOptions internalOptions)
   at System.Threading.Tasks.Task.Run(Action action)
   at System.Management.Automation.Runspaces.EarlyStartup.Init()
   at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
   at Microsoft.PowerShell.ManagedPSEntry.Main(String[] args)

1 REPLY 1

tianmiaohu-fis
Visitor

The root cause was that Dynatrace currently only supports .Net 6 which maps to PowerShell 7.2.10.  The error was due to PowerShell 7.3.2 that maps to .Net 7.  After downgrading to PowerShell 7.2.10, the error no longer appears.

Featured Posts