Don't queue flushes without --wait

Don't try to queue up a flush when there is already a flush lock; direct
the user to use --wait (which will actually wait before triggering the
new action), or try again later.
This commit is contained in:
Joshua Boniface 2019-06-27 14:36:58 -04:00
parent d28b1ba133
commit 77e215b0eb
1 changed files with 6 additions and 2 deletions

View File

@ -150,7 +150,9 @@ def flush_node(zk_conn, node, wait):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node) return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
if zkhandler.readdata(zk_conn, '/locks/flush_lock') == 'True': if zkhandler.readdata(zk_conn, '/locks/flush_lock') == 'True':
retmsg = 'Flushing hypervisor {} of running VMs. A flush lock currently exists; flush will continue once the lock is freed.'.format(node) retmsg = 'A lock currently exists; use --wait to wait for it, or try again later.'.format(node)
if not wait:
return False, retmsg
lock_wait = True lock_wait = True
else: else:
retmsg = 'Flushing hypervisor {} of running VMs.'.format(node) retmsg = 'Flushing hypervisor {} of running VMs.'.format(node)
@ -185,7 +187,9 @@ def ready_node(zk_conn, node, wait):
return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node) return False, 'ERROR: No node named "{}" is present in the cluster.'.format(node)
if zkhandler.readdata(zk_conn, '/locks/flush_lock') == 'True': if zkhandler.readdata(zk_conn, '/locks/flush_lock') == 'True':
retmsg = 'Restoring hypervisor {} to active service. A flush lock currently exists; unflush will continue once the lock is freed.'.format(node) retmsg = 'A lock currently exists; use --wait to wait for it, or try again later.'.format(node)
if not wait:
return False, retmsg
lock_wait = True lock_wait = True
else: else:
retmsg = 'Restoring hypervisor {} to active service.'.format(node) retmsg = 'Restoring hypervisor {} to active service.'.format(node)