Skip to content

Commit

Permalink
Psp 8624 - allow api startup without external services. (#4095)
Browse files Browse the repository at this point in the history
* psp-8624 reclassify health checks run as part of readiness check

* PSP-8624 prevent psp health checks from preventing startup.
  • Loading branch information
devinleighsmith authored Jun 10, 2024
1 parent 329e31e commit 9429943
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
var fileTypes = await _generationRepository.TryGetFileTypesAsync();
if (fileTypes.HttpStatusCode != System.Net.HttpStatusCode.OK || fileTypes.Payload == null || fileTypes.Payload.Dictionary.Count == 0)
{
return new HealthCheckResult(HealthStatus.Unhealthy, $"received invalid file types response from CDOGS");
return new HealthCheckResult(HealthStatus.Degraded, $"received invalid file types response from CDOGS");
}
}
catch (Exception e)
{
return new HealthCheckResult(HealthStatus.Degraded, $"Cdogs error response: {e.Message} {e.StackTrace}");
return new HealthCheckResult(context.Registration.FailureStatus, $"Cdogs error response: {e.Message} {e.StackTrace}");
}
return HealthCheckResult.Healthy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
var sites = await _geocoderService.GetSiteAddressesAsync(_address);
if (sites == null || !sites.Features.Any())
{
return new HealthCheckResult(HealthStatus.Unhealthy, $"received invalid file types response from Geocoder");
return new HealthCheckResult(HealthStatus.Degraded, $"received invalid file types response from Geocoder");
}
}
catch (Exception e)
{
return new HealthCheckResult(HealthStatus.Degraded, $"Mayan error response: {e.Message}");
return new HealthCheckResult(context.Registration.FailureStatus, $"Mayan error response: {e.Message}");
}
return HealthCheckResult.Healthy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
var titleSummary = await _ltsaService.GetTitleSummariesAsync(_pid);
if (titleSummary.TitleSummaries.Count == 0)
{
return new HealthCheckResult(HealthStatus.Unhealthy, $"received invalid title summary response for pid: {_pid}");
return new HealthCheckResult(HealthStatus.Degraded, $"received invalid title summary response for pid: {_pid}");
}
}
catch(LtsaException e)
{
return new HealthCheckResult(HealthStatus.Degraded, $"LTSA error response: {e.Message}");
return new HealthCheckResult(context.Registration.FailureStatus, $"LTSA error response: {e.Message}");
}
return HealthCheckResult.Healthy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
}
catch (Exception e)
{
return new HealthCheckResult(HealthStatus.Degraded, $"Mayan error response: {e.Message}");
return new HealthCheckResult(context.Registration.FailureStatus, $"Mayan error response: {e.Message}");
}
return HealthCheckResult.Healthy();
}
Expand Down
6 changes: 3 additions & 3 deletions source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<UserSecretsId>0ef6255f-9ea0-49ec-8c65-c172304b4926</UserSecretsId>
<Version>5.3.0-81.35</Version>
<Version>5.3.0-81.35</Version>
<AssemblyVersion>5.3.0.81</AssemblyVersion>
<Version>5.3.1-81.35</Version>
<Version>5.3.1-81.35</Version>
<AssemblyVersion>5.3.1.81</AssemblyVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<ProjectGuid>16BC0468-78F6-4C91-87DA-7403C919E646</ProjectGuid>
<TargetFramework>net8.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion source/backend/api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVers
});
app.UseHealthChecks(this.Configuration.GetValue<string>("HealthChecks:ReadyPath"), healthPort, new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("services"),
Predicate = r => r.Tags.Contains("services") && !r.Tags.Contains("external"),
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse,
});

Expand Down
2 changes: 1 addition & 1 deletion source/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "5.3.0-81.35",
"version": "5.3.1-81.35",
"private": true,
"dependencies": {
"@bcgov/bc-sans": "1.0.1",
Expand Down

0 comments on commit 9429943

Please sign in to comment.