Skip to content

Commit 20bc1c0

Browse files
committed
feat(Runtime): Refactored runtimes by removing Containerized runtime and replacing it with DockerRuntime and KubernetesRuntime implementations
Signed-off-by: Charles d'Avernas <[email protected]>
1 parent bdcf723 commit 20bc1c0

32 files changed

+1165
-246
lines changed

Synapse.sln

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "runner", "runner", "{1DA47E
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core", "src\core\Synapse.Core\Synapse.Core.csproj", "{F2804D69-04C9-463D-B5E5-D3185163EBC0}"
1919
EndProject
20-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core.Infrastructure.Containers.Docker", "src\core\Synapse.Core.Infrastructure.Containers.Docker\Synapse.Core.Infrastructure.Containers.Docker.csproj", "{40EB503E-6E97-4375-A172-6EF55F9E0FF3}"
21-
EndProject
2220
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{63715FC0-736D-4972-A865-41126155DF45}"
2321
EndProject
2422
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Dashboard", "src\dashboard\Synapse.Dashboard\Synapse.Dashboard.csproj", "{A9BB7219-B24B-4E40-B10A-69E618BDA272}"
@@ -58,8 +56,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Abstraction
5856
EndProject
5957
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Native", "src\runtime\Synapse.Runtime.Native\Synapse.Runtime.Native.csproj", "{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}"
6058
EndProject
61-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runtime.Containerized", "src\runtime\Synapse.Runtime.Containerized\Synapse.Runtime.Containerized.csproj", "{F327B8F1-9A13-4924-AE1B-E69788AC73E7}"
62-
EndProject
6359
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Runner", "src\runner\Synapse.Runner\Synapse.Runner.csproj", "{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}"
6460
EndProject
6561
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Dashboard.StateManagement", "src\dashboard\Synapse.Dashboard.StateManagement\Synapse.Dashboard.StateManagement.csproj", "{91EF9F64-4997-407C-B353-C26B1421D0FB}"
@@ -104,7 +100,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "images", "images", "{811240
104100
assets\images\transparent_logo.png = assets\images\transparent_logo.png
105101
assets\images\transparent_logomark.ico = assets\images\transparent_logomark.ico
106102
assets\images\transparent_logomark.png = assets\images\transparent_logomark.png
107-
assets\images\transparent_logomark_256.png = assets\images\transparent_logomark_256.png
108103
assets\images\transparent_logomark_black.png = assets\images\transparent_logomark_black.png
109104
assets\images\transparent_logomark_white.png = assets\images\transparent_logomark_white.png
110105
assets\images\transparent_logo_black.png = assets\images\transparent_logo_black.png
@@ -133,6 +128,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{
133128
deployments\helm\templates\services.yaml = deployments\helm\templates\services.yaml
134129
EndProjectSection
135130
EndProject
131+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Docker", "src\runtime\Synapse.Runtime.Docker\Synapse.Runtime.Docker.csproj", "{8FF58403-9E13-4F58-864F-E6FBC877BF37}"
132+
EndProject
133+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synapse.Runtime.Kubernetes", "src\runtime\Synapse.Runtime.Kubernetes\Synapse.Runtime.Kubernetes.csproj", "{9B37AA4A-A342-4A41-A2A1-C8466825A70A}"
134+
EndProject
135+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Synapse.Core.Infrastructure.Containers.Docker", "src\core\Synapse.Core.Infrastructure.Containers.Docker\Synapse.Core.Infrastructure.Containers.Docker.csproj", "{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}"
136+
EndProject
136137
Global
137138
GlobalSection(SolutionConfigurationPlatforms) = preSolution
138139
Debug|Any CPU = Debug|Any CPU
@@ -143,10 +144,6 @@ Global
143144
{F2804D69-04C9-463D-B5E5-D3185163EBC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
144145
{F2804D69-04C9-463D-B5E5-D3185163EBC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
145146
{F2804D69-04C9-463D-B5E5-D3185163EBC0}.Release|Any CPU.Build.0 = Release|Any CPU
146-
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
147-
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
148-
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
149-
{40EB503E-6E97-4375-A172-6EF55F9E0FF3}.Release|Any CPU.Build.0 = Release|Any CPU
150147
{A9BB7219-B24B-4E40-B10A-69E618BDA272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
151148
{A9BB7219-B24B-4E40-B10A-69E618BDA272}.Debug|Any CPU.Build.0 = Debug|Any CPU
152149
{A9BB7219-B24B-4E40-B10A-69E618BDA272}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -191,10 +188,6 @@ Global
191188
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Debug|Any CPU.Build.0 = Debug|Any CPU
192189
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Release|Any CPU.ActiveCfg = Release|Any CPU
193190
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888}.Release|Any CPU.Build.0 = Release|Any CPU
194-
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
195-
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
196-
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
197-
{F327B8F1-9A13-4924-AE1B-E69788AC73E7}.Release|Any CPU.Build.0 = Release|Any CPU
198191
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
199192
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}.Debug|Any CPU.Build.0 = Debug|Any CPU
200193
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -219,6 +212,18 @@ Global
219212
{A2D3AFB0-C7E0-4778-9D0A-DFCE0E24AF17}.Debug|Any CPU.Build.0 = Debug|Any CPU
220213
{A2D3AFB0-C7E0-4778-9D0A-DFCE0E24AF17}.Release|Any CPU.ActiveCfg = Release|Any CPU
221214
{A2D3AFB0-C7E0-4778-9D0A-DFCE0E24AF17}.Release|Any CPU.Build.0 = Release|Any CPU
215+
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
216+
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Debug|Any CPU.Build.0 = Debug|Any CPU
217+
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Release|Any CPU.ActiveCfg = Release|Any CPU
218+
{8FF58403-9E13-4F58-864F-E6FBC877BF37}.Release|Any CPU.Build.0 = Release|Any CPU
219+
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
220+
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Debug|Any CPU.Build.0 = Debug|Any CPU
221+
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Release|Any CPU.ActiveCfg = Release|Any CPU
222+
{9B37AA4A-A342-4A41-A2A1-C8466825A70A}.Release|Any CPU.Build.0 = Release|Any CPU
223+
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
224+
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
225+
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
226+
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA}.Release|Any CPU.Build.0 = Release|Any CPU
222227
EndGlobalSection
223228
GlobalSection(SolutionProperties) = preSolution
224229
HideSolutionNode = FALSE
@@ -230,7 +235,6 @@ Global
230235
{32EAD165-3D99-42CD-B3AF-05136DCC7F35} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
231236
{1DA47E5F-B23A-4D3C-96AA-4BD2662AB946} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
232237
{F2804D69-04C9-463D-B5E5-D3185163EBC0} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
233-
{40EB503E-6E97-4375-A172-6EF55F9E0FF3} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
234238
{63715FC0-736D-4972-A865-41126155DF45} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
235239
{A9BB7219-B24B-4E40-B10A-69E618BDA272} = {7DF998B8-0FB1-470E-8ED0-EA1CC7B16901}
236240
{327FF68E-E729-4616-B1BE-B262A95890A2} = {63715FC0-736D-4972-A865-41126155DF45}
@@ -244,7 +248,6 @@ Global
244248
{175CE1C5-FE17-4C8B-8823-E812BAD4E527} = {4B9AF05C-9D6D-48C0-994D-D4A5C28FA24D}
245249
{A0E5E7F2-8C9C-4F36-B3FD-C09074893023} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
246250
{DC24E506-602F-4FD9-B8C0-CEA6B2AD8888} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
247-
{F327B8F1-9A13-4924-AE1B-E69788AC73E7} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
248251
{E5FAA9BA-07C3-49CF-AD3B-897AE1D0B018} = {1DA47E5F-B23A-4D3C-96AA-4BD2662AB946}
249252
{91EF9F64-4997-407C-B353-C26B1421D0FB} = {7DF998B8-0FB1-470E-8ED0-EA1CC7B16901}
250253
{A9085F4A-5FDF-4F4A-B267-A03BC5E0FDB0} = {32EAD165-3D99-42CD-B3AF-05136DCC7F35}
@@ -256,6 +259,9 @@ Global
256259
{2A6EE5DF-BD7E-4CC6-BB9B-7BE5FC128302} = {750922F9-5C47-42FE-945F-576818E6DEC9}
257260
{B6A96DC3-E57A-4022-9279-1DB57744C893} = {562C91A3-6E91-4489-9D9D-064E7436D900}
258261
{3F5CCCE8-46F8-4873-8EF9-38E14EAE7E01} = {B6A96DC3-E57A-4022-9279-1DB57744C893}
262+
{8FF58403-9E13-4F58-864F-E6FBC877BF37} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
263+
{9B37AA4A-A342-4A41-A2A1-C8466825A70A} = {175CE1C5-FE17-4C8B-8823-E812BAD4E527}
264+
{DD6381BD-2C8B-4CE1-99B2-EC585DD818FA} = {9E296C8A-4D78-4592-B046-11A3A953FD25}
259265
EndGlobalSection
260266
GlobalSection(ExtensibilityGlobals) = postSolution
261267
SolutionGuid = {2A6C03D6-355A-4B39-9F2B-D0FDE429C0E2}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace Synapse;
15+
16+
/// <summary>
17+
/// Enumerates all default container image pull policies
18+
/// </summary>
19+
public static class ImagePullPolicy
20+
{
21+
22+
/// <summary>
23+
/// Gets the policy that specifies that the image should always be pulled
24+
/// </summary>
25+
public const string Always = "Always";
26+
/// <summary>
27+
/// Gets the policy that specifies that the image should be pulled only if it is not already present locally
28+
/// </summary>
29+
public const string IfNotPresent = "IfNotPresent";
30+
/// <summary>
31+
/// Gets the policy that specifies that the image should never be pulled
32+
/// </summary>
33+
public const string Never = "Never";
34+
35+
/// <summary>
36+
/// Gets a new <see cref="IEnumerable{T}"/> containing all default container image pull policies
37+
/// </summary>
38+
/// <returns>A new <see cref="IEnumerable{T}"/> containing all default container image pull policies</returns>
39+
public static IEnumerable<string> AsEnumerable()
40+
{
41+
yield return Always;
42+
yield return IfNotPresent;
43+
yield return Never;
44+
}
45+
46+
}

src/core/Synapse.Core/OperatorRuntimeMode.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ public static class OperatorRuntimeMode
2424
/// </summary>
2525
public const string Native = "native";
2626
/// <summary>
27-
/// Gets the containerized operator runtime mode
27+
/// Gets the Docker operator runtime mode
2828
/// </summary>
29-
public const string Containerized = "containerized";
29+
public const string Docker = "docker";
30+
/// <summary>
31+
/// Gets the Kubernetes operator runtime mode
32+
/// </summary>
33+
public const string Kubernetes = "kubernetes";
3034

3135
/// <summary>
3236
/// Gets a new <see cref="IEnumerable{T}"/> containing all default operator runtime modes
@@ -35,7 +39,8 @@ public static class OperatorRuntimeMode
3539
public static IEnumerable<string> AsEnumerable()
3640
{
3741
yield return Native;
38-
yield return Containerized;
42+
yield return Docker;
43+
yield return Kubernetes;
3944
}
4045

4146
}

