Skip to content

Commit

Permalink
Merge pull request #303 from microsoft/net8
Browse files Browse the repository at this point in the history
Net8 changes
  • Loading branch information
sidhant012 authored Aug 7, 2024
2 parents 4d322d7 + 7474e82 commit ad28a23
Show file tree
Hide file tree
Showing 69 changed files with 544 additions and 670 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.3.0" "$scriptPath\bin\release\ClusterObserver\linux-x64\self-contained\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Linux.FrameworkDependent.2.3.0" "$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.3.0" "$scriptPath\bin\release\ClusterObserver\win-x64\self-contained\ClusterObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.ClusterObserver.Windows.FrameworkDependent.2.3.0" "$scriptPath\bin\release\ClusterObserver\win-x64\framework-dependent\ClusterObserverType"
}
finally {
Pop-Location
Expand Down
8 changes: 4 additions & 4 deletions Build-SFPkgs.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.FabricObserver.Linux.SelfContained.3.2.16" "$scriptPath\bin\release\FabricObserver\linux-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Linux.FrameworkDependent.3.2.16" "$scriptPath\bin\release\FabricObserver\linux-x64\framework-dependent\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Linux.SelfContained.3.3.0" "$scriptPath\bin\release\FabricObserver\linux-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Linux.FrameworkDependent.3.3.0" "$scriptPath\bin\release\FabricObserver\linux-x64\framework-dependent\FabricObserverType"

Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.SelfContained.3.2.16" "$scriptPath\bin\release\FabricObserver\win-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.FrameworkDependent.3.2.16" "$scriptPath\bin\release\FabricObserver\win-x64\framework-dependent\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.SelfContained.3.3.0" "$scriptPath\bin\release\FabricObserver\win-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.FrameworkDependent.3.3.0" "$scriptPath\bin\release\FabricObserver\win-x64\framework-dependent\FabricObserverType"
}
finally {
Pop-Location
Expand Down
18 changes: 8 additions & 10 deletions ClusterObserver.nuspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="3.3.0">
<id>%PACKAGE_ID%</id>
<version>2.2.8</version>
<version>2.3.0</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.
- .NET 8 implementation of ClusterObserver. This version is built for .NET 8 and SF Runtime >= 9.1 (Self-Contained FO builds only). If you have deployed SF Runtime version >= 10.1 Cumulative Update 3.0 (CU3), then you can deploy the framework-dependent release build for the target platform (Windows or Linux). If you are not running SF Runtime version >= 10.1 CU3, then you must deploy the Self-Contained release build for the target platform (Windows or Linux). **If you can't upgrade to .NET 8 yet, then do not upgrade to this version.**
</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.3.0" />
</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)
{
return;
}
Expand Down
8 changes: 5 additions & 3 deletions ClusterObserver/ClusterObserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
<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>
<TargetLatestRuntimePatch>True</TargetLatestRuntimePatch>
<Product>ClusterObserver</Product>
<Version>2.2.8</Version>
<FileVersion>2.2.8</FileVersion>
<Version>2.3.0</Version>
<FileVersion>2.3.0</FileVersion>
<Copyright>Copyright © 2024</Copyright>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<StartupObject>ClusterObserver.Program</StartupObject>
<Platforms>x64</Platforms>
<!-- In .NET 8, if you want to build self-contained in VS, you must uncomment and set this to true.
<SelfContained>True</SelfContained>-->
</PropertyGroup>
<ItemGroup>
<Compile Remove="Utilities\ClusterIdentificationUtility.cs" />
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.3.0";

public bool EnableOperationalTelemetry
{
Expand Down
40 changes: 32 additions & 8 deletions ClusterObserver/FabricClusterObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
using System.Reflection;
using System.Linq;
using FabricObserver.Utilities;
using FabricObserver.Observers.Utilities;
using FabricObserver.Observers.Utilities.Telemetry;

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)
{

}
private readonly Logger logger = new("ClusterObserverService");

/// <summary>
/// This is the main entry point for your service instance.
Expand Down Expand Up @@ -68,11 +66,12 @@ 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)];
string dll = "";

