Skip to content

Commit ad05ce1

Browse files
imadityaaAditya Abhishek
andauthored
logFileUploadLogic (#154)
Co-authored-by: Aditya Abhishek <adityaa@microsoft.com>
1 parent 4924628 commit ad05ce1

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/VirtualClient/VirtualClient.Core/VirtualClientLoggingExtensions.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ internal static async Task LogProcessDetailsToFileAsync(this VirtualClientCompon
270270
(!string.IsNullOrWhiteSpace(processDetails.ToolName) ? processDetails.ToolName : component.TypeName).ToLowerInvariant().RemoveWhitespace(),
271271
string.Empty);
272272

273-
string effectiveCommand = $"{processDetails.CommandLine}".Trim();
273+
string effectiveCommand = $"{SensitiveData.ObscureSecrets(processDetails?.CommandLine)}".Trim();
274274
string logPath = specifics.GetLogsPath(effectiveToolName.ToLowerInvariant().RemoveWhitespace());
275275

276276
if (!fileSystem.Directory.Exists(logPath))
@@ -314,7 +314,7 @@ internal static async Task LogProcessDetailsToFileAsync(this VirtualClientCompon
314314
// Any results from the output of the process
315315

316316
StringBuilder outputBuilder = new StringBuilder();
317-
outputBuilder.AppendLine($"Command : {SensitiveData.ObscureSecrets(processDetails?.CommandLine)}");
317+
outputBuilder.AppendLine($"Command : {effectiveCommand}");
318318
outputBuilder.AppendLine($"Working Directory : {processDetails?.WorkingDirectory}");
319319
outputBuilder.AppendLine($"Exit Code : {processDetails?.ExitCode}");
320320
outputBuilder.AppendLine();
@@ -339,6 +339,26 @@ await VirtualClientLoggingExtensions.FileSystemAccessRetryPolicy.ExecuteAsync(as
339339
{
340340
await fileSystem.File.WriteAllTextAsync(logFilePath, outputBuilder.ToString());
341341
});
342+
343+
if (component.TryGetContentStoreManager(out IBlobManager blobManager))
344+
{
345+
FileContext fileContext = new FileContext(
346+
fileSystem.FileInfo.New(logFilePath),
347+
HttpContentType.PlainText,
348+
Encoding.UTF8.WebName,
349+
component.ExperimentId,
350+
component.AgentId,
351+
effectiveToolName,
352+
component.Scenario,
353+
effectiveCommand,
354+
component.Roles?.Any() == true ? string.Join(',', component.Roles) : null);
355+
356+
// The file is already timestamped at this point, so there is no need to add any additional
357+
// timestamping information.
358+
FileUploadDescriptor descriptor = component.CreateFileUploadDescriptor(fileContext, component.Parameters, component.Metadata, timestamped: false);
359+
360+
await component.RequestFileUploadAsync(descriptor);
361+
}
342362
}
343363
}
344364
catch (Exception exc)

0 commit comments

Comments
 (0)