Skip to content

Commit

Permalink
FO 3.2.3.831
Browse files Browse the repository at this point in the history
FO 3.2.3.831
  • Loading branch information
GitTorre authored Oct 19, 2022
2 parents b2674d4 + 9f88a70 commit 6697b2b
Show file tree
Hide file tree
Showing 35 changed files with 982 additions and 302 deletions.
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.2.831" "$scriptPath\bin\release\FabricObserver\linux-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Linux.FrameworkDependent.3.2.2.831" "$scriptPath\bin\release\FabricObserver\linux-x64\framework-dependent\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Linux.SelfContained.3.2.3.831" "$scriptPath\bin\release\FabricObserver\linux-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Linux.FrameworkDependent.3.2.3.831" "$scriptPath\bin\release\FabricObserver\linux-x64\framework-dependent\FabricObserverType"

Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.SelfContained.3.2.2.831" "$scriptPath\bin\release\FabricObserver\win-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.FrameworkDependent.3.2.2.831" "$scriptPath\bin\release\FabricObserver\win-x64\framework-dependent\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.SelfContained.3.2.3.831" "$scriptPath\bin\release\FabricObserver\win-x64\self-contained\FabricObserverType"
Build-SFPkg "Microsoft.ServiceFabricApps.FabricObserver.Windows.FrameworkDependent.3.2.3.831" "$scriptPath\bin\release\FabricObserver\win-x64\framework-dependent\FabricObserverType"
}
finally {
Pop-Location
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Deployment/Deploy-FabricObserver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Try {

$resourceGroup = "<YOUR-CLUSTER-RESOURCE-NAME>"
$armTemplate = "service-fabric-observer.json"
$armTemplateParameters = "service-fabric-observer.v3.2.2.831.parameters.json"
$armTemplateParameters = "service-fabric-observer.v3.2.3.831.parameters.json"

cd "<LOCAL-FO-REPO-PATH>\Documentation\Deployment"

Expand Down
6 changes: 3 additions & 3 deletions Documentation/Deployment/service-fabric-observer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
},
"applicationTypeVersionFabricObserver": {
"type": "string",
"defaultValue": "3.2.2.831",
"defaultValue": "3.2.3.831",
"metadata": {
"description": "Provide the app version number of FabricObserver. This must be identical to the version, 3.2.2.831, in the referenced sfpkg specified in packageUrlFabricObserver."
"description": "Provide the app version number of FabricObserver. This must be identical to the version, 3.2.3.831, in the referenced sfpkg specified in packageUrlFabricObserver."
}
},
"packageUrlFabricObserver": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "This has to be a public accessible URL for the sfpkg file which contains the FabricObserver app package. Example: https://github.com/microsoft/service-fabric-observer/releases/download/[xxxxxxxx]/Microsoft.ServiceFabricApps.FabricObserver.Windows.SelfContained.3.2.2.831.sfpkg"
"description": "This has to be a public accessible URL for the sfpkg file which contains the FabricObserver app package. Example: https://github.com/microsoft/service-fabric-observer/releases/download/[xxxxxxxx]/Microsoft.ServiceFabricApps.FabricObserver.Windows.SelfContained.3.2.3.831.sfpkg"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"value": "<YOUR-CLUSTER-RESOURCE-NAME>"
},
"applicationTypeVersionFabricObserver": {
"value": "3.2.2.831"
"value": "3.2.3.831"
},
"packageUrlFabricObserver": {
"value": "<PUBLIC-ACCESSIBLE-URL-FOR-FABRICOBSERVER-SFPKG>"
Expand Down
2 changes: 1 addition & 1 deletion Documentation/OperationalTelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Here is a full example of exactly what is sent in one of these telemetry events,
"ClusterId": "00000000-1111-1111-0000-00f00d000d",
"ClusterType": "SFRP",
"NodeNameHash": "3e83569d4c6aad78083cd081215dafc81e5218556b6a46cb8dd2b183ed0095ad",
"FOVersion": "3.2.2.831",
"FOVersion": "3.2.3.831",
"HasPlugins": "False",
"ParallelCapable": "True",
"SFRuntimeVersion":"8.2.1363.9590"
Expand Down
9 changes: 4 additions & 5 deletions FabricObserver.Extensibility.nuspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="3.3.0">
<id>%PACKAGE_ID%</id>
<version>3.2.2</version>
<version>3.2.3</version>
<releaseNotes>
- Support for Service Fabric Resource Governance memory limit monitoring by AppObserver (Windows-only).
- Support for monitoring Private Bytes (Commit/Charge) usage by service processes (Windows-only).
- Support for monitoring multiple service code packages.
- Support for dumping service processes in Warning.
- Bug Fix (OSInfoProvider - Windows impl). This version fixes a bug with the Logger implementation in WindowsOSInfoProvider that leads to a NullReferenceException.
- Updated OSInfoProvider.TupleGetDynamicPortRange impl.
- Updated Windows TCP port detection impl to account for BOUND state connections (netstat is used to get port data in this release).
</releaseNotes>
<authors>Microsoft</authors>
<license type="expression">MIT</license>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<RootNamespace>FabricObserver</RootNamespace>
<Copyright>Copyright © 2022</Copyright>
<Product>FabricObserver</Product>
<Version>3.2.2</Version>
<FileVersion>3.2.2</FileVersion>
<Version>3.2.3</Version>
<FileVersion>3.2.3</FileVersion>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Utilities\MemoryUsage\**" />
Expand Down
12 changes: 5 additions & 7 deletions FabricObserver.Extensibility/ObserverBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,21 +1050,19 @@ public void ProcessResourceDataReportHealth<T>(
// Ephemeral port sugar for event description.
string dynamicRange = string.Empty;
string totalPorts = string.Empty;
int Low = 0, High = 0;
int Low = 0, High = 0, Total = 0;

if (data.Property.Contains("Ephemeral"))
{
(Low, High) = OSInfoProvider.Instance.TupleGetDynamicPortRange();
(Low, High, Total) = OSInfoProvider.Instance.TupleGetDynamicPortRange();
dynamicRange = $" (dynamic range: {Low}-{High})";

if (data.Property.Contains("Percent"))
{
int total = High - Low;

if (total > 0)
if (Total > 0)
{
int count = (int)(data.AverageDataValue / 100 * total);
totalPorts = $" ({count}/{total})";
int count = (int)(data.AverageDataValue / 100 * Total);
totalPorts = $" ({count}/{Total})";
}
}
}
Expand Down
65 changes: 63 additions & 2 deletions FabricObserver.Extensibility/Utilities/HealthReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,78 +11,139 @@ namespace FabricObserver.Observers.Utilities
{
public class HealthReport
{
/// <summary>
/// Service Fabric Application Name.
/// </summary>
public Uri AppName
{
get; set;
}

/// <summary>
/// Error code.
/// </summary>
public string Code
{
get; set;
}

/// <summary>
/// TTL for Health Report (Time-to-live).
/// </summary>
public TimeSpan HealthReportTimeToLive
{
get; set;
}

/// <summary>
/// Description.
/// </summary>
public string HealthMessage
{
get; set;
}

public bool EmitLogEvent { get; set; } = true;

/// <summary>
/// Whether or not to write a local log entry in addition to generating a health report. Default is true.
/// Note that if Verbose logging is not enabled for some observer, then only Warning and Error report data will be written to local logs.
/// </summary>
public bool EmitLogEvent
{
get; set;
} = true;

/// <summary>
/// Target EntityType (Node, Application, Service, Machine, etc.). This determines what kind of HealthReport FabricObserver will generate.
/// Use this instead of the deprecated ReportType.
/// </summary>
public EntityType EntityType
{
get; set;
}

/// <summary>
/// [Deprecated] Type of health report. Use EntityType instead.
/// </summary>
public HealthReportType ReportType
{
get; set;
}

/// <summary>
/// HealthState.
/// </summary>
public HealthState State
{
get; set;
}

/// <summary>
/// Node name.
/// </summary>
public string NodeName
{
get; set;
}

/// <summary>
/// Observer name.
/// </summary>
public string Observer
{
get; set;
}

/// <summary>
/// Service Fabric Health Event Property.
/// </summary>
public string Property
{
get; set;
}

/// <summary>
/// Resource usage data property.
/// </summary>
public string ResourceUsageDataProperty
{
get; set;
}

/// <summary>
/// Service Fabric Health Event SourceId.
/// </summary>
public string SourceId
{
get; set;
}

/// <summary>
/// TelemetryData instance (this will be JSON-serialized and used as the Description of the generated health event).
/// </summary>
public TelemetryData HealthData
{
get; set;
}

/// <summary>
/// Service Fabric Service name.
/// </summary>
public Uri ServiceName
{
get; set;
}

/// <summary>
/// Service Fabric Partition Id.
/// </summary>
public Guid PartitionId
{
get; set;
}

/// <summary>
/// Service Fabric Replica or Instance Id.
/// </summary>
public long ReplicaOrInstanceId
{
get; set;
Expand Down
6 changes: 4 additions & 2 deletions FabricObserver.Extensibility/Utilities/JsonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static bool IsJson<T>(string text)
MissingMemberHandling = MissingMemberHandling.Ignore
};

return TryDerializeObject<T>(text, out _, jsonSerializerSettings);
return TryDeserializeObject<T>(text, out _, jsonSerializerSettings);
}
catch (JsonException)
{
Expand Down Expand Up @@ -86,7 +86,7 @@ public static bool TrySerializeObject<T>(T obj, out string data)
/// <param name="obj">Json string representing an instance of type T.</param>
/// <param name="data">out: an instance of type T.</param>
/// <returns>An instance of the specified type T or null if the string can't be deserialized into the specified type T. Note: Missing members are treated as Error.</returns>
public static bool TryDerializeObject<T>(string obj, out T data, JsonSerializerSettings jsonSerializerSettings = null)
public static bool TryDeserializeObject<T>(string obj, out T data, JsonSerializerSettings jsonSerializerSettings = null)
{
if (string.IsNullOrWhiteSpace(obj))
{
Expand All @@ -98,6 +98,8 @@ public static bool TryDerializeObject<T>(string obj, out T data, JsonSerializerS
{
if (jsonSerializerSettings == null)
{
// Being strict here is the default behavior. This is important because ChildProcessTelemetryData is close enough in structure to TelemetryData
// that without this setting either serialized type would deserialize to TelemetryData successfully, which is not the right behavior.
jsonSerializerSettings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error };
}

Expand Down
22 changes: 8 additions & 14 deletions FabricObserver.Extensibility/Utilities/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static class NativeMethods
private const int ERROR_SUCCESS = 0;
private const int THREAD_STILL_ACTIVE = 259;
private const int ERROR_NO_MORE_ITEMS = 259;
private const int ERROR_INSUFFICIENT_BUFFER_SIZE = 122;
private static readonly Logger logger = new Logger("NativeMethods");

[Flags]
Expand Down Expand Up @@ -825,7 +826,7 @@ private enum PSS_WALK_INFORMATION_CLASS
private static extern bool GlobalMemoryStatusEx([In, Out] MEMORYSTATUSEX lpBuffer);

[DllImport("iphlpapi.dll", SetLastError = true)]
private static extern uint GetExtendedTcpTable(IntPtr pTcpTable, ref int dwOutBufLen, bool sort, int ipVersion, TCP_TABLE_CLASS tblClass, uint reserved = 0);
public static extern uint GetExtendedTcpTable(IntPtr pTcpTable, ref uint pdwSize, [MarshalAs(UnmanagedType.Bool)] bool bOrder, uint ulAf, TCP_TABLE_CLASS TableClass, uint Reserved = 0);

[DllImport("kernel32.dll", SetLastError = true)]
private static extern int PssCaptureSnapshot(SafeProcessHandle ProcessHandle, PSS_CAPTURE_FLAGS CaptureFlags, uint ContextFlags, ref IntPtr SnapshotHandle);
Expand Down Expand Up @@ -1249,26 +1250,25 @@ public static MEMORYSTATUSEX GetSystemMemoryInfo()
/// Gets a list of TCP (v4) connection info objects for use in determining TCP ports in use per process or machine-wide.
/// </summary>
/// <returns>List of MIB_TCPROW_OWNER_PID objects.</returns>
public static List<MIB_TCPROW_OWNER_PID> GetAllTcpConnections()
public static List<MIB_TCPROW_OWNER_PID> GetAllTCPV4Connections()
{
return GetTCPConnections<MIB_TCPROW_OWNER_PID, MIB_TCPTABLE_OWNER_PID>(AF_INET);
}

public static List<MIB_TCP6ROW_OWNER_PID> GetAllTcpIpv6Connections()
public static List<MIB_TCP6ROW_OWNER_PID> GetAllTCPV6Connections()
{
return GetTCPConnections<MIB_TCP6ROW_OWNER_PID, MIB_TCP6TABLE_OWNER_PID>(AF_INET6);
}

private static List<IPR> GetTCPConnections<IPR, IPT>(int ipVersion)//IPR = Row Type, IPT = Table Type
private static List<IPR> GetTCPConnections<IPR, IPT>(uint ipVersion)
{
IPR[] tableRows;
int buffSize = 0;

uint buffSize = 0;
var dwNumEntriesField = typeof(IPT).GetField("dwNumEntries");

// Determine how much memory to allocate.
_ = GetExtendedTcpTable(IntPtr.Zero, ref buffSize, true, ipVersion, TCP_TABLE_CLASS.TCP_TABLE_OWNER_PID_ALL);
IntPtr tcpTablePtr = Marshal.AllocHGlobal(buffSize);
IntPtr tcpTablePtr = Marshal.AllocHGlobal((int)buffSize);

try
{
Expand All @@ -1277,17 +1277,12 @@ private static List<IPR> GetTCPConnections<IPR, IPT>(int ipVersion)//IPR = Row T
if (ret != ERROR_SUCCESS)
{
logger.LogWarning($"GetTCPConnections: Failed to get TCP connections with Win32 error {Marshal.GetLastWin32Error()}");

// return an empty list to caller.
return new List<IPR>();
}

// get the number of entries in the table
IPT table = (IPT)Marshal.PtrToStructure(tcpTablePtr, typeof(IPT));
int rowStructSize = Marshal.SizeOf(typeof(IPR));
uint numEntries = (uint)dwNumEntriesField.GetValue(table);

// buffer we will be returning
tableRows = new IPR[numEntries];
IntPtr rowPtr = (IntPtr)((long)tcpTablePtr + 4);

Expand All @@ -1300,7 +1295,6 @@ private static List<IPR> GetTCPConnections<IPR, IPT>(int ipVersion)//IPR = Row T
}
finally
{
// Free memory
Marshal.FreeHGlobal(tcpTablePtr);
}

Expand Down Expand Up @@ -1442,7 +1436,7 @@ private static bool FindInStringArray(string[] arr, string s)

for (int i = 0; i < arr.Length; i++)
{
if (string.IsNullOrWhiteSpace(arr[i]) || arr[i] != s)
if (arr[i] != s)
{
continue;
}
Expand Down
Loading

0 comments on commit 6697b2b

Please sign in to comment.