Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use /actuator/health for backend health checks #6777

Merged
merged 6 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ protected void configure(HttpSecurity http) throws Exception {
http.cors()
.and()
.authorizeRequests()
.antMatchers("/")
.permitAll()
.antMatchers(HttpMethod.OPTIONS, "/**")
.permitAll()
.antMatchers(HttpMethod.GET, WebConfiguration.HEALTH_CHECK)
.permitAll()
.antMatchers("/echo/**", "/authTest/**")
.permitAll()
.requestMatchers(EndpointRequest.to(HealthEndpoint.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ protected void configure(HttpSecurity http) throws Exception {
http.cors()
.and()
.authorizeRequests()
.antMatchers("/")
.permitAll()
.antMatchers(HttpMethod.OPTIONS, "/**")
.permitAll()
.antMatchers(HttpMethod.GET, WebConfiguration.HEALTH_CHECK)
.permitAll()
.antMatchers("/echo/**", "/authTest/**")
.permitAll()
.requestMatchers(EndpointRequest.to(HealthEndpoint.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ConditionalOnWebApplication
public class WebConfiguration implements WebMvcConfigurer {

public static final String HEALTH_CHECK = "/health";
public static final String PATIENT_EXPERIENCE = "/pxp/**";
public static final String TWILIO_CALLBACK = "/pxp/callback";
public static final String RS_QUEUE_CALLBACK = "/reportstream/callback";
Expand All @@ -34,11 +31,6 @@ public class WebConfiguration implements WebMvcConfigurer {

@Autowired private RestLoggingInterceptor _loggingInterceptor;

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addStatusController(HEALTH_CHECK, HttpStatus.OK);
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(_loggingInterceptor).excludePathPatterns(GRAPH_QL);
Expand Down
8 changes: 0 additions & 8 deletions backend/src/main/resources/static/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ EOF
SPEC_PATH="cypress/e2e/**"
TEST_ENV="https://localhost.simplereport.gov"
CHECK_COMMIT="$(git rev-parse HEAD)"
BACKEND_URL_PATH="/api/health"
BACKEND_URL_PATH="/api/actuator/health"
PUBLIC_URL="/app"
FRONTEND_URL_PATH="/health/commit"
RUN_OPEN=false
Expand Down
6 changes: 3 additions & 3 deletions lighthouse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
echo "Starting docker containers"
docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d --quiet-pull

echo "Waiting for backend to start at https://localhost.simplereport.gov/api/health"
echo "Waiting for backend to start at https://localhost.simplereport.gov/api/actuator/health"
http_response=0
polls=0
while [[ $http_response != "200" && $polls -lt 180 ]]; do
((polls++))
sleep 2
echo "Waiting for backend to start at https://localhost.simplereport.gov/api/health"
http_response=$(curl -skL -w "%{http_code}" "https://localhost.simplereport.gov/api/health")
echo "Waiting for backend to start at https://localhost.simplereport.gov/api/actuator/health"
http_response=$(curl -skL -w "%{http_code}" "https://localhost.simplereport.gov/api/actuator/health")
done
if [[ $http_response -ne 200 ]]; then
echo 'Backend never started. Exiting...'
Expand Down
34 changes: 34 additions & 0 deletions ops/services/app_gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ resource "azurerm_application_gateway" "load_balancer" {
protocol = "Http"
request_timeout = 60
pick_host_name_from_backend_address = true
probe_name = "be-http"
}

backend_http_settings {
Expand All @@ -133,6 +134,37 @@ resource "azurerm_application_gateway" "load_balancer" {
protocol = "Https"
request_timeout = 60
pick_host_name_from_backend_address = true
probe_name = "be-https"
}

probe {
name = "be-http"
interval = 10
path = "/actuator/health"
pick_host_name_from_backend_http_settings = true
protocol = "Http"
timeout = 10
unhealthy_threshold = 3

match {
body = "UP"
status_code = [200]
}
}

probe {
name = "be-https"
interval = 10
path = "/actuator/health"
pick_host_name_from_backend_http_settings = true
protocol = "Https"
timeout = 10
unhealthy_threshold = 3

match {
body = "UP"
status_code = [200]
}
}

# ------- Backend Metabase App -------------------------
Expand Down Expand Up @@ -174,6 +206,7 @@ resource "azurerm_application_gateway" "load_balancer" {
protocol = "Http"
request_timeout = 20
pick_host_name_from_backend_address = true
probe_name = "be-http"
}

backend_http_settings {
Expand All @@ -183,6 +216,7 @@ resource "azurerm_application_gateway" "load_balancer" {
protocol = "Https"
request_timeout = 20
pick_host_name_from_backend_address = true
probe_name = "be-https"
}

# ------- Listeners -------------------------
Expand Down
4 changes: 2 additions & 2 deletions ops/services/app_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ resource "azurerm_linux_web_app" "service" {
# Configure Docker Image to load on start
site_config {
always_on = "true"
health_check_path = "/health"
health_check_path = "/actuator/health"
health_check_eviction_time_in_min = 5
scm_minimum_tls_version = "1.2"
use_32_bit_worker = false
Expand Down Expand Up @@ -90,7 +90,7 @@ resource "azurerm_linux_web_app_slot" "staging" {
# Configure Docker Image to load on start
site_config {
always_on = "true"
health_check_path = "/health"
health_check_path = "/actuator/health"
health_check_eviction_time_in_min = 5
scm_minimum_tls_version = "1.2"
use_32_bit_worker = false
Expand Down