sample healer plugin project like the one we have in FO
This commit is contained in:
Родитель
cca6332283
Коммит
e31b63d55b
|
@ -25,8 +25,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
Documentation\OperationalTelemetry.md = Documentation\OperationalTelemetry.md
|
||||
README.md = README.md
|
||||
Documentation\Deployment\service-fabric-healer.json = Documentation\Deployment\service-fabric-healer.json
|
||||
Documentation\Deployment\service-fabric-healer.v1.2.11.parameters.json = Documentation\Deployment\service-fabric-healer.v1.2.11.parameters.json
|
||||
Documentation\Using.md = Documentation\Using.md
|
||||
Documentation\Deployment\service-fabric-healer.v1.2.12.parameters.json = Documentation\Deployment\service-fabric-healer.v1.2.12.parameters.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FHTest", "FHTest\FHTest.csproj", "{8D9712BF-C026-4A36-B6D1-6345137D3B6F}"
|
||||
|
@ -37,6 +37,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelemetryLib", "TelemetryLi
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FabricHealerProxy", "FabricHealerProxy\FabricHealerProxy.csproj", "{FB6B2E0E-2243-4447-BA56-7D91CB0D2127}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleHealerPlugin", "SampleHealerPlugin\SampleHealerPlugin.csproj", "{88C2DBDC-2C91-4145-804C-B91879BDCB94}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -89,6 +91,14 @@ Global
|
|||
{FB6B2E0E-2243-4447-BA56-7D91CB0D2127}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FB6B2E0E-2243-4447-BA56-7D91CB0D2127}.Release|x64.ActiveCfg = Release|x64
|
||||
{FB6B2E0E-2243-4447-BA56-7D91CB0D2127}.Release|x64.Build.0 = Release|x64
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{88C2DBDC-2C91-4145-804C-B91879BDCB94}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -197,4 +197,6 @@ TimeScopedRestartReplica(?count, ?time) :- GetRepairHistory(?repairCount, ?time)
|
|||
TimeScopedRestartCodePackage :- RestartCodePackage(DoHealthChecks=false, MaxWaitTimeForHealthStateOk=00:01:00, MaxExecutionTime=00:30:00).
|
||||
|
||||
## Restart individual replica hosted in the process. If you do not specify a value for MaxExecutionTime argument, the default is 60 minutes.
|
||||
TimeScopedRestartReplica :- RestartReplica(DoHealthChecks=false, MaxWaitTimeForHealthStateOk=00:01:00, MaxExecutionTime=00:15:00).
|
||||
TimeScopedRestartReplica :- RestartReplica(DoHealthChecks=false, MaxWaitTimeForHealthStateOk=00:01:00, MaxExecutionTime=00:15:00).
|
||||
|
||||
##Mitigate(HealthState="Warning") :- SampleHealerPluginPredicateType("repair rule loaded from plugin").
|
|
@ -0,0 +1,21 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy "$(ProjectDir)packages\microsoft.logic.guan\1.0.4\lib\netstandard2.0\Guan.dll" "$(OutDir)"
" />
|
||||
<Exec Command="copy "$(OutDir)*.dll" "$(OutDir)FabricHealerPkg\Data\Plugins"
copy "$(OutDir)*.pdb" "$(OutDir)FabricHealerPkg\Data\Plugins"" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Logic.Guan" Version="1.0.4" />
|
||||
<PackageReference Include="microsoft.servicefabricapps.fabrichealer.windows.selfcontained" Version="1.2.12" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="packages\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,93 @@
|
|||
// ------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
using System.Globalization;
|
||||
using Guan.Logic;
|
||||
using FabricHealer.Utilities;
|
||||
using FabricHealer.TelemetryLib;
|
||||
using FabricHealer.Utilities.Telemetry;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace FabricHealer.Repair.Guan
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper external predicate that generates health/etw/telemetry events.
|
||||
/// </summary>
|
||||
public class SampleHealerPluginPredicateType : PredicateType
|
||||
{
|
||||
private static SampleHealerPluginPredicateType Instance;
|
||||
private static TelemetryData RepairData;
|
||||
|
||||
private class Resolver : BooleanPredicateResolver
|
||||
{
|
||||
public Resolver(CompoundTerm input, Constraint constraint, QueryContext context)
|
||||
: base(input, constraint, context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override async Task<bool> CheckAsync()
|
||||
{
|
||||
Debugger.Launch();
|
||||
int count = Input.Arguments.Count;
|
||||
string output, format;
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
throw new GuanException("SampleHealerPluginPredicateType: At least 1 argument is required.");
|
||||
}
|
||||
|
||||
format = Input.Arguments[0].Value.GetEffectiveTerm().GetStringValue();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(format))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// formatted args string?
|
||||
if (count > 1)
|
||||
{
|
||||
object[] args = new object[count - 1];
|
||||
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
args[i - 1] = Input.Arguments[i].Value.GetEffectiveTerm().GetObjectValue();
|
||||
}
|
||||
|
||||
output = string.Format(CultureInfo.InvariantCulture, format, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
output = format;
|
||||
}
|
||||
|
||||
await FabricHealerManager.TelemetryUtilities.EmitTelemetryEtwHealthEventAsync(
|
||||
LogLevel.Warning,
|
||||
"LogWarningPredicate",
|
||||
output,
|
||||
FabricHealerManager.Token);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static SampleHealerPluginPredicateType Singleton(string name, TelemetryData repairData)
|
||||
{
|
||||
RepairData = repairData;
|
||||
return Instance ??= new SampleHealerPluginPredicateType(name);
|
||||
}
|
||||
|
||||
private SampleHealerPluginPredicateType(string name)
|
||||
: base(name, true, 1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override PredicateResolver CreateResolver(CompoundTerm input, Constraint constraint, QueryContext context)
|
||||
{
|
||||
return new Resolver(input, constraint, context);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
// ------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
using FabricHealer.Attributes;
|
||||
using FabricHealer.Interfaces;
|
||||
using FabricHealer.Repair.Guan;
|
||||
using FabricObserver.Observers;
|
||||
using Guan.Logic;
|
||||
using FabricHealer.Utilities.Telemetry;
|
||||
|
||||
[assembly: CustomRepairPredicateType(typeof(SampleNewHealerStartup))]
|
||||
namespace FabricObserver.Observers
|
||||
{
|
||||
public class SampleNewHealerStartup : IPredicateTypesCollection
|
||||
{
|
||||
public void RegisterPredicateTypes(FunctorTable functorTable, TelemetryData repairData)
|
||||
{
|
||||
functorTable.Add(SampleHealerPluginPredicateType.Singleton(nameof(SampleHealerPluginPredicateType), repairData));
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче