Skip to content

Set the Django migrate command to run once or throttle when updating multiple instances #121

@mtinberg

Description

@mtinberg

When deploying/updating Netbox across two hosts that share a backend database everything works great in parallel except for running manage.py migrate, whichever host runs second fails sometimes because the first one is running DDL statements, which fails the rest of the playbook for that host requiring at least a second run to clean up or manual intervention to restart services.

I hotfixed this at my site by adding run_once: true to the migrate task so it only runs on the first host in the batch, which works great when limiting to just prod or qa instances but wouldn't work if someone was changing both at the same time. The serial keyword only works on the playbook level, and it's probably not worth it to make the whole deploy_netbox play serialized, if I wanted that I could just set --forks 1, but the throttle keyword should work for the individual task and may resolve this issue, but I haven't tested that yet.

It may also make sense to make the whole block throttle so that none of the manage.py steps which modify data have any chance to interfere with one another, while many probably can safely run in parallel, that may not be guaranteed.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions