Commit 6c00ebec authored by Georgios Gousios's avatar Georgios Gousios
Browse files

Reconciliation command documentation + config options

parent b673cfd8
......@@ -142,6 +142,35 @@ to Synnefo v0.3.
* Reconciliation process: On certain occasions, such as a Ganeti or
RabbitMQ failure, the VM state in the system's database may differ from
that in the Ganeti installation. The reconciliation process is designed
to bring the system's database in sync with what Ganeti knows about
each VM.
The reconciliation process can be triggered for all VMs using the command
./ reconcile --all
It is advised, though not strictly necessary, to run the reconciliation
process periodically, through cron. To avoid overloading the Ganeti
master, the periodic reconciliation process takes a staggered approach
to updating the VMs, which is configured through the following
* The parameter: RECONCILIATION_MIN, which specifies the
maximum time a VM can remain ``non-reconciled''. (default: 30 mins)
* The --interval option to the reconcile command, which declares the
interval time between reconciliation attempts (default: 1 min)
On each invocation of the reconcile command, the system will trigger a
reconciliation for ((num_all_vms/RECONCILIATION_MIN) * interval)
machines. Obviously the less the interval value and the more the
RECONCILIATION_MIN setting, the less load is going to be put on Ganeti.
- OS Specific instructions
* Debian Squeeze
......@@ -9,4 +9,3 @@ south==0.7.1
......@@ -29,11 +29,11 @@
# Reconcile VM state - Management Script
from import NoArgsCommand
from synnefo.db.models import VirtualMachine
from django.conf import settings
from datetime import datetime, timedelta
from optparse import make_option
from import BaseCommand
from synnefo.logic import amqp_connection
from synnefo.logic.amqp_connection import AMQPError
......@@ -41,20 +41,32 @@ from synnefo.logic.amqp_connection import AMQPError
import json
import sys
class Command(NoArgsCommand):
class Command(BaseCommand):
help = 'Reconcile VM status with the backend'
def handle_noargs(self, **options):
option_list = BaseCommand.option_list + (
make_option('--all', action='store_true', dest='all_vms', default=False,
help='Run the reconciliation function for all VMs, now'),
make_option('--interval', action='store', dest='interval', default=1,
help='Interval in minutes between reconciliations'),
def handle(self, all_vms = False, interval = 1, **options):
all = VirtualMachine.objects.all()
now =
last_update = timedelta(minutes = settings.RECONCILIATION_MIN)
not_updated = VirtualMachine.objects \
if not all_vms:
now =
last_update = timedelta(minutes = settings.RECONCILIATION_MIN)
not_updated = VirtualMachine.objects \
.filter(deleted = False) \
.filter(suspended = False) \
.filter(updated__lte = (now - last_update))
all = VirtualMachine.objects.all()
to_update = all.count() / settings.RECONCILIATION_MIN
to_update = ((all.count() / settings.RECONCILIATION_MIN) * interval)
to_update = all.count()
not_updated = all
vm_ids = map(lambda x:, not_updated[:to_update])
for vmid in vm_ids :
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment