Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

C#: Namespaced support for functions #85

Open
Poimen opened this issue Aug 7, 2020 · 6 comments
Open

C#: Namespaced support for functions #85

Poimen opened this issue Aug 7, 2020 · 6 comments

Comments

@Poimen
Copy link

Poimen commented Aug 7, 2020

This issue has been reported before and apparently resolved, however, I'm curious if I'm perhaps I'm implementing this incorrectly or running an old version.

For my test I'm using the example file namespaced-helloget and using the deployment command

kubeless function deploy helloget2 --runtime dotnetcore3.1 --from-file Functions/namespaced-helloget.cs --handler module.handler

I wait for the function to be loaded:

helloget2       default         module.handler          dotnetcore3.1                                   1/1 READY

Then attempt to call the function:

kubeless function call helloget2

This results in the error:

$ kubeless function call helloget2
ERRO[0000]                                              
FATA[0000] an error on the server ("") has prevented the request from succeeding (get services helloget2:http-function-port)

The logs show:

$ kubectl logs helloget2-5b9dd69dbf-scrxh
cp: cannot create regular file '/app/Kubeless.Functions.dll': Permission denied
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://[::]:8080
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /app
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://127.0.0.1:44929/  
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'Kubeless.WebAPI.Controllers.RuntimeController.Execute (Kubeless.WebAPI)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
      Route matched with {action = "Execute", controller = "Runtime"}. Executing controller action with signature System.Threading.Tasks.Task`1[System.Object] Execute() on controller Kubeless.WebAPI.Controllers.RuntimeController (Kubeless.WebAPI).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
      Executed action Kubeless.WebAPI.Controllers.RuntimeController.Execute (Kubeless.WebAPI) in 2.2701ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Kubeless.WebAPI.Controllers.RuntimeController.Execute (Kubeless.WebAPI)'
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM1QSHPHL081", Request id "0HM1QSHPHL081: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)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 58.0324ms 500 
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://10.244.0.14: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 2.9038ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Kubeless.WebAPI.Controllers.RuntimeController.Health (Kubeless.WebAPI)'
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM1QSHPHL082", Request id "0HM1QSHPHL082: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)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 18.5316ms 500 
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://10.244.0.14: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 2.0856ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'Kubeless.WebAPI.Controllers.RuntimeController.Health (Kubeless.WebAPI)'
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HM1QSHPHL083", Request id "0HM1QSHPHL083: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)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 9.5518ms 500 

If this is an error on my part, please could you point to the correct usage pattern?

--- edit
I should mention that this works fine without the namespaced version.

@har07
Copy link

har07 commented Aug 12, 2020

I have seen similar error message when trying .net core 3.1 runtime (with a little modification) for running vb.net function: #68, unfortunately I still can't get it working so far.

@Poimen
Copy link
Author

Poimen commented Aug 14, 2020

After some more digging around - this appears to be working:

kubeless function deploy helloget2 --runtime dotnetcore2.2 --from-file Functions/namespaced-helloget.cs --handler module.handler

The switch to 3.1 appears to be causing the issue

@Poimen Poimen closed this as completed Aug 14, 2020
@Poimen
Copy link
Author

Poimen commented Aug 14, 2020

Sorry - clicked the wrong button

@Poimen Poimen reopened this Aug 14, 2020
@har07
Copy link

har07 commented Aug 15, 2020

Can you post the content of namespaced-helloget.cs?

@Poimen
Copy link
Author

Poimen commented Aug 15, 2020

The content is the same as:
https://github.com/kubeless/runtimes/blob/master/stable/dotnetcore/examples-2x/namespaced-helloget.cs

I used the Makefile command:

kubeless function deploy get-dotnetcore-namespaced22 --runtime dotnetcore2.2 --handler module.handler --from-file examples-2x/namespaced-helloget.cs

and this worked.

Updating that command to:

kubeless function deploy get-dotnetcore-namespaced31 --runtime dotnetcore3.1 --handler module.handler --from-file examples-2x/namespaced-helloget.cs

cause the break to manifest

@har07
Copy link

har07 commented Aug 29, 2020

The 3.1 runtime supposed to have different function signature due to migration of synchronous code to async. I posted example function that worked in the other thread #67 (comment), or you can try this:

using System;
using System.Threading.Tasks;
using Kubeless.Functions;

public class module
{
    public async Task<object> handler(Event k8Event, Context k8Context)
    {
        return "hello world";
    }
}

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

No branches or pull requests

2 participants