Error "Could not load file or assembly '/app/*.dll'." in attempt to deploy vb.net function
har07 opened this issue · 8 comments
I wrote a function in vb and attempted to deploy it to kubeless. I got it passed the compilation phase, but the function can't be executed and the runtime container has this error log:
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://10.244.2.80:8080/healthz
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'Kubeless.WebAPI.Controllers.RuntimeController.Health (Kubeless.WebAPI)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
Route matched with {action = "Health", controller = "Runtime"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Health() on controller Kubeless.WebAPI.Controllers.RuntimeController (Kubeless.WebAPI).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
Executed action Kubeless.WebAPI.Controllers.RuntimeController.Health (Kubeless.WebAPI) in 4.0448ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'Kubeless.WebAPI.Controllers.RuntimeController.Health (Kubeless.WebAPI)'
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLVF98RHI157", Request id "0HLVF98RHI157:00000001": An unhandled exception was thrown by the application.
System.IO.FileNotFoundException: Could not load file or assembly '/app/*.dll'. The system cannot find the file specified.
File name: '/app/*.dll'
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at Kubeless.Core.Invokers.CompiledFunctionInvoker.LoadAssembly(String path) in /app/Kubeless.Core/Invokers/CompiledFunctionInvoker.cs:line 37
at Kubeless.Core.Invokers.CompiledFunctionInvoker..ctor(IFunction function, Int32 functionTimeout) in /app/Kubeless.Core/Invokers/CompiledFunctionInvoker.cs:line 26
at Kubeless.WebAPI.Startup.<>c__DisplayClass4_0.<ConfigureServices>b__0(IServiceProvider _) in /app/Kubeless.WebAPI/Startup.cs:line 30
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>b__0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
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 where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
Is it the assembly path should be /app/project.dll
instead of /app/*.dll
? If this is the case where is this /app/*
.dll came from or where to look to fix this wrong path?
I am using compilation and runtime image from dotnetcore3.1 runtime to define new runtime that support vb.net. This is what I added to kubeless-config
configmap (following these steps):
{
"ID": "vbdotnetcore",
"depName": "project.vbproj",
"fileNameSuffix": ".vb",
"versions": [
{
"images": [
{
"command": "/app/compile-function.sh $KUBELESS_INSTALL_VOLUME",
"image": "lorenzoangelini3/kubeless-compile-dotnetcore31@sha256:4e6adfe873f7c4cd5e0d582bb5122f94c6d6ea73baa03b486dd93b8406deb8ca",
"phase": "compilation"
},
{
"env": {
"DOTNETCORE_HOME": "$(KUBELESS_INSTALL_VOLUME)/packages"
},
"image": "lorenzoangelini3/kubeless-runtime-dotnetcore31@sha256:4a2d94bd6da4aee612a2009d863beb554c43e61199d8d3fc4bf2d28b5673940b",
"phase": "runtime"
}
],
"name": "vbdotnetcore3.1",
"version": "3.1"
}
]
}
This is my function definition:
Imports System
Imports Kubeless.Functions
Class [module]
Public Async Function handler(ByVal k8Event As [Event], ByVal k8Context As Context) As Task(Of Object)
Return "Happy coding!"
End Function
End Class
vbproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp31</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Kubeless.Functions" Version="0.1.1" />
</ItemGroup>
</Project>
Hi @lorenzo-ange, I'm sorry to keep mentioning you. Since this is using dotnetcore 3.1 runtime and the error seems to be related to loading assembly which you have experience with (the last pull request of yours), maybe you have some insight and can give direction on where to look to fix this error?
Hi @har07 ,
can you try to deploy it adding the flag --env ASSEMBLY_NAME=project
?
for example:
kubeless function deploy ... --env ASSEMBLY_NAME=project
?
Hi @lorenzo-ange , thanks a lot for your suggestion. It get rid of the assembly loading error. Now I got this new error:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLVIBMOV8P89", Request id "0HLVIBMOV8P89:00000001": An unhandled exception was thrown by the application.
System.ArgumentNullException: Value cannot be null. (Parameter 'type')
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at Kubeless.Core.Invokers.CompiledFunctionInvoker..ctor(IFunction function, Int32 functionTimeout) in /app/Kubeless.Core/Invokers/CompiledFunctionInvoker.cs:line 29
at Kubeless.WebAPI.Startup.<>c__DisplayClass4_0.<ConfigureServices>b__0(IServiceProvider _) in /app/Kubeless.WebAPI/Startup.cs:line 30
at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope )
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>b__0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
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 where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
If I understand this correctly, function.ModuleName
was not found in project.dll, but I'm not sure what was the value of function.ModuleName
. Any idea?
@har07 I never tested the runtime with VB functions, but I'm really happy that, with your help, we can check why it doesn't work.
It seems the runtime cannot load correctly your function code.
Can you please try deploy with these explicit env vars: --env ASSEMBLY_NAME=project --env MOD_NAME=module --env FUNC_HANDLER=handler
?
@lorenzo-ange I just tried deploying with those env vars. Unfortunately, the error didn't change. I also tried using different module name like 'vbmodule' since 'module' is a keyword in vb, but still got the same error.:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLVIUA2C57AS", Request id "0HLVIUA2C57AS:00000001": An unhandled exception was thrown by the application.
System.ArgumentNullException: Value cannot be null. (Parameter 'type')
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at Kubeless.Core.Invokers.CompiledFunctionInvoker..ctor(IFunction function, Int32 functionTimeout) in /app/Kubeless.Core/Invokers/CompiledFunctionInvoker.cs:line 29
Hi @har07 ,
while deploying with --env ASSEMBLY_NAME=project --env MOD_NAME=module --env FUNC_HANDLER=handler
can you please try adding Public modifier to your VB class?
Imports System
Imports Kubeless.Functions
Public Class [module]
Public Async Function handler(ByVal k8Event As [Event], ByVal k8Context As Context) As Task(Of Object)
Return "Happy coding!"
End Function
End Class
@har07 any news on this? did you manage to run succesfully the function?
Hi @lorenzo-ange , I am sorry for the very long wait. The development server that I use for experimenting with kubeless was being migrated to a different data center.
Now that I regain access to the server, I tried adding public modifier to the vb class, exactly as you suggested. Then deployed the function with all parameters set:
kubeless function deploy dotnet-vb \
--runtime vbdotnetcore3.1 \
--from-file test.vb \
--dependencies test.vbproj \
--env ASSEMBLY_NAME=project \
--env MOD_NAME=module \
--env FUNC_HANDLER=handler \
--handler module.handler
Unfortunately, I still get this error:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLVSE2DKQI2C", Request id "0HLVSE2DKQI2C:00000001": An unhandled exception was thrown by the application.
System.ArgumentNullException: Value cannot be null. (Parameter 'type')
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at Kubeless.Core.Invokers.CompiledFunctionInvoker..ctor(IFunction function, Int32 functionTimeout) in /app/Kubeless.Core/Invokers/CompiledFunctionInvoker.cs:line 29
at Kubeless.WebAPI.Startup.<>c__DisplayClass4_0.<ConfigureServices>b__0(IServiceProvider _) in /app/Kubeless.WebAPI/Startup.cs:line 30
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>b__0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
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 where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)