for (int i = 0; i < pluginDlls.Length; ++i)
{
string dll = pluginDlls[i];
dll = pluginDlls[i];
PluginLoader loader = PluginLoader.CreateFromAssemblyFile(dll, sharedTypes, a => a.IsUnloadable = false);
pluginLoaders[i] = loader;
}
Expand Down Expand Up @@ -109,8 +108,33 @@ private void LoadObserversFromPlugins(IServiceCollection services)
}
catch (Exception e) when (e is ArgumentException or BadImageFormatException or IOException)
{
if (e is IOException)
{
string error = $"Plugin dll {dll} could not be loaded. {e.Message}";
HealthReport healthReport = new()
{
AppName = new Uri($"{Context.CodePackageActivationContext.ApplicationName}"),
EmitLogEvent = true,
HealthMessage = error,
EntityType = EntityType.Application,
HealthReportTimeToLive = TimeSpan.FromMinutes(10),
State = System.Fabric.Health.HealthState.Warning,
Property = "ClusterObserverPluginLoadError",
SourceId = $"ClusterObserverService-{Context.NodeContext.NodeName}",
NodeName = Context.NodeContext.NodeName,
};

ObserverHealthReporter observerHealth = new(logger);
observerHealth.ReportHealthToServiceFabric(healthReport);
}

continue;
}
catch (Exception e) when (e is not OutOfMemoryException)
{
logger.LogError($"Unhandled exception in ClusterObserverService Instance: {e.Message}");
throw;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion ClusterObserver/PackageRoot/Config/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@
If you want to enable versionless, parameter-only application upgrades, then add MustOverride to the Parameters you want to be
able to change without redeploying CO and add them to ApplicationManifest.xml just like for ClusterObserver.
<Section Name="MyClusterObserverPluginConfiguration">
<Section Name="SampleNewObserverConfiguration">
<Parameter Name="Enabled" Value="true" />
<Parameter Name="ClusterOperationTimeoutSeconds" Value="120" />
<Parameter Name="EnableEtw" Value="false" />
<Parameter Name="EnableTelemetry" Value="false" />
<Parameter Name="EnableVerboseLogging" Value="false" />
<Parameter Name="RunInterval" Value="" />
</Section> -->
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.3.0"
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.3.0">
<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.3.0" />

<!-- 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.3.0" />

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

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.

Starting with version 2.3.0, you must deploy the self-contained release package unless you are deploying to a cluster running SF Version >= 10.1 CU3 or higher, then you can deploy framework-dependent release.

By design, CO will send an Ok health state report when a cluster goes from Warning or Error state to Ok.

CO only sends telemetry when something is wrong or when something that was previously wrong recovers. This limits the amount of data sent to your log analytics service. Like FabricObserver, you can implement whatever analytics backend
Expand All @@ -30,7 +32,7 @@ Application Parameter Upgrade Example:
```Powershell
$appName = "fabric:/ClusterObserver"
$appVersion = "2.2.8"
$appVersion = "2.3.0"
$application = Get-ServiceFabricApplication -ApplicationName $appName
Expand Down Expand Up @@ -159,7 +161,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.3.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<!-- ClusterObserverManager settings. -->
<Parameter Name="ObserverManagerObserverLoopSleepTimeSeconds" DefaultValue="30" />
Expand Down Expand Up @@ -188,7 +190,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.3.0" />
<ConfigOverrides>
<ConfigOverride Name="Config">
<Settings>
Expand Down Expand Up @@ -260,8 +262,8 @@ Here is a full example of exactly what is sent in one of these telemetry events,
"TaskName": "ClusterObserver",
"ClusterId": "00000000-1111-1111-0000-00f00d000d",
"ClusterType": "SFRP",
"COVersion": "2.2.0.960",
"Timestamp": "2022-07-12T19:02:04.4287671Z",
"COVersion": "2.3.0",
"Timestamp": "2024-06-06T19:02:04.4287671Z",
"OS": "Windows"
}
```
Expand Down
Loading

0 comments on commit ad28a23

Please sign in to comment.