From 6b57b4ff8337e6d81c9778e507fd320818df2240 Mon Sep 17 00:00:00 2001 From: Sidhant Bhatia Date: Thu, 12 Dec 2024 18:36:15 -0500 Subject: [PATCH] Octokit check github version config --- .../Utilities/ObserverConstants.cs | 1 + FabricObserver/Observers/ObserverManager.cs | 12 ++++++++---- FabricObserver/PackageRoot/Config/Settings.xml | 3 +++ .../ApplicationPackageRoot/ApplicationManifest.xml | 3 +++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/FabricObserver.Extensibility/Utilities/ObserverConstants.cs b/FabricObserver.Extensibility/Utilities/ObserverConstants.cs index fcfd0103..aeacf30e 100644 --- a/FabricObserver.Extensibility/Utilities/ObserverConstants.cs +++ b/FabricObserver.Extensibility/Utilities/ObserverConstants.cs @@ -18,6 +18,7 @@ public sealed class ObserverConstants public const string EnableFabricObserverOperationalTelemetry = "EnableFabricObserverOperationalTelemetry"; public const string AsyncClusterOperationTimeoutSeconds = "ClusterOperationTimeoutSeconds"; public const string ObserverFailureHealthStateLevelParameter = "ObserverFailureHealthStateLevel"; + public const string CheckGithubVersion = "CheckGithubVersion"; // The name of the package that contains this Observer's configuration public const string ObserverConfigurationPackageName = "Config"; diff --git a/FabricObserver/Observers/ObserverManager.cs b/FabricObserver/Observers/ObserverManager.cs index 10da8bd9..fdb0a52a 100644 --- a/FabricObserver/Observers/ObserverManager.cs +++ b/FabricObserver/Observers/ObserverManager.cs @@ -260,11 +260,15 @@ public async Task StartObserversAsync() } } - // Check for new version once a day. - if (!(shutdownSignaled || runAsyncToken.IsCancellationRequested) && DateTime.UtcNow.Subtract(LastVersionCheckDateTime) >= NewReleaseCheckInterval) + _ = bool.TryParse(GetConfigSettingValue(ObserverConstants.CheckGithubVersion, null), out bool checkGithubVersion); + if (checkGithubVersion) { - await CheckGithubForNewVersionAsync(); - LastVersionCheckDateTime = DateTime.UtcNow; + // Check for new version once a day. + if (!(shutdownSignaled || runAsyncToken.IsCancellationRequested) && DateTime.UtcNow.Subtract(LastVersionCheckDateTime) >= NewReleaseCheckInterval) + { + await CheckGithubForNewVersionAsync(); + LastVersionCheckDateTime = DateTime.UtcNow; + } } // Time to tale a nap before running observers again. 30 seconds is the minimum sleep time. diff --git a/FabricObserver/PackageRoot/Config/Settings.xml b/FabricObserver/PackageRoot/Config/Settings.xml index 145e6145..6f44de00 100644 --- a/FabricObserver/PackageRoot/Config/Settings.xml +++ b/FabricObserver/PackageRoot/Config/Settings.xml @@ -49,6 +49,9 @@ + + + diff --git a/FabricObserverApp/ApplicationPackageRoot/ApplicationManifest.xml b/FabricObserverApp/ApplicationPackageRoot/ApplicationManifest.xml index ef5e4e73..04d02cda 100644 --- a/FabricObserverApp/ApplicationPackageRoot/ApplicationManifest.xml +++ b/FabricObserverApp/ApplicationPackageRoot/ApplicationManifest.xml @@ -23,6 +23,8 @@ This is primarily useful for scenarios where you have multiple instances of FO running on a node and you want to ensure that each instance writes ETW event data to different named sinks. This is more of an advanced scenario. In general, just leave this blank. --> + + @@ -429,6 +431,7 @@ +