Skip to content

Commit 4714ad1

Browse files
authored
Merge pull request #2273 from Azure/dev
Promote dev to main for 2.8.1 release
2 parents ab353f0 + ed2c8f5 commit 4714ad1

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

release_notes.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
## Bug Fixes
2-
- Correctly Serialize HostStoppingEvent in ActivityShim (https://github.com/Azure/azure-functions-durable-extension/pull/2178)
3-
- Fix NotImplementedException for management API calls from Java client (https://github.com/Azure/azure-functions-durable-extension/pull/2193)
4-
- Handle OOM and other exceptions in entity shim by aborting the session (https://github.com/Azure/azure-functions-durable-extension/pull/2234)
5-
6-
## Enhancements
7-
- add optional 'instanceIdPrefix' query parameter to the HTTP API for instance queries
8-
9-
## Dependencies
10-
- DurableTask.Core --> v2.10.*
11-
- DurableTask.AzureStorage --> v1.12.*
12-
- DurableTask.Analyzers --> 0.5.0

src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -497,16 +497,9 @@ private void InitializeLinuxLogging()
497497
string stampName = this.PlatformInformationService.GetLinuxStampName();
498498
string containerName = this.PlatformInformationService.GetContainerName();
499499

500-
// If running in linux, initialize the EventSource listener with the appropiate logger.
501-
LinuxAppServiceLogger linuxLogger;
502-
if (!inConsumption)
503-
{
504-
linuxLogger = new LinuxAppServiceLogger(writeToConsole: false, containerName, tenant, stampName);
505-
}
506-
else
507-
{
508-
linuxLogger = new LinuxAppServiceLogger(writeToConsole: true, containerName, tenant, stampName);
509-
}
500+
// in linux consumption, logs are emitted to the console.
501+
// In other linux plans, they are emitted to a logfile.
502+
var linuxLogger = new LinuxAppServiceLogger(writeToConsole: inConsumption, containerName, tenant, stampName);
510503

511504
// The logging service for linux works by capturing EventSource messages,
512505
// which our linux platform does not recognize, and logging them via a
@@ -521,10 +514,6 @@ private void InitializeLinuxLogging()
521514
/// <inheritdoc />
522515
public void Dispose()
523516
{
524-
// Not flushing the linux logger may lead to lost logs
525-
// 40 seconds timeout because we write normally every 30 seconds, so we're just
526-
// adding an extra 10 seconds to flush.
527-
LinuxAppServiceLogger.Logger?.Stop(TimeSpan.FromSeconds(40));
528517
this.HttpApiHandler?.Dispose();
529518
this.eventSourceListener?.Dispose();
530519
}

src/WebJobs.Extensions.DurableTask/EventSourceListener.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,11 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
106106
}
107107
}
108108
}
109+
110+
public override void Dispose()
111+
{
112+
this.logger?.Dispose();
113+
base.Dispose();
114+
}
109115
}
110116
}

src/WebJobs.Extensions.DurableTask/LinuxAppServiceFileLogger.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
1919
/// We have modified their implementation to utilize syscall.rename instead of File.Move during file rolling.
2020
/// This change is necessary for older versions of fluent-bit, our logging infrastructure in linux dedicated, to properly deal with logfile archiving.
2121
/// </summary>
22-
public class LinuxAppServiceFileLogger
22+
internal class LinuxAppServiceFileLogger : IDisposable
2323
{
24+
private static readonly SemaphoreSlim Semaphore = new SemaphoreSlim(initialCount: 1, maxCount: 1);
2425
private readonly string logFileName;
2526
private readonly string logFileDirectory;
2627
private readonly string logFilePath;
@@ -126,12 +127,18 @@ internal async Task InternalProcessLogQueue()
126127
{
127128
try
128129
{
130+
// block on semaphore to prevent concurrent writes
131+
await Semaphore.WaitAsync();
129132
await this.WriteLogs(this.currentBatch);
130133
}
131134
catch (Exception)
132135
{
133136
// Ignored
134137
}
138+
finally
139+
{
140+
Semaphore.Release();
141+
}
135142

136143
this.currentBatch.Clear();
137144
}
@@ -165,6 +172,14 @@ private async Task AppendLogs(string filePath, IEnumerable<string> logs)
165172
}
166173
}
167174

175+
public void Dispose()
176+
{
177+
// Not flushing the linux logger may lead to lost logs
178+
// 40 seconds timeout because we write normally every 30 seconds, so we're just
179+
// adding an extra 10 seconds to flush.
180+
this.Stop(TimeSpan.FromSeconds(40));
181+
}
182+
168183
private void RollFiles()
169184
{
170185
// Rename current file to older file.

src/WebJobs.Extensions.DurableTask/LinuxAppServiceLogger.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
1818
/// This class is utilized by <c>EventSourceListener</c> to write logs corresponding to
1919
/// specific EventSource providers.
2020
/// </summary>
21-
internal class LinuxAppServiceLogger
21+
internal class LinuxAppServiceLogger : IDisposable
2222
{
2323
private const string ConsolePrefix = "MS_DURABLE_FUNCTION_EVENTS_LOGS";
2424

25-
// variable below is internal static for testing and other convenient purposes
26-
// we need to be able to change the logging path for a windows-based CI
27-
// the logger being internal static is convenient for flushing it
2825
#pragma warning disable SA1401 // Fields should be private
2926
internal static string LoggingPath = "/var/log/functionsLogs/durableeventsJSON.log";
30-
internal static LinuxAppServiceFileLogger Logger; // The File Logger
3127
#pragma warning restore SA1401 // Fields should be private
3228

3329
// logging metadata
@@ -40,6 +36,8 @@ internal class LinuxAppServiceLogger
4036
// if true, we write to console (linux consumption), else to a file (linux dedicated).
4137
private readonly bool writeToConsole;
4238

39+
private readonly LinuxAppServiceFileLogger fileLogger;
40+
4341
/// <summary>
4442
/// Create a LinuxAppServiceLogger instance.
4543
/// </summary>
@@ -86,7 +84,7 @@ public LinuxAppServiceLogger(
8684
// int tenMbInBytes = 10000000;
8785
string fname = Path.GetFileName(LinuxAppServiceLogger.LoggingPath);
8886
string dir = Path.GetDirectoryName(LinuxAppServiceLogger.LoggingPath);
89-
Logger = new LinuxAppServiceFileLogger(fname, dir);
87+
this.fileLogger = new LinuxAppServiceFileLogger(fname, dir);
9088
}
9189
}
9290

@@ -173,8 +171,13 @@ public void Log(EventWrittenEventArgs eventData)
173171
{
174172
// We write to a file in Linux Dedicated
175173
// Our file logger already handles file rolling (archiving) and deletion of old logs
176-
Logger.Log(jsonString);
174+
this.fileLogger.Log(jsonString);
177175
}
178176
}
177+
178+
public void Dispose()
179+
{
180+
this.fileLogger?.Dispose();
181+
}
179182
}
180183
}

src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<RootNamespace>Microsoft.Azure.WebJobs.Extensions.DurableTask</RootNamespace>
77
<MajorVersion>2</MajorVersion>
88
<MinorVersion>8</MinorVersion>
9-
<PatchVersion>0</PatchVersion>
9+
<PatchVersion>1</PatchVersion>
1010
<Version>$(MajorVersion).$(MinorVersion).$(PatchVersion)</Version>
1111
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
1212
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>

0 commit comments

Comments
 (0)