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

middleware: implement maintenance mode middleware (bug 1927149) #145

Open
wants to merge 1 commit into
base: zeid/bug-1904616-update-uwsgi-config
Choose a base branch
from

Conversation

zzzeid
Copy link
Collaborator

@zzzeid zzzeid commented Oct 30, 2024

  • remove legacy hook code
  • add db fixture to some tests
  • move dockerflow urls to own namespaced module
  • add ConfigurationVariable to admin UI
  • return value of variables in get method instead of returning full object
  • add maintenance page template
  • add maintenance mode middleware, filter out excluded namespaces, urls
  • hide login/logout buttons when in maintenance mode
  • add maintenance command
  • check for pending migrations before enabling maintenance mode (default)

@zzzeid zzzeid changed the base branch from main to zeid/bug-1904616-update-uwsgi-config October 30, 2024 13:33
@zzzeid zzzeid changed the title Zeid/bug 1927149 maintenance mode middleware: implement maintenance mode middlewware (bug 1927149) Oct 30, 2024
@zzzeid zzzeid requested a review from shtrom October 30, 2024 13:41
@zzzeid zzzeid marked this pull request as ready for review October 30, 2024 20:01
@zzzeid zzzeid changed the title middleware: implement maintenance mode middlewware (bug 1927149) middleware: implement maintenance mode middleware (bug 1927149) Oct 30, 2024
Comment on lines +58 to +63
unapplied_migrations = (
subprocess.run(["lando", "migrate", "--check", "--noinput"]).returncode != 0
)

if force or unapplied_migrations:
action_mapping[action]()
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the migrations should be a separate command, that toggles the maintenance mode as needed. This way we could turn on maintenance mode for any other reason where we might not want to add the weight of migrations.

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, we could provide a flag such as --skip-migration to achieve the same thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was kind of the intention of the force parameter, though I do see your point. Maybe maintenance should modify the flags regardless, and instead we can create pre-deploy and post-deploy commands which can do the migration check instead.

@@ -10,7 +10,7 @@
)


def test_app_wide_headers_set(client):
def test_app_wide_headers_set(db, client):
Copy link
Member

Choose a reason for hiding this comment

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

Where does db come from? Is it a fixture? I can't find its definition (not that it impacts the tests).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. This is actually a fixture provided by pytest-django, though after going over the documentation again, it seems it is intended to be used in other fixtures, and not as a shortcut/alternative to marking the test with django_db.

Though it works as expected, I think it's better to explicitly mark those tests as needing the db. I'll file a bug to fix other occurrences in the future, but will change these in this PR.

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