Skip to content

Commit ce289a9

Browse files
artifact logging (#432)
* artifact logging Signed-off-by: Jack Schofield <[email protected]>
1 parent c7ce726 commit ce289a9

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/WorkflowManager/Logging/Logging/Log.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
using Amazon.Runtime.Internal;
1718
using Microsoft.AspNetCore.Mvc;
1819
using Microsoft.AspNetCore.Mvc.Filters;
1920
using Microsoft.Extensions.Logging;
@@ -152,7 +153,13 @@ public static void LogControllerEndTime(this ILogger logger, ResultExecutedConte
152153
[LoggerMessage(EventId = 33, Level = LogLevel.Debug, Message = "Task destination condition for task {taskId} with condition: {conditions} resolved to false.")]
153154
public static partial void TaskDestinationConditionFalse(this ILogger logger, string conditions, string taskId);
154155

155-
[LoggerMessage(EventId = 34, Level = LogLevel.Debug, Message = "Payload already exists for {payloadId}. This is likley due to being requeued")]
156+
public static void LogArtifactPassing(this ILogger logger, Artifact artifact, string path, string artifactType, bool exists)
157+
{
158+
logger.LogInformation(34, "Artifact Passed data Artifact {artifact}, Path {path}, ArtifactType {artifactType}, Exists {exists}",
159+
JsonConvert.SerializeObject(artifact), path, artifactType, exists);
160+
}
161+
162+
[LoggerMessage(EventId = 35, Level = LogLevel.Debug, Message = "Payload already exists for {payloadId}. This is likley due to being requeued")]
156163
public static partial void PayloadAlreadyExists(this ILogger logger, string payloadId);
157164
}
158165
}

src/WorkflowManager/WorkflowExecuter/Common/ArtifactMapper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ public async Task<Dictionary<string, string>> ConvertArtifactVariablesToPath(Art
7070
{
7171
artifactPathDictionary.Add(mappedArtifact.Key, mappedArtifact.Value);
7272

73+
_logger.LogArtifactPassing(artifact, mappedArtifact.Value, shouldExistYet ? "Input" : "Pre-Task Output Path Mapping", true);
74+
7375
continue;
7476
}
7577

78+
_logger.LogArtifactPassing(artifact, mappedArtifact.Value, shouldExistYet ? "Input" : "Pre-Task Output Path Mapping", false);
79+
7680
if (artifact.Mandatory)
7781
{
7882
throw new FileNotFoundException($"Mandatory artifact was not found: {artifact.Name}, {artifact.Value}");

src/WorkflowManager/WorkflowExecuter/Services/WorkflowExecuterService.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public async Task<bool> ProcessPayload(WorkflowRequestEvent message, Payload pay
119119
var workflowInstances = new List<WorkflowInstance>();
120120

121121
var tasks = workflows.Select(workflow => CreateWorkflowInstanceAsync(message, workflow));
122-
await Task.WhenAll(tasks).ConfigureAwait(false);
123-
workflowInstances.AddRange(tasks.Select(t => t.Result));
122+
var newInstances = await Task.WhenAll(tasks).ConfigureAwait(false);
123+
workflowInstances.AddRange(newInstances);
124124

125125
var existingInstances = await _workflowInstanceRepository.GetByWorkflowsIdsAsync(workflowInstances.Select(w => w.WorkflowId).ToList());
126126

@@ -423,13 +423,17 @@ private async Task<bool> HandleOutputArtifacts(WorkflowInstance workflowInstance
423423

424424
var validOutputArtifacts = await _storageService.VerifyObjectsExistAsync(workflowInstance.BucketId, artifactDict);
425425

426-
workflowInstance.Tasks?.ForEach(t =>
426+
foreach (var artifact in artifactDict)
427427
{
428-
if (t.TaskId == task.TaskId)
429-
{
430-
t.OutputArtifacts = validOutputArtifacts;
431-
}
432-
});
428+
_logger.LogArtifactPassing(new Artifact { Name = artifact.Key, Value = artifact.Value }, artifact.Value, "Post-Task Output Artifact", validOutputArtifacts.ContainsKey(artifact.Key));
429+
}
430+
431+
var currentTask = workflowInstance.Tasks?.FirstOrDefault(t => t.TaskId == task.TaskId);
432+
433+
if (currentTask is not null)
434+
{
435+
currentTask.OutputArtifacts = validOutputArtifacts;
436+
}
433437

434438
if (validOutputArtifacts is not null && validOutputArtifacts.Any())
435439
{

0 commit comments

Comments
 (0)