From 37d5234fde09d09e0e7f8e7d81bafad6ff1a5157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emek=20Vysok=C3=BD?= Date: Thu, 10 Feb 2022 11:35:10 +0100 Subject: [PATCH] Revert "Warnings were getting buried in binlogs; promote ALL SendAsync logging to Important (it's brief) and produce warnings for missing queues. (#8426)" This reverts commit 6bf25f4f78bf1c3961f31bbce6bb51fdaafda387. --- azure-pipelines.yml | 6 ------ .../JobSender/JobDefinition.cs | 12 ++++++++++-- src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1fac68b9691..cf1757f335e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -141,7 +141,6 @@ stages: -ci -restore -test - -warnAsError $false -projects $(Build.SourcesDirectory)\tests\UnitTests.proj /bl:$(Build.SourcesDirectory)\artifacts\log\$(_BuildConfig)\Helix.binlog /p:RestoreUsingNuGetTargets=false @@ -171,7 +170,6 @@ stages: -ci -restore -test - -warnAsError $false -projects $(Build.SourcesDirectory)\tests\XHarness.Android.DeviceTests.proj /bl:$(Build.SourcesDirectory)\artifacts\log\$(_BuildConfig)\Helix.XHarness.Android.Device.Tests.binlog /p:RestoreUsingNuGetTargets=false @@ -202,7 +200,6 @@ stages: --ci --restore --test - --warnAsError false --projects $(Build.SourcesDirectory)/tests/UnitTests.proj /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Helix.binlog /p:RestoreUsingNuGetTargets=false @@ -233,7 +230,6 @@ stages: -ci -restore -test - -warnAsError false -projects $(Build.SourcesDirectory)/tests/XHarness.Apple.SimulatorTests.proj /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/XHarness.Apple.Simulator.Tests.binlog /p:RestoreUsingNuGetTargets=false @@ -264,7 +260,6 @@ stages: -ci -restore -test - -warnAsError false -projects $(Build.SourcesDirectory)/tests/XHarness.Apple.DeviceTests.proj /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Helix.XHarness.Apple.Device.Tests.binlog /p:RestoreUsingNuGetTargets=false @@ -295,7 +290,6 @@ stages: -ci -restore -test - -warnAsError false -projects $(Build.SourcesDirectory)/tests/XHarness.Android.SimulatorTests.proj /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/Helix.XHarness.Android.Simulator.Tests.binlog /p:RestoreUsingNuGetTargets=false diff --git a/src/Microsoft.DotNet.Helix/JobSender/JobDefinition.cs b/src/Microsoft.DotNet.Helix/JobSender/JobDefinition.cs index b5e4bee42c4..e6ca7b2cc70 100644 --- a/src/Microsoft.DotNet.Helix/JobSender/JobDefinition.cs +++ b/src/Microsoft.DotNet.Helix/JobSender/JobDefinition.cs @@ -238,23 +238,31 @@ public async Task SendAsync(Action log, CancellationToken canc private void WarnForImpendingRemoval(Action log, QueueInfo queueInfo) { + bool azDoVariableDefined = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SYSTEM_TEAMPROJECT")); DateTime whenItExpires = DateTime.MaxValue; if (DateTime.TryParseExact(queueInfo.EstimatedRemovalDate, "yyyy-MM-dd", null, DateTimeStyles.AssumeUniversal, out DateTime dtIso)) { whenItExpires = dtIso; } + // This branch can be removed once the strings start coming in in ISO-8601 format + // Currently the API provides values in this format though and they are unlikely to get confused with each other. + else if (DateTime.TryParseExact(queueInfo.EstimatedRemovalDate, "M/d/yyyy", null, DateTimeStyles.AssumeUniversal, out DateTime dtUsa)) + { + whenItExpires = dtUsa; + } + if (whenItExpires != DateTime.MaxValue) // We recognized a date from the string { TimeSpan untilRemoved = whenItExpires.ToUniversalTime().Subtract(DateTime.UtcNow); if (untilRemoved.TotalDays <= 21) { - log?.Invoke($"warning : Helix queue {queueInfo.QueueId} {(untilRemoved.TotalDays < 0 ? "was" : "is")} slated for removal on {queueInfo.EstimatedRemovalDate}. Please discontinue usage. Contact dnceng for questions / concerns "); + log?.Invoke($"{(azDoVariableDefined ? "##vso[task.logissue type=warning]" : "")}Helix queue {queueInfo.QueueId} {(untilRemoved.TotalDays < 0 ? "was" : "is")} slated for removal on {queueInfo.EstimatedRemovalDate}. Please discontinue usage. Contact dnceng for questions / concerns "); } } else { - log?.Invoke($"error : Unable to parse estimated removal date '{queueInfo.EstimatedRemovalDate}' for queue '{queueInfo.QueueId}' (please contact dnceng with this information)"); + log?.Invoke($"{(azDoVariableDefined ? "##vso[task.logissue type=warning]" : "")}Unable to parse estimated removal date '{queueInfo.EstimatedRemovalDate}' for queue '{queueInfo.QueueId}' (please contact dnceng with this information)"); } } diff --git a/src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs b/src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs index a2abfe956a3..abbf3ef3d80 100644 --- a/src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs +++ b/src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs @@ -262,9 +262,9 @@ protected override async Task ExecuteCore(CancellationToken cancellationToken) } Log.LogMessage(MessageImportance.High, $"Sending Job to {TargetQueue}..."); + cancellationToken.ThrowIfCancellationRequested(); - // LogMessageFromText will take any string formatted as a canonical error or warning and convert the type of log to this - ISentJob job = await def.SendAsync(msg => Log.LogMessageFromText(msg, MessageImportance.High), cancellationToken); + ISentJob job = await def.SendAsync(msg => Log.LogMessage(msg), cancellationToken); JobCorrelationId = job.CorrelationId; JobCancellationToken = job.HelixCancellationToken; ResultsContainerUri = job.ResultsContainerUri;