Skip to content

Commit

Permalink
Update maintenance page (#2526)
Browse files Browse the repository at this point in the history
  • Loading branch information
vertism authored Dec 17, 2024
1 parent 174dce8 commit 13afdd9
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 13 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ jobs:
- name: Rollout restart deployment
run: |
kubectl apply -f config/kubernetes/development/configmap.yaml -n ${KUBE_NAMESPACE}
kubectl set image -f config/kubernetes/development/migrations.yaml \
migrations="${{ vars.ECR_URL }}:$SHA" --local --output yaml | kubectl apply -n ${KUBE_NAMESPACE} -f -
Expand Down Expand Up @@ -213,8 +211,6 @@ jobs:
- name: Rollout restart deployment
run: |
kubectl apply -f config/kubernetes/staging/configmap.yaml -n ${KUBE_NAMESPACE}
kubectl set image -f config/kubernetes/staging/migrations.yaml \
migrations="${{ vars.ECR_URL }}:$SHA" --local --output yaml | kubectl apply -n ${KUBE_NAMESPACE} -f -
Expand Down Expand Up @@ -315,8 +311,6 @@ jobs:
- name: Rollout restart deployment
run: |
kubectl apply -f config/kubernetes/qa/configmap.yaml -n ${KUBE_NAMESPACE}
kubectl set image -f config/kubernetes/qa/migrations.yaml \
migrations="${{ vars.ECR_URL }}:$SHA" --local --output yaml | kubectl apply -n ${KUBE_NAMESPACE} -f -
Expand Down Expand Up @@ -418,8 +412,6 @@ jobs:
- name: Rollout restart deployment
run: |
kubectl apply -f config/kubernetes/production/configmap.yaml -n ${KUBE_NAMESPACE}
kubectl set image -f config/kubernetes/production/migrations.yaml \
migrations="${{ vars.ECR_URL }}:$SHA" --local --output yaml | kubectl apply -n ${KUBE_NAMESPACE} -f -
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def set_user
def maintenance_mode
redirect_to "/" and return unless maintenance_mode_on?

render layout: nil, file: "layouts/maintenance"
render "layouts/maintenance", layout: nil
end

private
Expand All @@ -43,7 +43,7 @@ def check_maintenance_mode
end

def maintenance_mode_on?
File.exist? Rails.root.join("maintenance.txt")
ENV["MAINTENANCE_MODE"] == "ON"
end

def download_csv_request?
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/heartbeat_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "sidekiq/api"

class HeartbeatController < ApplicationController
skip_before_action :check_maintenance_mode

respond_to :json

def ping
Expand Down
3 changes: 3 additions & 0 deletions app/views/cases/filters/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

= render partial: 'layouts/header'

- content_for :alert_banner
= render partial: 'layouts/alert_banner'

- if @can_add_case
.grid-row
.column-full.button-holder
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

= csrf_meta_tags
= render partial: 'layouts/phase_banner'
= yield :alert_banner

.grid-row
.column-full
Expand Down
6 changes: 5 additions & 1 deletion app/views/layouts/maintenance.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- content_for :page_title do
= "Sorry, the service is unavailable – #{t('common.service_name')} – GOV.UK"

- content_for :logo_link_title do
= "Return to home page"

Expand Down Expand Up @@ -37,7 +40,8 @@
main#content
h1.page-heading style="border-bottom: 1px solid #000"
= "Service down for planned maintenance"
p.lede This service will be down for essential maintenance during the afternoon of Wednesday 13 November. You will not have access after 13.00 on this day – the site will likely resume service after business hours. Apologies for the inconvenience.
p.lede This service is down for essential maintenance from 17:30 on Tuesday 17 December.<br>You will not have access from this time.<br>The site will resume service later in the evening of 17 December.
p.lede We apologies for any inconvenience this may cause.

- content_for :body_end do
= javascript_include_tag "application"
Expand Down
1 change: 1 addition & 0 deletions config/kubernetes/development/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ data:
SENTRY_ENVIRONMENT: 'development'
OMNIAUTH_AZURE_CLIENT_ID: e807f454-c5ce-45d4-a9a7-4656c0aff9db
OMNIAUTH_AZURE_TENANT_ID: c6874728-71e6-41fe-a9e1-2e8c36776ad8
MAINTENANCE_MODE: 'ON'
kind: ConfigMap
metadata:
name: environment-variables
1 change: 1 addition & 0 deletions config/kubernetes/production/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ data:
RAILS_ENV: 'production'
RAILS_SERVE_STATIC_FILES: 'true'
SENTRY_ENVIRONMENT: 'production'
MAINTENANCE_MODE: 'OFF'
kind: ConfigMap
metadata:
name: environment-variables
1 change: 1 addition & 0 deletions config/kubernetes/qa/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ data:
SENTRY_ENVIRONMENT: 'qa'
OMNIAUTH_AZURE_CLIENT_ID: e807f454-c5ce-45d4-a9a7-4656c0aff9db
OMNIAUTH_AZURE_TENANT_ID: c6874728-71e6-41fe-a9e1-2e8c36776ad8
MAINTENANCE_MODE: 'OFF'
kind: ConfigMap
metadata:
name: environment-variables
2 changes: 1 addition & 1 deletion config/kubernetes/staging/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data:
SENTRY_ENVIRONMENT: 'staging'
OMNIAUTH_AZURE_CLIENT_ID: e807f454-c5ce-45d4-a9a7-4656c0aff9db
OMNIAUTH_AZURE_TENANT_ID: c6874728-71e6-41fe-a9e1-2e8c36776ad8
MAINTENANCE_MODE: 'OFF'
kind: ConfigMap
metadata:
name: environment-variables

2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ en:

common:
accessibility: Accessibility
alert_banner_html: "This service will be down for essential maintenance during the afternoon of Wednesday 14th April. You will not have access after 13.00 on this day and the site will resume service after business hours. Please contact <a href='mailto:[email protected]'>[email protected]</a> if you have any queries. Apologies for the inconvenience."
alert_banner_html: "This service will be down for essential maintenance from 17:30 on Tuesday 17 December. The site will resume service after business hours. Please contact <a href='mailto:[email protected]'>[email protected]</a> if you have any queries. Apologies for the inconvenience."
case:
actions: Actions
answered_in_time: Answered in time
Expand Down
Binary file added public/favicon.ico
Binary file not shown.
35 changes: 35 additions & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "rails_helper"

RSpec.describe ApplicationController, type: :controller do
let(:user) { create(:user) }

xdescribe "#maintenance_mode" do
before do
sign_in user
end

context "when maintenance mode is off" do
it "redirects requests for the maintenance page to the homepage" do
get :maintenance_mode
expect(response).to redirect_to("/")
end
end

context "when maintenance mode is on" do
before do
allow(controller).to receive(:maintenance_mode_on?).and_return true
end

it "renders the maintenance page" do
get :maintenance_mode
expect(response).to render_template(:maintenance)
end

it "redirects other requests to the maintenance page" do
@controller = Cases::FiltersController.new
get :open
expect(response).to redirect_to("/maintenance")
end
end
end
end

0 comments on commit 13afdd9

Please sign in to comment.