Skip to content

Commit

Permalink
Merge pull request #304 from microsoft/develop
Browse files Browse the repository at this point in the history
.net8 changes
  • Loading branch information
sidhant012 authored Aug 7, 2024
2 parents b243209 + ad28a23 commit 22bd802
Show file tree
Hide file tree
Showing 86 changed files with 862 additions and 1,889 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.15" "$scriptPath\bin\release\FabricObserver\linux-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Linux.FrameworkDependent.3.2.15" "$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.15" "$scriptPath\bin\release\FabricObserver\win-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.FrameworkDependent.3.2.15" "$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
11 changes: 7 additions & 4 deletions ClusterObserver/ClusterObserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +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 All @@ -24,7 +27,7 @@
<None Remove="ApplicationInsights.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="6.0.1017" />
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="6.0.1672" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
</ItemGroup>
<ItemGroup>
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
9 changes: 4 additions & 5 deletions ClusterObserver/PackageRoot/Config/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
**NOTE: For Linux runtime target, just supply the name of the directory (not a path with drive letter like you for Windows).** -->
<Parameter Name="ObserverLogPath" Value="" MustOverride="true" />
<!-- Required: Enabling this will generate noisy logs. Disabling it means only Warning and Error information
will be locally logged. This is the recommended setting. Note that file logging is generally
only useful for FabricObserverWebApi, which is an optional log reader service that ships in this repo. -->
will be locally logged. This is the recommended setting. -->
<Parameter Name="EnableVerboseLogging" Value="" MustOverride="true" />
<Parameter Name="ObserverFailureHealthStateLevel" Value="" MustOverride="true" />
<Parameter Name="EnableETWProvider" Value="" MustOverride="true" />
Expand Down Expand Up @@ -66,8 +65,7 @@
<!-- Required: To enable or not enable, that is the question.-->
<Parameter Name="Enabled" Value="" MustOverride="true" />
<!-- Optional: Enabling this will generate noisy logs. Disabling it means only Warning and Error information
will be locally logged. This is the recommended setting. Note that file logging is generally
only useful for FabricObserverWebApi, which is an optional log reader service that ships in this repo. -->
will be locally logged. This is the recommended setting. -->
<Parameter Name="EnableEtw" Value="" MustOverride="true"/>
<Parameter Name="EnableVerboseLogging" Value="" MustOverride="true" />
<Parameter Name="EnableTelemetry" Value="" MustOverride="true" />
Expand All @@ -92,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
Loading

0 comments on commit 22bd802

Please sign in to comment.