Skip to content

Facilitate bulk redeployments from the Django shell.

Boros Gábor requested to merge smarnach/bulk-deploy into master

Created by: smarnach

In order to be able to run bulk deployments of appservers from the Django shell without congesting the Huey queue for periodic tasks and deployments triggered from the UI, this PR introduces a separate Huey queue for tasks started from the Django shell. This makes it possible to redeploy instances in bulk using simple loops in the shell.

Eventually we would like to be able to trigger bulk deployments from the GUI. Currently, the Django integration of Huey only supports a single queue to be configured per process, but it would be rather easy to change this.

To be able to mark the instances that failed or succeeded, the spawn_appserver() task got additional arguments for tags to apply in either case.

With these small changes applied, the redeployment of all instances tagged by tag could be executed like this:

success_tag = InstanceTag.objects.create(name=tag.name + "-succeeded")
failure_tag = InstanceTag.objects.create(name=tag.name + "-failed")
for instance in tag.openedxinstance_set.iterator():
    spawn_appserver(instance.ref.pk, success_tag=success_tag, failure_tag=failure_tag)

The failed instances can be retried using this code

for instance in failure_tag.openedxinstance_set.iterator():
    spawn_appserver(instance.ref.pk, success_tag=success_tag, failure_tag=failure_tag)

We can or course add convenience functions to make running this code even more convenient.

Merge request reports