Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,24 @@ jobs:
with:
command: run
profile: tensorflow-serving
dotnet8:
runs-on: ubuntu-latest
needs: check
if: contains(needs.check.outputs.packages, 'dotnet8')
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Fission Environment
uses: ./.github/actions/setup-cluster
- name: Fission and Test images
run: |
SKAFFOLD_PROFILE=dotnet8 make skaffold-run
make dotnet8-test-images
make router-port-forward
- name: dotnet8-tests
run: ./test_utils/run_test.sh ./dotnet8/tests/test_dotnet8_env.sh
- name: Collect Fission Dump
uses: ./.github/actions/collect-fission-dump
if: ${{ failure() }}
with:
workflow-name: dotnet8
2 changes: 2 additions & 0 deletions .github/workflows/filters/filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ dotnet:
- 'dotnet/**'
dotnet20:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also check code in donet20 and if we can consolidate both ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by consolidate both by looking at dotnet20 code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think let it be, I was exploring if we can keep only one env.
But this can done later once dotnet8 is released

- 'dotnet20/**'
dotnet8:
- 'dotnet8/**'
go:
- 'go/**'
jvm:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/filters/version_filter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ dotnet:
- 'dotnet/envconfig.json'
dotnet20:
- 'dotnet20/envconfig.json'
dotnet8:
- 'dotnet8/envconfig.json'
go:
- 'go/envconfig.json'
jvm:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ FISSION_ENVS := nodejs-envs \
binary-envs \
tensorflow-serving-envs \
dotnet20-envs \
dotnet8-envs \
ruby-envs

all: $(FISSION_ENVS)
Expand Down Expand Up @@ -91,5 +92,9 @@ python-fastapi-test-images:
@kind load docker-image python-fastapi-env
@kind load docker-image python-fastapi-builder

dotnet8-test-images:
@kind load docker-image dotnet8-env
@kind load docker-image dotnet8-builder

router-port-forward:
@kubectl port-forward svc/router 8888:80 -nfission &
60 changes: 60 additions & 0 deletions dotnet8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/

# Visual Studio cache/options directory
.vs/

# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/

# Files built by Visual Studio
*.user
*.userosscache
*.sln.docstates

# Build results
*.dll
*.exe
*.pdb
*.cache
*.log

# NuGet Packages
*.nupkg
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/

# Example ZIP files (for testing)
examples/**/*.zip

# macOS
.DS_Store
32 changes: 32 additions & 0 deletions dotnet8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use the .NET 8 SDK image for runtime (needed for compilation support)
FROM mcr.microsoft.com/dotnet/sdk:8.0

# Install required tools
RUN apt-get update && apt-get install -y unzip curl && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy the Fission .NET runtime application
COPY Fission.DotNet/ /app/Fission.DotNet/
COPY Fission.DotNet.Common/ /app/Fission.DotNet.Common/

# Build the runtime application
RUN dotnet restore Fission.DotNet/Fission.DotNet.csproj
RUN dotnet publish Fission.DotNet/Fission.DotNet.csproj -c Release -o /app/publish

# Build and copy Fission.DotNet.Common.dll to /app for runtime compilation
RUN dotnet build Fission.DotNet.Common/Fission.DotNet.Common.csproj -c Release -o /app/

# Create function directory
RUN mkdir -p /function

# Set environment variables
ENV ASPNETCORE_URLS=http://*:8888
ENV ASPNETCORE_ENVIRONMENT=Production

# Expose port
EXPOSE 8888

# Start the runtime
CMD ["dotnet", "/app/publish/Fission.DotNet.dll"]
26 changes: 26 additions & 0 deletions dotnet8/Fission.DotNet.Common/Fission.DotNet.Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<PackageId>Fission.DotNet.Common</PackageId>
<Version>1.1.0</Version>
<Authors>Lorenzo Caldon</Authors>
<Description>Fission dotnet environment common package</Description>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<RepositoryUrl>https://github.com/lcsoft77/fission-env-dotnet8</RepositoryUrl>
<PackageOutputPath>./nupkg</PackageOutputPath>
</PropertyGroup>

<PropertyGroup>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
24 changes: 24 additions & 0 deletions dotnet8/Fission.DotNet.Common/Fission.DotNet.Common.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fission.DotNet.Common", "Fission.DotNet.Common.csproj", "{66CA3524-4798-6315-18DF-47CD0B936395}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{66CA3524-4798-6315-18DF-47CD0B936395}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66CA3524-4798-6315-18DF-47CD0B936395}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66CA3524-4798-6315-18DF-47CD0B936395}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66CA3524-4798-6315-18DF-47CD0B936395}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AF6A70F1-84DB-4983-A581-08BC54DF98A5}
EndGlobalSection
EndGlobal
76 changes: 76 additions & 0 deletions dotnet8/Fission.DotNet.Common/FissionContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace Fission.DotNet.Common;

