Skip to content

[ENG-10768] Have a display of some form when the OSF is down for planned maintenance #11706

Open
mkovalua wants to merge 3 commits intoCenterForOpenScience:feature/pbs-26-6from
mkovalua:feature/ENG-10768
Open

[ENG-10768] Have a display of some form when the OSF is down for planned maintenance #11706
mkovalua wants to merge 3 commits intoCenterForOpenScience:feature/pbs-26-6from
mkovalua:feature/ENG-10768

Conversation

@mkovalua
Copy link
Copy Markdown
Contributor

@mkovalua mkovalua commented Apr 23, 2026

Ticket

Purpose

When OSF undergoes planned downtime for software releases, users who are unaware of the maintenance window have no way of knowing the site is intentionally offline — they simply experience a broken site. A backend maintenance mode is needed so that when enabled, the API halts normal request processing and signals to clients that the system is in maintenance.

Changes

return 503 for API if maintanence_mode is set to true

set maintenance mode via admin

8758-3bb9-4cb1-867c-eee081c8032e.mp4

Side Effects

QE Notes

CE Notes

Documentation

@mkovalua mkovalua marked this pull request as ready for review April 24, 2026 13:15
Copy link
Copy Markdown
Collaborator

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments. Also, please add some API tests to ensure that all the functionality is working properly.

Comment thread api/base/middleware.py Outdated
Comment on lines +144 to +145
if request.path.endswith(('/v2', '/v2/')):
return self.get_response(request)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why you did this, based on the ticket, but I don't think this is explicitly necessary. Having the /v2 route return just the information from the maintenance mode section below would be fine.

Comment thread api/base/middleware.py Outdated
{
'meta': {
'maintenance_mode': True,
'status_page': 'status',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is supposed to be https://status.cos.io.

Comment thread api/base/middleware.py
request.session = SessionStore()


class MaintenanceModeMiddleware:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super-familiar with Middleware in Django. Will this also prevent incoming requests from being processed (i.e. if someone POSTs or PATCHes something, will we prevent that from affecting the OSF DB)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, middleware calls for all requests and workflow goes to view only if MaintenanceMode.is_under_maintenance() is False

image

Copy link
Copy Markdown
Collaborator

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to remove special casing of the v2 endpoint. Also, please add an API test that attempts to make a change with a PATCH Request and it fails with maintenance mode on but succeeds with it off.

Comment on lines +10 to +13
def test_bypasses_v2_root_if_maintenance_mode_on(self, mock_maintenance, client):
response = client.get('/v2')
assert response.status_code != 503
mock_maintenance.assert_not_called()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I said we shouldn't special case the /v2/ endpoint. It should behave the same as the other endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants