Skip to content

Commit fdc5a9d

Browse files
authored
AC-1029 improvements to argo plugin loggin (#656)
* minor improvement to logging in argo plugin Signed-off-by: Lillie Dae <[email protected]>
1 parent c636502 commit fdc5a9d

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

src/TaskManager/Plug-ins/Argo/ArgoPlugin.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ public ArgoPlugin(
7676

7777
private void Initialize()
7878
{
79+
using var loggingScope = _logger.BeginScope(new Dictionary<string, object>
80+
{
81+
["correlationId"] = Event.CorrelationId,
82+
["workflowInstanceId"] = Event.WorkflowInstanceId,
83+
["taskId"] = Event.TaskId,
84+
["executionId"] = Event.ExecutionId,
85+
["payloadId"] = Event.PayloadId
86+
});
87+
7988
if (Event.TaskPluginArguments.ContainsKey(Keys.TimeoutSeconds) &&
8089
int.TryParse(Event.TaskPluginArguments[Keys.TimeoutSeconds], out var result))
8190
{
@@ -128,7 +137,11 @@ private void Initialize()
128137
Task.Run(() => _taskDispatchEventService.UpdateTaskPluginArgsAsync(eventInfo, Event.TaskPluginArguments));
129138
}
130139

131-
_logger.Initialized(_namespace, _baseUrl, _activeDeadlineSeconds, (!string.IsNullOrWhiteSpace(_apiToken)));
140+
_logger.Initialized(_namespace,
141+
_baseUrl,
142+
_activeDeadlineSeconds,
143+
!string.IsNullOrWhiteSpace(_apiToken) ? "true" : "false",
144+
_allowInsecure ? "true" : "false");
132145
}
133146

134147
private void ValidateEvent()

src/TaskManager/Plug-ins/Argo/Logging/Log.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public static partial class Log
5050
[LoggerMessage(EventId = 1009, Level = LogLevel.Debug, Message = "Creating Argo workflow: {generateName}")]
5151
public static partial void CreatingArgoWorkflow(this ILogger logger, string generateName);
5252

53-
[LoggerMessage(EventId = 1010, Level = LogLevel.Information, Message = "Argo plugin initialized: namespace={argoNamespace}, base URL={baseUrl}, activeDeadlineSeconds={activeDeadlineSeconds}, apiToken configured={apiTokenSet}.")]
54-
public static partial void Initialized(this ILogger logger, string argoNamespace, string baseUrl, int? activeDeadlineSeconds, bool apiTokenSet);
53+
[LoggerMessage(EventId = 1010, Level = LogLevel.Information, Message = "Argo plugin initialized: namespace={argoNamespace}, base URL={baseUrl}, activeDeadlineSeconds={activeDeadlineSeconds}, apiToken configured={apiTokenSet}. allowInsecure={allowInsecure}")]
54+
public static partial void Initialized(this ILogger logger, string argoNamespace, string baseUrl, int? activeDeadlineSeconds, string apiTokenSet, string allowInsecure);
5555

5656
[LoggerMessage(EventId = 1011, Level = LogLevel.Error, Message = "Error generating Argo workflow.")]
5757
public static partial void ErrorGeneratingWorkflow(this ILogger logger, Exception ex);

src/TaskManager/Plug-ins/Argo/Strings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Monai.Deploy.WorkflowManager.TaskManager.Argo
1919
public static class Strings
2020
{
2121
public const string ArgoApiVersion = "argoproj.io/v1alpha1";
22-
public const string DefaultNamespace = "default";
22+
public const string DefaultNamespace = "argo";
2323
public const string KindWorkflow = "Workflow";
2424

2525
public const string TaskIdLabelSelectorName = "md-task-id";

src/TaskManager/TaskManager/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"test": "Monai.Deploy.WorkflowManager.TaskManager.TestPlugin.Repositories.TestPluginRepository, Monai.Deploy.WorkflowManager.TaskManager.TestPlugin"
2626
},
2727
"argoPluginArguments": {
28-
"server_url": "http://argo-argo-workflows-server.argo:2746"
28+
"server_url": "http://localhost:2746"
2929
}
3030
},
3131
"storage": {

src/TaskManager/TaskManager/appsettings.Local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"test": "Monai.Deploy.WorkflowManager.TaskManager.TestPlugin.Repositories.TestPluginRepository, Monai.Deploy.WorkflowManager.TaskManager.TestPlugin"
2626
},
2727
"argoPluginArguments": {
28-
"server_url": "http://argo-argo-workflows-server.argo:2746"
28+
"server_url": "http://localhost:2746"
2929
}
3030
},
3131
"storage": {

tests/UnitTests/TaskManager.Argo.Tests/ArgoPluginTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void ArgoPlugin_InitializesValues()
135135
var message = GenerateTaskDispatchEventWithValidArguments();
136136

137137
_ = new ArgoPlugin(_serviceScopeFactory.Object, _logger.Object, _options, message);
138-
_logger.VerifyLogging($"Argo plugin initialized: namespace=namespace, base URL=http://api-endpoint/, activeDeadlineSeconds=50, apiToken configured=True.", LogLevel.Information, Times.Once());
138+
_logger.VerifyLogging($"Argo plugin initialized: namespace=namespace, base URL=http://api-endpoint/, activeDeadlineSeconds=50, apiToken configured=true. allowInsecure=true", LogLevel.Information, Times.Once());
139139
}
140140

141141
[Fact(DisplayName = "ExecuteTask - returns ExecutionStatus on failure")]

0 commit comments

Comments
 (0)