Skip to content

Commit

Permalink
final adjustments
Browse files Browse the repository at this point in the history
Signed-off-by: Neil South <[email protected]>
  • Loading branch information
neildsouth committed Oct 20, 2023
1 parent ee61cf9 commit 5388837
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
12 changes: 7 additions & 5 deletions src/TaskManager/TaskManager/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,17 @@ private async Task HandleCancellationTask(JsonMessage<TaskCancellationEvent> mes
}

var pluginAssembly = string.Empty;
ITaskPlugin? taskRunner = null;
ITaskPlugin? taskRunner;
try
{
var taskExecution = await _taskDispatchEventService.GetByTaskExecutionIdAsync(message.Body.ExecutionId).ConfigureAwait(false);
pluginAssembly = _options.Value.TaskManager.PluginAssemblyMappings[taskExecution?.Event.TaskPluginType] ?? string.Empty;
var taskExecEvent = taskExecution?.Event;
if (taskExecEvent == null)

var taskExecEvent = taskExecution?.Event ?? throw new InvalidOperationException("Task Event data not found.");

pluginAssembly = string.Empty;
if (_options.Value.TaskManager.PluginAssemblyMappings.ContainsKey(taskExecution?.Event.TaskPluginType))
{
throw new InvalidOperationException("Task Event data not found.");
pluginAssembly = _options.Value.TaskManager.PluginAssemblyMappings[taskExecution?.Event.TaskPluginType];
}

taskRunner = typeof(ITaskPlugin).CreateInstance<ITaskPlugin>(serviceProvider: _scope.ServiceProvider, typeString: pluginAssembly, _serviceScopeFactory, taskExecEvent);
Expand Down
27 changes: 19 additions & 8 deletions src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public async Task AddOrUpdateItemAsync(string workflowInstanceId, string taskId,

var item = new ArtifactReceivedItems()
{
Id = workflowInstanceId + taskId,
WorkflowInstanceId = workflowInstanceId,
TaskId = taskId,
Artifacts = artifacts.ToList()
Expand All @@ -175,18 +176,28 @@ public async Task AddOrUpdateItemAsync(string workflowInstanceId, string taskId,
.FindAsync(a => a.WorkflowInstanceId == workflowInstanceId && a.TaskId == taskId).ConfigureAwait(false);
var existing = await result.FirstOrDefaultAsync().ConfigureAwait(false);

if (existing == null)
try
{
await _artifactReceivedItemsCollection.InsertOneAsync(item).ConfigureAwait(false);
if (existing == null)
{
await _artifactReceivedItemsCollection.InsertOneAsync(item).ConfigureAwait(false);
}
else
{
item.Artifacts = item.Artifacts.Concat(existing.Artifacts).ToList();
var update = Builders<ArtifactReceivedItems>.Update.Set(a => a.Artifacts, item.Artifacts);
await _artifactReceivedItemsCollection
.UpdateOneAsync(a => a.WorkflowInstanceId == workflowInstanceId && a.TaskId == taskId, update)
.ConfigureAwait(false);
}
}
else
catch (Exception ex)

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / task-manager-integration-tests

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / unit-tests-and-codecov

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / workflow-executor-integration-tests

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / sonarscanner

Add logic to this catch clause or eliminate it and rethrow the exception automatically. (https://rules.sonarsource.com/csharp/RSPEC-2737)

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / scan

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / docs

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / docs

The variable 'ex' is declared but never used

Check warning on line 194 in src/WorkflowManager/Database/Repositories/ArtifactsRepository.cs

View workflow job for this annotation

GitHub Actions / analyze

The variable 'ex' is declared but never used
{
item.Artifacts = item.Artifacts.Concat(existing.Artifacts).ToList();
var update = Builders<ArtifactReceivedItems>.Update.Set(a => a.Artifacts, item.Artifacts);
await _artifactReceivedItemsCollection
.UpdateOneAsync(a => a.WorkflowInstanceId == workflowInstanceId && a.TaskId == taskId, update)
.ConfigureAwait(false);

throw;
}


}
}
}

0 comments on commit 5388837

Please sign in to comment.