src/core/Synapse.Core/Resources/DockerApiConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ public record DockerApiConfiguration
3434
[DataMember(Order = 2, Name = "version"), JsonPropertyOrder(2), JsonPropertyName("version"), YamlMember(Order = 2, Alias = "version")]
3535
public virtual string? Version { get; set; }
3636

37-
}
37+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
using Docker.DotNet.Models;
15+
using Neuroglia.Serialization.Yaml;
16+
17+
namespace Synapse.Resources;
18+
19+
/// <summary>
20+
/// Represents an object used to configure a Docker runtime
21+
/// </summary>
22+
[DataContract]
23+
public record DockerRuntimeConfiguration
24+
{
25+
26+
/// <summary>
27+
/// Gets the default network to connect Runner containers to
28+
/// </summary>
29+
public const string DefaultNetwork = "synapse";
30+
/// <summary>
31+
/// Gets the default runner container template
32+
/// </summary>
33+
public static readonly Config DefaultContainerTemplate = new()
34+
{
35+
Image = SynapseDefaults.Containers.Images.Runner
36+
};
37+
38+
/// <summary>
39+
/// Gets/sets the Docker API to use
40+
/// </summary>
41+
[DataMember(Order = 1, Name = "api"), JsonPropertyOrder(1), JsonPropertyName("api"), YamlMember(Order = 1, Alias = "api")]
42+
public virtual DockerApiConfiguration Api { get; set; } = new();
43+
44+
/// <summary>
45+
/// Gets/sets the name of the image repository to use when pulling the runtime's container image
46+
/// </summary>
47+
[DataMember(Order = 2, Name = "imageRepository"), JsonPropertyOrder(2), JsonPropertyName("imageRepository"), YamlMember(Order = 2, Alias = "imageRepository")]
48+
public virtual string? ImageRepository { get; set; }
49+
50+
/// <summary>
51+
/// Gets/sets the Docker image pull policy. Supported values are 'Always', 'IfNotPresent' and 'Never'. Defaults to 'Always'.
52+
/// </summary>
53+
[DataMember(Order = 3, Name = "imagePullPolicy"), JsonPropertyOrder(3), JsonPropertyName("imagePullPolicy"), YamlMember(Order = 3, Alias = "imagePullPolicy")]
54+
public virtual string ImagePullPolicy { get; set; } = Synapse.ImagePullPolicy.Always;
55+
56+
/// <summary>
57+
/// Gets/sets the template to use to create runner containers
58+
/// </summary>
59+
[DataMember(Order = 4, Name = "containerTemplate"), JsonPropertyOrder(4), JsonPropertyName("containerTemplate"), YamlMember(Order = 4, Alias = "containerTemplate")]
60+
public virtual Config ContainerTemplate { get; set; } = LoadContainerTemplate();
61+
62+
/// <summary>
63+
/// Gets/sets the path to the directory that contains the secrets to mount in runner containers on a per workflow configuration basis
64+
/// </summary>
65+
[DataMember(Order = 5, Name = "secrets"), JsonPropertyOrder(5), JsonPropertyName("secrets"), YamlMember(Order = 5, Alias = "secrets")]
66+
public virtual DockerRuntimeSecretsConfiguration Secrets { get; set; } = new();
67+
68+
/// <summary>
69+
/// Gets/sets the name of the network, if any, to connect Runner containers to
70+
/// </summary>
71+
[DataMember(Order = 6, Name = "network"), JsonPropertyOrder(6), JsonPropertyName("network"), YamlMember(Order = 6, Alias = "network")]
72+
public virtual string Network { get; set; } = DefaultNetwork;
73+
74+
/// <summary>
75+
/// Loads the runner container template
76+
/// </summary>
77+
/// <returns>The runner container template</returns>
78+
public static Config LoadContainerTemplate()
79+
{
80+
var templateFilePath = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Docker.Container);
81+
if (string.IsNullOrWhiteSpace(templateFilePath) || !File.Exists(templateFilePath)) return DefaultContainerTemplate;
82+
var yaml = File.ReadAllText(templateFilePath);
83+
return YamlSerializer.Default.Deserialize<Config>(yaml)!;
84+
}
85+
86+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright © 2024-Present The Synapse Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"),
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
namespace Synapse.Resources;
15+
16+
/// <summary>
17+
/// Represents an object used to configure the secrets of a Docker runtime
18+
/// </summary>
19+
[DataContract]
20+
public record DockerRuntimeSecretsConfiguration
21+
{
22+
23+
/// <summary>
24+
/// Gets the default secrets directory
25+
/// </summary>
26+
public static string DefaultDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".synapse", "secrets");
27+
/// <summary>
28+
/// Gets the default name for the volume on which to mount secrets
29+
/// </summary>
30+
public const string DefaultMountPath = "/run/secrets/synapse";
31+
32+
/// <summary>
33+
/// Gets/sets the path to the directory that contains the secrets to mount
34+
/// </summary>
35+
[DataMember(Order = 1, Name = "directory"), JsonPropertyOrder(1), JsonPropertyName("directory"), YamlMember(Order = 1, Alias = "directory")]
36+
public virtual string Directory { get; set; } = DefaultDirectory;
37+
38+
/// <summary>
39+
/// Gets/sets the path to the folder to mount the secrets volume to
40+
/// </summary>
41+
[DataMember(Order = 2, Name = "mountPath"), JsonPropertyOrder(2), JsonPropertyName("mountPath"), YamlMember(Order = 2, Alias = "mountPath")]
42+
public virtual string MountPath { get; set; } = DefaultMountPath;
43+
44+
}

0 commit comments

Comments
 (0)