Skip to content

Commit e5fe2fa

Browse files
committed
feat: enhance update check logging and adjust default log level to Debug
Signed-off-by: Christopher Thomsen <christhomsen82@gmail.com>
1 parent 5058293 commit e5fe2fa

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

OrchestratorWorker.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ private async Task<bool> CheckForUpdateAsync()
8383
{
8484
try
8585
{
86+
_logger.LogDebug("Checking for updates for orchestrator {OrchestratorId}...", _orchestratorId);
8687
var pendingUpdate = await _apiClient.CheckForUpdateAsync(_orchestratorId);
88+
_logger.LogDebug("Update check result for {OrchestratorId}: pendingUpdate={PendingUpdate}", _orchestratorId, pendingUpdate);
89+
8790
if (pendingUpdate)
8891
{
8992
_logger.LogInformation("Pending update detected for orchestrator {OrchestratorId}", _orchestratorId);
@@ -94,7 +97,7 @@ private async Task<bool> CheckForUpdateAsync()
9497
}
9598
catch (Exception ex)
9699
{
97-
_logger.LogWarning(ex, "Failed to check for updates");
100+
_logger.LogWarning(ex, "Failed to check for updates for orchestrator {OrchestratorId}", _orchestratorId);
98101
return false;
99102
}
100103
}

Services/ApiClient.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,29 @@ public async Task<bool> CheckForUpdateAsync(string orchestratorId)
305305
{
306306
if (!await EnsureAuthenticatedAsync())
307307
{
308+
_logger.LogWarning("Cannot check for update: Not authenticated");
308309
return false;
309310
}
310311

311-
var response = await _httpClient.GetAsync($"/api/orchestrators/{Uri.EscapeDataString(orchestratorId)}/update-status");
312+
var url = $"/api/orchestrators/{Uri.EscapeDataString(orchestratorId)}/update-status";
313+
_logger.LogDebug("Checking update status at: {Url}", url);
314+
315+
var response = await _httpClient.GetAsync(url);
316+
_logger.LogDebug("Update status response: {StatusCode}", response.StatusCode);
312317

313318
if (response.IsSuccessStatusCode)
314319
{
320+
var content = await response.Content.ReadAsStringAsync();
321+
_logger.LogDebug("Update status response body: {Content}", content);
322+
315323
var result = await response.Content.ReadFromJsonAsync<UpdateStatusResponse>(_jsonOptions);
324+
_logger.LogDebug("Parsed pendingUpdate value: {PendingUpdate}", result?.PendingUpdate);
316325
return result?.PendingUpdate ?? false;
317326
}
327+
else if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
328+
{
329+
_logger.LogDebug("Orchestrator {OrchestratorId} not found in API", orchestratorId);
330+
}
318331

319332
return false;
320333
}
@@ -345,5 +358,6 @@ public async Task AcknowledgeUpdateAsync(string orchestratorId)
345358

346359
public class UpdateStatusResponse
347360
{
361+
[System.Text.Json.Serialization.JsonPropertyName("pendingUpdate")]
348362
public bool PendingUpdate { get; set; }
349363
}

appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Logging": {
33
"LogLevel": {
4-
"Default": "Information",
4+
"Default": "Debug",
55
"Microsoft.Hosting.Lifetime": "Information",
66
"System.Net.Http": "Warning"
77
}

0 commit comments

Comments
 (0)