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
2 changes: 1 addition & 1 deletion src/core/Synapse.Core/Resources/RuntimeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public record RuntimeDefinition
/// Gets the runtime mode
/// </summary>
[IgnoreDataMember, JsonIgnore, YamlIgnore]
public virtual string Mode => this.Native != null ? OperatorRuntimeMode.Native : this.Docker != null ? OperatorRuntimeMode.Docker : this.Kubernetes != null ? OperatorRuntimeMode.Kubernetes : throw new Exception("The runtime mode must be set");
public virtual string Mode => this.Kubernetes != null ? OperatorRuntimeMode.Kubernetes : this.Native != null ? OperatorRuntimeMode.Native : this.Docker != null ? OperatorRuntimeMode.Docker : throw new Exception("The runtime mode must be set");

}
23 changes: 8 additions & 15 deletions src/operator/Synapse.Operator/Services/WorkflowInstanceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,16 @@ protected virtual async Task OnPersistLogBatchAsync()
protected virtual async Task UpdateWorkflowInstanceStatusAsync(Action<WorkflowInstanceStatus> statusUpdate, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(statusUpdate);
var maxRetries = 3;
for (var attempt = 0; attempt < maxRetries; attempt++)
try
{
try
{
var original = this.WorkflowInstance.Resource;
var updated = original.Clone()!;
updated.Status ??= new();
statusUpdate(updated.Status);
var patch = JsonPatchUtility.CreateJsonPatchFromDiff(original, updated);
await this.Resources.PatchStatusAsync<WorkflowInstance>(new Patch(PatchType.JsonPatch, patch), updated.GetName(), updated.GetNamespace(), null, false, cancellationToken).ConfigureAwait(false);
}
catch (ConcurrencyException) when (attempt + 1 < maxRetries)
{
await Task.Delay(TimeSpan.FromMilliseconds(100 * (attempt + 1)), cancellationToken).ConfigureAwait(false);
}
var original = this.WorkflowInstance.Resource;
var updated = original.Clone()!;
updated.Status ??= new();
statusUpdate(updated.Status);
var patch = JsonPatchUtility.CreateJsonPatchFromDiff(original, updated);
await this.Resources.PatchStatusAsync<WorkflowInstance>(new Patch(PatchType.JsonPatch, patch), updated.GetName(), updated.GetNamespace(), null, false, cancellationToken).ConfigureAwait(false);
}
catch (ProblemDetailsException ex) when (ex.Problem.Status == (int)HttpStatusCode.NotModified) { }
}

/// <summary>
Expand Down
9 changes: 6 additions & 3 deletions src/operator/Synapse.Operator/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
"Uri": "http://localhost:5257"
},
"Runtime": {
"Native": {
"Directory": "..\\..\\..\\..\\..\\runner\\Synapse.Runner\\bin\\Debug\\net9.0\\",
"Executable": "Synapse.Runner.exe"
//"Native": {
// "Directory": "..\\..\\..\\..\\..\\runner\\Synapse.Runner\\bin\\Debug\\net9.0\\",
// "Executable": "Synapse.Runner.exe"
//}
"Kubernetes": {
"Namespace": "default"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ public class KubernetesRuntime(IServiceProvider serviceProvider, ILoggerFactory
protected virtual async Task InitializeAsync(CancellationToken cancellationToken = default)
{
if (this.Runner.Runtime.Kubernetes == null) throw new NullReferenceException($"Failed to initialize the Kubernetes Runtime because the operator is not configured to use Kubernetes as a runtime");
var kubeconfig = string.IsNullOrWhiteSpace(this.Runner.Runtime.Kubernetes.Kubeconfig)
? KubernetesClientConfiguration.InClusterConfig()
: await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(new FileInfo(this.Runner.Runtime.Kubernetes.Kubeconfig)).ConfigureAwait(false);
this.Kubernetes = new k8s.Kubernetes(kubeconfig);
var configuration = Environment.RunsInKubernetes()
? KubernetesClientConfiguration.InClusterConfig()
: (string.IsNullOrWhiteSpace(this.Runner.Runtime.Kubernetes.Kubeconfig)
? KubernetesClientConfiguration.BuildDefaultConfig()
: await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(new FileInfo(this.Runner.Runtime.Kubernetes.Kubeconfig)).ConfigureAwait(false));
this.Kubernetes = new k8s.Kubernetes(configuration);
}

/// <inheritdoc/>
Expand Down