Skip to content

Commit

Permalink
net8 branch..
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Torre committed Aug 2, 2024
1 parent 6eb536b commit e51cde8
Show file tree
Hide file tree
Showing 53 changed files with 289 additions and 454 deletions.
8 changes: 4 additions & 4 deletions Build-COSFPkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function Build-SFPkg {
try {
Push-Location $scriptPath

Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Linux.SelfContained.2.2.8" "$scriptPath\bin\release\ClusterObserver\linux-x64\self-contained\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Linux.FrameworkDependent.2.2.8" "$scriptPath\bin\release\ClusterObserver\linux-x64\framework-dependent\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Linux.SelfContained.2.2.8-net8" "$scriptPath\bin\release\ClusterObserver\linux-x64\self-contained\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Linux.FrameworkDependent.2.2.8-net8" "$scriptPath\bin\release\ClusterObserver\linux-x64\framework-dependent\ClusterObserverType"

Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Windows.SelfContained.2.2.8" "$scriptPath\bin\release\ClusterObserver\win-x64\self-contained\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Windows.FrameworkDependent.2.2.8" "$scriptPath\bin\release\ClusterObserver\win-x64\framework-dependent\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Windows.SelfContained.2.2.8-net8" "$scriptPath\bin\release\ClusterObserver\win-x64\self-contained\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Windows.FrameworkDependent.2.2.8-net8" "$scriptPath\bin\release\ClusterObserver\win-x64\framework-dependent\ClusterObserverType"
}
finally {
Pop-Location
Expand Down
16 changes: 7 additions & 9 deletions ClusterObserver.nuspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<id>%PACKAGE_ID%</id>
<version>2.2.8</version>
<releaseNotes>
- *Breaking Change*: Telemetry configuration settings are now required to be overridden in ApplicationManifest.xml to support versionless, parameter-only application upgrades for telemetry settings. See [Issue 292](https://github.com/microsoft/service-fabric-observer/issues/292) for details. Just move your related settings' Value strings from Settings.xml to ApplicationManifest.xml app parameter (the names of these settings are the same).
- Bug fix in app param update for log path and max archive lifetime settings.
- Updated nuget package dependencies to latest versions.
- net8.0 implementation of ClusterObserver.
</releaseNotes>
<authors>Microsoft</authors>
<license type="expression">MIT</license>
Expand All @@ -15,14 +13,14 @@
<icon>icon.png</icon>
<readme>conuget.md</readme>
<language>en-US</language>
<description>This package contains the Service Fabric ClusterObserver(CO) Application - built for .NET 6.0 and SF Runtime 9.x. CO is a highly configurable and extensible Service Fabric stateless service that monitors aggregated cluster health and emits SF entity-specific telemetry. It is designed to be run in Service Fabric Windows and Linux clusters. This package contains the entire application and can be used to build .NET Standard 2.0 observer plugins. NOTE: If you want to target .NET 6 for your plugins, then you must use Microsoft.ServiceFabricApps.FabricObserver.Extensibility.3.2.9 nuget package to build them.</description>
<description>This package contains the Service Fabric ClusterObserver(CO) Application - built for .NET 8.0 and SF Runtime 10.1.x. CO is a highly configurable and extensible Service Fabric stateless service that monitors aggregated cluster health and emits SF entity-specific telemetry. It is designed to be run in Service Fabric Windows and Linux clusters. This package contains the entire application and can be used to build .NET Standard 2.0/.NET6 observer plugins. NOTE: If you want to target .NET 6 for your plugins, then you must use Microsoft.ServiceFabricApps.FabricObserver.Extensibility.3.2.9 or higher nuget package to build them.</description>
<contentFiles>
<files include="**" buildAction="None" copyToOutput="true" />
</contentFiles>
<dependencies>
<group targetFramework="net6.0">
<group targetFramework="net8.0">
<dependency id="Microsoft.ServiceFabric.Services" version="6.0.1017" />
<dependency id="Microsoft.ServiceFabricApps.FabricObserver.Extensibility" version="3.2.15" />
<dependency id="Microsoft.ServiceFabricApps.FabricObserver.Extensibility" version="3.2.16" />
</group>
</dependencies>
<projectUrl>https://aka.ms/sf/FabricObserver</projectUrl>
Expand All @@ -31,9 +29,9 @@
</metadata>
<files>
<file src="**" target="contentFiles\any\any" />
<file src="ClusterObserverPkg\Code\ClusterObserver.dll" target="lib\net6.0" />
<file src="ClusterObserverPkg\Code\FabricObserver.Extensibility.dll" target="lib\net6.0" />
<file src="ClusterObserverPkg\Code\TelemetryLib.dll" target="lib\net6.0" />
<file src="ClusterObserverPkg\Code\ClusterObserver.dll" target="lib\net8.0" />
<file src="ClusterObserverPkg\Code\FabricObserver.Extensibility.dll" target="lib\net8.0" />
<file src="ClusterObserverPkg\Code\TelemetryLib.dll" target="lib\net8.0" />
<file src="%ROOT_PATH%\icon.png" target="" />
<file src="%ROOT_PATH%\conuget.md" target="" />
</files>
Expand Down
10 changes: 5 additions & 5 deletions ClusterObserver/ClusterObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public bool EmitWarningDetails
get; set;
}

public ClusterObserver(StatelessServiceContext serviceContext, bool ignoreDefaultQueryTimeout = false)
public ClusterObserver(StatelessServiceContext serviceContext, bool ignoreDefaultQueryTimeout = false)
: base (null, serviceContext)
{
NodeStatusDictionary = new Dictionary<string, (NodeStatus NodeStatus, DateTime FirstDetectedTime, DateTime LastDetectedTime)>();
ApplicationUpgradesCompletedStatus = new Dictionary<string, bool>();
NodeStatusDictionary = [];
ApplicationUpgradesCompletedStatus = [];

this.ignoreDefaultQueryTimeout = ignoreDefaultQueryTimeout;

Expand Down Expand Up @@ -400,7 +400,7 @@ private async Task ReportApplicationUpgradeStatus(Uri appName, CancellationToken
{
ServiceFabricUpgradeEventData appUpgradeInfo =
await FabricClientRetryHelper.ExecuteFabricActionWithRetryAsync(
() => UpgradeChecker.GetApplicationUpgradeDetailsAsync(FabricClientInstance, Token, appName),
() => UpgradeChecker.GetApplicationUpgradeDetailsAsync(FabricClientInstance, appName, Token),
Token);

if (appUpgradeInfo?.ApplicationUpgradeProgress == null || Token.IsCancellationRequested)
Expand Down Expand Up @@ -534,7 +534,7 @@ private async Task ProcessApplicationHealthAsync(ApplicationHealthState appHealt
appHealth.HealthEvents.Where(
e => e.HealthInformation.HealthState is HealthState.Error or HealthState.Warning).ToList();

if (!appHealthEvents.Any())
if (appHealthEvents.Count == 0)

This comment has been minimized.

Copy link
@sidhant012

sidhant012 Aug 6, 2024

Collaborator

Why did you decide to change this? Isnt the use of "Any()" technically more efficient because "Count" could require enumeration if Count is not 0?

{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ClusterObserver/ClusterObserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<RootNamespace>ClusterObserver</RootNamespace>
<AssemblyName>ClusterObserver</AssemblyName>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>disable</Nullable>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
Expand Down
2 changes: 1 addition & 1 deletion ClusterObserver/ClusterObserverManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public sealed class ClusterObserverManager : IDisposable
private bool appParamsUpdating;

// Folks often use their own version numbers. This is for internal diagnostic telemetry.
private const string InternalVersionNumber = "2.2.8";
private const string InternalVersionNumber = "2.2.8-net8";

public bool EnableOperationalTelemetry
{
Expand Down
9 changes: 2 additions & 7 deletions ClusterObserver/FabricClusterObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ namespace ClusterObserver
/// <summary>
/// An instance of this class is created for each service instance by the Service Fabric runtime.
/// </summary>
internal sealed class FabricClusterObserver : StatelessService
internal sealed class FabricClusterObserver(StatelessServiceContext context) : StatelessService(context)
{
public FabricClusterObserver(StatelessServiceContext context)
: base(context)
{

}

/// <summary>
/// This is the main entry point for your service instance.
Expand Down Expand Up @@ -68,7 +63,7 @@ private void LoadObserversFromPlugins(IServiceCollection services)
}

PluginLoader[] pluginLoaders = new PluginLoader[pluginDlls.Length];
Type[] sharedTypes = { typeof(FabricObserverStartupAttribute), typeof(IFabricObserverStartup), typeof(IServiceCollection) };
Type[] sharedTypes = [typeof(FabricObserverStartupAttribute), typeof(IFabricObserverStartup), typeof(IServiceCollection)];

for (int i = 0; i < pluginDlls.Length; ++i)
{
Expand Down
8 changes: 4 additions & 4 deletions ClusterObserver/PackageRoot/ServiceManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="ClusterObserverPkg"
Version="2.2.8"
Version="2.2.8-net8"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Expand All @@ -11,7 +11,7 @@
</ServiceTypes>

<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="2.2.8">
<CodePackage Name="Code" Version="2.2.8-net8">
<EntryPoint>
<ExeHost>
<Program>ClusterObserver</Program>
Expand All @@ -21,11 +21,11 @@

<!-- Config package is the contents of the Config directory under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="2.2.8" />
<ConfigPackage Name="Config" Version="2.2.8-net8" />

<!-- Config package is the contents of the Config directory under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<DataPackage Name="Data" Version="2.2.8" />
<DataPackage Name="Data" Version="2.2.8-net8" />

<Resources>
<Endpoints>
Expand Down
12 changes: 6 additions & 6 deletions ClusterObserver/Readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### ClusterObserver 2.2.8
#### This version - and all subsequent versions - requires SF Runtime >= 9.0 and targets .NET 6
### ClusterObserver 2.2.8-net8
#### This version targets .NET 8

ClusterObserver (CO) is a stateless singleton Service Fabric .NET 6 service that runs on one node in a cluster. CO observes cluster health (aggregated)
ClusterObserver (CO) is a stateless singleton Service Fabric .NET 8 service that runs on one node in a cluster. CO observes cluster health (aggregated)
and sends telemetry when a cluster is in Error or Warning. CO shares a very small subset of FabricObserver's (FO) code. It is designed to be completely independent from FO sources,
but lives in this repo (and SLN) because it is very useful to have both services deployed, especially for those who want cluster-level health observation and reporting in addition to
the node-level user-defined resource monitoring, health event creation, and health reporting done by FO. FabricObserver is designed to generate Service Fabric health events based on user-defined resource usage Warning and Error thresholds which ClusterObserver sends to your log analytics and alerting service.
Expand Down Expand Up @@ -30,7 +30,7 @@ Application Parameter Upgrade Example:
```Powershell
$appName = "fabric:/ClusterObserver"
$appVersion = "2.2.8"
$appVersion = "2.2.8-net8"
$application = Get-ServiceFabricApplication -ApplicationName $appName
Expand Down Expand Up @@ -159,7 +159,7 @@ Start-ServiceFabricApplicationUpgrade -ApplicationName $appName -ApplicationType

``` XML
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ClusterObserverType" ApplicationTypeVersion="2.2.8" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ClusterObserverType" ApplicationTypeVersion="2.2.8-net8" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<!-- ClusterObserverManager settings. -->
<Parameter Name="ObserverManagerObserverLoopSleepTimeSeconds" DefaultValue="30" />
Expand Down Expand Up @@ -188,7 +188,7 @@ Start-ServiceFabricApplicationUpgrade -ApplicationName $appName -ApplicationType
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. -->
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="ClusterObserverPkg" ServiceManifestVersion="2.2.8" />
<ServiceManifestRef ServiceManifestName="ClusterObserverPkg" ServiceManifestVersion="2.2.8-net8" />
<ConfigOverrides>
<ConfigOverride Name="Config">
<Settings>
Expand Down
2 changes: 1 addition & 1 deletion ClusterObserver/Utilities/UpgradeChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class UpgradeChecker
/// <param name="token">CancellationToken</param>
/// <param name="app">ApplicationName (Uri)</param>
/// <returns>An instance of ServiceFabricUpgradeEventData containing ApplicationUpgradeProgress instance.</returns>
internal static async Task<ServiceFabricUpgradeEventData> GetApplicationUpgradeDetailsAsync(FabricClient fabricClient, CancellationToken token, Uri app)
internal static async Task<ServiceFabricUpgradeEventData> GetApplicationUpgradeDetailsAsync(FabricClient fabricClient, Uri app, CancellationToken token)
{
if (token.IsCancellationRequested)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ClusterObserverType" ApplicationTypeVersion="2.2.8" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="ClusterObserverType" ApplicationTypeVersion="2.2.8-net8" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<!-- ClusterObserverManager settings. -->
<Parameter Name="ObserverManagerObserverLoopSleepTimeSeconds" DefaultValue="30" />
Expand All @@ -11,8 +11,8 @@
<!-- ETW -->
<Parameter Name="ObserverManagerEnableETWProvider" DefaultValue="true" />
<Parameter Name="ObserverManagerETWProviderName" DefaultValue="ClusterObserverETWProvider" />
<!-- If you want to transmit telemetry events to ApplicationInsights or LogAnalytics, for example, then enable this setting. Otherwise, set this to false. -->
<!-- Observer Telemetry -->
<!-- If you want to transmit telemetry events to ApplicationInsights or LogAnalytics, for example, then enable this setting. Otherwise, set this to false. -->
<Parameter Name="ObserverManagerEnableTelemetryProvider" DefaultValue="true" />
<!-- Telemetry Provider - ApplicationInsights/LogAnalytics. Supported values are AzureApplicationInsights and AzureLogAnalytics. -->
<Parameter Name="TelemetryProvider" DefaultValue="" />
Expand All @@ -28,7 +28,7 @@
<Parameter Name="MaxArchivedLogFileLifetimeDays" DefaultValue="7" />
<!-- ClusterObserver settings. -->
<Parameter Name="ClusterObserverEnabled" DefaultValue="true" />
<Parameter Name="ClusterObserverEnableETW" DefaultValue="false" />
<Parameter Name="ClusterObserverEnableETW" DefaultValue="true" />
<Parameter Name="ClusterObserverEnableTelemetry" DefaultValue="true" />
<Parameter Name="ClusterObserverEnableVerboseLogging" DefaultValue="false" />
<Parameter Name="MaxTimeNodeStatusNotOk" DefaultValue="02:00:00" />
Expand All @@ -43,7 +43,7 @@
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. -->
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="ClusterObserverPkg" ServiceManifestVersion="2.2.8" />
<ServiceManifestRef ServiceManifestName="ClusterObserverPkg" ServiceManifestVersion="2.2.8-net8" />
<ConfigOverrides>
<ConfigOverride Name="Config">
<Settings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"applicationTypeVersionClusterObserver": {
"type": "string",
"defaultValue": "2.2.8",
"defaultValue": "2.2.8-net8",
"metadata": {
"description": "Provide the app version number of ClusterObserver. This must be identical to the version specified in the corresponding sfpkg."
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusterName": {
"value": "<ClusterResourceName>"
},
"applicationTypeVersionClusterObserver": {
"value": "2.2.8"
},
"packageUrlClusterObserver": {
"value": "<PUBLIC-ACCESSIBLE-URL-FOR-CLUSTEROBSERVER-SFPKG>"
}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusterName": {
"value": "<ClusterResourceName>"
},
"applicationTypeVersionClusterObserver": {
"value": "2.2.8"

This comment has been minimized.

Copy link
@sidhant012

sidhant012 Aug 6, 2024

Collaborator

Shouldn't this be 2.2.8-net8?

This comment has been minimized.

Copy link
@GitTorre

GitTorre Aug 6, 2024

Member

No. There should be no -net8 in version names. This will be a version bump.

},
"packageUrlClusterObserver": {
"value": "<PUBLIC-ACCESSIBLE-URL-FOR-CLUSTEROBSERVER-SFPKG>"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@
namespace FabricObserver
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class FabricObserverStartupAttribute : Attribute
public sealed class FabricObserverStartupAttribute(Type startupType) : Attribute
{
public FabricObserverStartupAttribute(Type startupType)
{
StartupType = startupType;
}

public Type StartupType
{
get;
}
} = startupType;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Platforms>x64</Platforms>
<RootNamespace>FabricObserver</RootNamespace>
<Copyright>Copyright © 2024</Copyright>
<Product>FabricObserver</Product>
<Version>3.2.16</Version>
<FileVersion>3.2.16</FileVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.22.0" />
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="6.0.1672" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.2" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions FabricObserver.Extensibility/ObserverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ public bool DumpWindowsServiceProcess(int processId, string procName, string met

}

if (!ServiceDumpCountDictionary.ContainsKey(dumpKey))
if (!ServiceDumpCountDictionary.TryGetValue(dumpKey, out (int DumpCount, DateTime LastDumpDate) value))
{
_ = ServiceDumpCountDictionary.TryAdd(dumpKey, (0, DateTime.UtcNow));
}
else if (DateTime.UtcNow.Subtract(ServiceDumpCountDictionary[dumpKey].LastDumpDate) >= MaxDumpsTimeWindow)
else if (DateTime.UtcNow.Subtract(value.LastDumpDate) >= MaxDumpsTimeWindow)
{
ServiceDumpCountDictionary[dumpKey] = (0, DateTime.UtcNow);
}
Expand Down
Loading

0 comments on commit e51cde8

Please sign in to comment.