public class FissionContext
{
protected Stream _content;
protected Dictionary<string, object> _arguments;
protected Dictionary<string, string> _headers;
protected Dictionary<string, string> _parameters;

public FissionContext(Stream body, Dictionary<string, object> arguments, Dictionary<string, string> headers, Dictionary<string, string> parameters)
{
if (body == null) throw new ArgumentNullException(nameof(body));
if (arguments == null) throw new ArgumentNullException(nameof(arguments));
if (headers == null) throw new ArgumentNullException(nameof(headers));
if (parameters == null) throw new ArgumentNullException(nameof(parameters));

_content = body;
_arguments = arguments;
_headers = headers;
_parameters = parameters;
}

protected string GetHeaderValue(string key, string defaultValue = null)
{
return _headers.ContainsKey(key) ? _headers[key] : defaultValue;
}

public Dictionary<string, object> Arguments => _arguments;
public Dictionary<string, string> Parameters => _parameters;

public string TraceID => GetHeaderValue("traceparent", Guid.NewGuid().ToString());
public string FunctionName => GetHeaderValue("X-Fission-Function-Name");
public string Namespace => GetHeaderValue("X-Fission-Function-Namespace");
public string ResourceVersion => GetHeaderValue("X-Fission-Function-Resourceversion");
public string UID => GetHeaderValue("X-Fission-Function-Uid");
public string Trigger => GetHeaderValue("Source-Name");
public string ContentType => GetHeaderValue("Content-Type");
public Int32 ContentLength => GetHeaderValue("Content-Length") != null ? Int32.Parse(GetHeaderValue("Content-Length")) : 0;
public Stream Content => _content;

public async Task<string?> ContentAsString()
{
if (_content == null)
{
return null;
}

_content.Position = 0;
using (StreamReader reader = new StreamReader(_content, Encoding.UTF8, leaveOpen: true))
{
return await reader.ReadToEndAsync();
}
}

public async Task<T> ContentAs<T>(JsonSerializerOptions? options = null)
{
if (_content == null)
{
return default;
}

_content.Position = 0;
using (StreamReader reader = new StreamReader(_content, Encoding.UTF8, leaveOpen: true))
{
string content = await reader.ReadToEndAsync();
return JsonSerializer.Deserialize<T>(content, options);
}
}
}
44 changes: 44 additions & 0 deletions dotnet8/Fission.DotNet.Common/FissionHttpContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;

namespace Fission.DotNet.Common;

public class FissionHttpContext : FissionContext
{
private string _method;

public FissionHttpContext(Stream body, string method, Dictionary<string, object> arguments, Dictionary<string, string> headers, Dictionary<string, string> parameters) : base(body, arguments, headers, parameters)
{
_method = method;
}

public Dictionary<string, string> Headers => _headers;
public string Url
{
get
{
var urlHeader = GetHeaderValue("X-Fission-Full-Url");

if (urlHeader != null)
{
if (urlHeader.Contains("?"))
{
urlHeader = urlHeader.Substring(0, urlHeader.IndexOf("?"));
}

return urlHeader;
}
else
{
return "/";
}
}
}
public string Method => _method;
public string Host => GetHeaderValue("X-Forwarded-Host");
public int Port => _headers.ContainsKey("X-Forwarded-Port") ? Int32.Parse(GetHeaderValue("X-Forwarded-Port")) : 0;
public string UserAgent => GetHeaderValue("User-Agent");
}
17 changes: 17 additions & 0 deletions dotnet8/Fission.DotNet.Common/FissionMqContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.IO;

namespace Fission.DotNet.Common;

public class FissionMqContext : FissionContext
{
public FissionMqContext(Stream body, Dictionary<string, object> arguments, Dictionary<string, string> headers, Dictionary<string, string> parameters) : base(body, arguments, headers, parameters)
{

}

public string Topic => GetHeaderValue("Topic");
public string ErrorTopic => GetHeaderValue("Errortopic");
public string ResponseTopic => GetHeaderValue("Resptopic");
}
16 changes: 16 additions & 0 deletions dotnet8/Fission.DotNet.Common/ICorsPolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace Fission.DotNet.Common
{
public interface ICorsPolicy
{
void AllowAnyOrigin();
void AllowAnyHeader();
void AllowAnyMethod();
void AllowCredentials();

void WithOrigin(string[] origin);
void WithHeader(string[] header);
void WithMethod(string[] method);
}
}
14 changes: 14 additions & 0 deletions dotnet8/Fission.DotNet.Common/ILogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace Fission.DotNet.Common
{
public interface ILogger
{
void LogInformation(string message);
void LogDebug(string message);
void LogWarning(string message);
void LogError(string message);
void LogCritical(string message);
void LogError(string message, Exception exception);
}
}
Loading