Skip to content

Commit

Permalink
Octokit Github Version Check (#189)
Browse files Browse the repository at this point in the history
* made github version check configurable for airgapped clusters

* added missing parameter value to ConfigOverride section

---------

Co-authored-by: Sidhant Bhatia <[email protected]>
  • Loading branch information
sidhant012 and Sidhant Bhatia authored Dec 13, 2024
1 parent a80f202 commit e14233a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
12 changes: 8 additions & 4 deletions FabricHealer/FabricHealerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,17 @@ await TelemetryUtilities.EmitTelemetryEtwHealthEventAsync(
}
}

// Check for new version once a day.
if (DateTime.UtcNow.Subtract(LastVersionCheckDateTime) >= OperationalTelemetryRunInterval)
if (ConfigSettings.CheckGithubVersion)
{
await CheckGithubForNewVersionAsync();
LastVersionCheckDateTime = DateTime.UtcNow;
// Check for new version once a day.
if (DateTime.UtcNow.Subtract(LastVersionCheckDateTime) >= OperationalTelemetryRunInterval)
{
await CheckGithubForNewVersionAsync();
LastVersionCheckDateTime = DateTime.UtcNow;
}
}


await Task.Delay(
TimeSpan.FromSeconds(
ConfigSettings.HealthCheckIntervalInSeconds > 0 ? ConfigSettings.HealthCheckIntervalInSeconds : 10), Token);
Expand Down
1 change: 1 addition & 0 deletions FabricHealer/PackageRoot/Config/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Parameter Name="EnableVerboseLogging" Value="" MustOverride="true" />
<Parameter Name="EnableTelemetry" Value="" MustOverride="true" />
<Parameter Name="EnableETW" Value="" MustOverride="true" />
<Parameter Name="CheckGithubVersion" Value="" MustOverride="true"/>
<!-- Big Red Button: You can turn FabricHealer on and off with a versionless parameter-only application upgrade. -->
<Parameter Name="EnableAutoMitigation" Value="" MustOverride="true" />
<Parameter Name="EnableOperationalTelemetry" Value="" MustOverride="true" />
Expand Down
3 changes: 3 additions & 0 deletions FabricHealer/Repair/RepairConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,8 @@ public static class RepairConstants
public const string MaxOutstandingRepairs = "MaxOutstandingRepairs";
public const string NodeProbationPeriod = "NodeProbationPeriod";
public const string MinHealthStateDuration = "MinHealthStateDuration";

// Octokit Github Version Check
public const string CheckGithubVersion = "CheckGithubVersion";
}
}
11 changes: 11 additions & 0 deletions FabricHealer/Utilities/ConfigSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public string AppInsightsConnectionString
private set;
}

public bool CheckGithubVersion
{
get;
private set;
}

// For Azure LogAnalytics Telemetry
public string LogAnalyticsWorkspaceId
{
Expand Down Expand Up @@ -188,6 +194,11 @@ internal void UpdateConfigSettings(ConfigurationSettings settings = null)
EnableCustomRepairPredicateType = enableCustomRepairPredicateType;
}

if(bool.TryParse(GetConfigSettingValue(RepairConstants.RepairManagerConfigurationSectionName, RepairConstants.CheckGithubVersion), out bool checkGithubVersion))
{
CheckGithubVersion = checkGithubVersion;
}

// Logger
if (bool.TryParse(GetConfigSettingValue(RepairConstants.RepairManagerConfigurationSectionName, RepairConstants.EnableVerboseLoggingParameter), out bool enableVerboseLogging))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Parameter Name="AutoMitigationEnabled" DefaultValue="true" />
<Parameter Name="EnableETW" DefaultValue="false" />
<Parameter Name="HealthCheckIntervalInSeconds" DefaultValue="30" />
<Parameter Name="CheckGithubVersion" DefaultValue="true"/>
<!-- If set to true, then FH will emit log events containing the full text of the logic rule with the currently executing external repair predicate.
This is extremely useful for both debugging and auditing repair rules. -->
<Parameter Name="EnableLogicRuleTracing" DefaultValue="true" />
Expand Down Expand Up @@ -60,6 +61,7 @@
<Parameter Name="EnableLogicRuleTracing" Value="[EnableLogicRuleTracing]" />
<Parameter Name="EnableCustomServiceInitializers" Value="[EnableCustomServiceInitializers]" />
<Parameter Name="EnableCustomRepairPredicateType" Value="[EnableCustomRepairPredicateType]" />
<Parameter Name="CheckGithubVersion" Value="[CheckGithubVersion]" />
</Section>
<!-- Repair policies -->
<Section Name="AppRepairPolicy">
Expand Down

0 comments on commit e14233a

Please sign in to comment.